aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-18 09:07:05 -0500
committerColin Okay <colin@cicadas.surf>2022-07-18 09:07:05 -0500
commit55ad89e92a9796979d6f075afba74a6076f45d6d (patch)
treebf57ebc00f4673a11176dbf1a3261f145c5a2f4a
parent03ce5afadae02847aadd7ae89ce4779ee0b7e6e4 (diff)
[doc] docstring on with-grid-bezier
-rw-r--r--examples/11-canvas-geometry.lisp2
-rw-r--r--src/grid-geometry.lisp16
2 files changed, 14 insertions, 4 deletions
diff --git a/examples/11-canvas-geometry.lisp b/examples/11-canvas-geometry.lisp
index 325cbe4..7103663 100644
--- a/examples/11-canvas-geometry.lisp
+++ b/examples/11-canvas-geometry.lisp
@@ -61,7 +61,7 @@
(200 300)
(0 400)
(40 250))))
- (ww::with-grid-bezier (x y) (control-points :step 0.001)
+ (ww::with-grid-bezier (x y) (control-points :count 80)
(ww::with-grid-rect (rx ry) ((- x 2) (- y 2) (+ x 2) (+ y 2))
(ww::with-pixel (r g b a) (ww::pixel canvas rx ry)
(setf g 255)))))
diff --git a/src/grid-geometry.lisp b/src/grid-geometry.lisp
index b23b207..c046032 100644
--- a/src/grid-geometry.lisp
+++ b/src/grid-geometry.lisp
@@ -102,9 +102,19 @@ top right corners of the bounding box for POLY "
(defmacro with-grid-bezier
- ((x y) (control-pts &key (step 0.001)) &body body)
- (with-gensyms (fn points a)
- `(let* ((,points
+ ((x y) (control-pts &key (count 1000)) &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
+point is always the first control point and the last point is always
+the last control point. Use high counts for smooth curves, as needed.
+
+Evaluates the BODY with X Y bound to a point on the bezier curve.
+"
+ (with-gensyms (fn points a step)
+ `(let* ((,step
+ (/ 1.0 ,count))
+ (,points
,control-pts)
(,fn
(apply #'bezier-lambda ,points)))