diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-20 17:01:26 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-20 17:01:26 -0500 |
commit | 4da8c16d60a61eff5a1cb03e6573a4d43b3abd09 (patch) | |
tree | a527e12db68060b81bdd2430ddb0d3ede1d384c3 | |
parent | 030111b871ab1a75f299411b8e9cadad13d06b8d (diff) |
[refactor] odd behavior in with-grid-bezier
-rw-r--r-- | examples/12-canvas-drawing-language.lisp | 9 | ||||
-rw-r--r-- | src/grid-geometry.lisp | 6 |
2 files changed, 7 insertions, 8 deletions
diff --git a/examples/12-canvas-drawing-language.lisp b/examples/12-canvas-drawing-language.lisp index 8020550..0713d90 100644 --- a/examples/12-canvas-drawing-language.lisp +++ b/examples/12-canvas-drawing-language.lisp @@ -57,7 +57,7 @@ (defun flower (&optional (petals 5)) (ww:with-pen (:width 1) (let ((r ; radius - (sqrt (+ (* 25 25) (* 100 100)))) + #.(sqrt (+ (* 25 25) (* 100 100)))) (psw ; petal semi-width (* pi 0.08))) ;; for each angle a between 0 and 2π draw a petal as a bezier @@ -74,7 +74,7 @@ (ww:fill-rel-bezier ctls 12) ;; draw border of each petal (ww:with-pen (:color (list 0 50 200 255)) - (ww:stroke-rel-bezier ctls 12)))))) + (ww:stroke-rel-bezier ctls 20)))))) (defun draw-stuff (canvas) (ww:with-canvas canvas @@ -86,8 +86,7 @@ (ww:with-pen (:color #'lower-the-bluer :width 2) ;; draw a flower stem (ww:stroke-bezier - '((0 0) (200 120) (50 350) (200 100) (300 400)) - 12) + '((0 0) (200 120) (50 350) (200 100) (300 400))) ;; draw a flower (flower 28)) @@ -116,7 +115,7 @@ (ww:start (make-instance 'canvas-lang-demo - :fps 10 + :fps 3 :width side :height side :title "Canvas demo"))) diff --git a/src/grid-geometry.lisp b/src/grid-geometry.lisp index 5fdfdd8..3597e75 100644 --- a/src/grid-geometry.lisp +++ b/src/grid-geometry.lisp @@ -102,7 +102,7 @@ top right corners of the bounding box for POLY " (defmacro with-grid-bezier - ((x y) (control-pts &key (count 1000)) &body body) + ((x y) (control-pts &key (count 100)) &body body) "CONTROL-POINTS is an expression that evalueates to a list of (X Y) pairs, these are the control points for the curve.. COUNT is the number of points on the bezier curve that will be calclated. The first @@ -118,7 +118,7 @@ Evaluates the BODY with X Y bound to a point on the bezier curve. ,control-pts) (,fn (apply #'bezier-lambda ,points))) - (loop for ,a from 0.0 to 1.0 by ,step - for (,x ,y) = (mapcar #'round (funcall ,fn ,a)) + (loop for ,a from 0.0 to (+ 1.0 ,step) by ,step + for (,x ,y) = (mapcar #'round (funcall ,fn (clamp 0 ,a 1.0))) do ,@body)))) |