# HG changeset patch # User Steve Losh # Date 1521847685 14400 # Node ID 2c3734fe6cd178624f24c252f61a2a08b252fd6d # Parent b098ec32e059a840818cb01b63a47a5cf3702822 Add plot output diff -r b098ec32e059 -r 2c3734fe6cd1 flax.asd --- a/flax.asd Fri Mar 23 19:18:28 2018 -0400 +++ b/flax.asd Fri Mar 23 19:28:05 2018 -0400 @@ -32,7 +32,8 @@ (:module "drawing" :serial t :components ((:file "api") (:file "png") - (:file "svg"))) + (:file "svg") + (:file "plot"))) (:module "looms" :serial nil :components ((:file "001-triangles") diff -r b098ec32e059 -r 2c3734fe6cd1 src/drawing/api.lisp --- a/src/drawing/api.lisp Fri Mar 23 19:18:28 2018 -0400 +++ b/src/drawing/api.lisp Fri Mar 23 19:28:05 2018 -0400 @@ -183,9 +183,16 @@ (defgeneric write-file (canvas filename)) +;;;; File Extensions ---------------------------------------------------------- +(defgeneric file-extension (type)) + +(defmethod file-extension (type) + (string-downcase (symbol-name type))) + + ;;;; Toplevel ----------------------------------------------------------------- (defun full-filename (filename canvas-type) - (format nil "~A.~A" filename (string-downcase (symbol-name canvas-type)))) + (format nil "~A.~A" filename (file-extension canvas-type))) (defmacro with-rendering ((canvas-symbol canvas-type filename width height &key diff -r b098ec32e059 -r 2c3734fe6cd1 src/drawing/plot.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/drawing/plot.lisp Fri Mar 23 19:28:05 2018 -0400 @@ -0,0 +1,18 @@ +(in-package :flax.drawing) + +;;; A plot is an SVG without the square background. +;;; TODO: shell out to svgsort automatically? + + +(defclass* (plot-canvas :conc-name "") (svg-canvas) ()) + +(defmethod make-canvas ((type (eql :plot)) &key height width) + (let ((scene (svg:make-svg-toplevel 'svg:svg-1.1-toplevel + :height height :width width))) + (make-instance 'plot-canvas + :height height + :width width + :scene scene))) + +(defmethod file-extension ((type (eql :plot))) + "svg") diff -r b098ec32e059 -r 2c3734fe6cd1 src/looms/004-turtle-curves.lisp --- a/src/looms/004-turtle-curves.lisp Fri Mar 23 19:18:28 2018 -0400 +++ b/src/looms/004-turtle-curves.lisp Fri Mar 23 19:28:05 2018 -0400 @@ -314,9 +314,9 @@ -;; (time (loom 12 "out" :svg 800 800 +;; (time (loom 12 "out" :plot 800 800 ;; ;; :l-system *hexagonal-gosper-curve* -;; ;; :iterations 5 +;; :iterations 5 ;; ;; :starting-angle (- 1/4tau) ;; ))