aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-07-20 13:27:15 -0500
committerColin Okay <okay@toyful.space>2022-07-20 13:27:15 -0500
commit452021d2cb82d02baab0d54b6e3f585c07cff518 (patch)
treef51bda6632a1c813f7795b6ac42ac51ed555b3c3 /examples
parent613f3381583537033e03285ab3f9242bbfbeba65 (diff)
[example] tweaking
Diffstat (limited to 'examples')
-rw-r--r--examples/12-canvas-drawing-language.lisp39
1 files changed, 20 insertions, 19 deletions
diff --git a/examples/12-canvas-drawing-language.lisp b/examples/12-canvas-drawing-language.lisp
index 43d2dea..dcc557d 100644
--- a/examples/12-canvas-drawing-language.lisp
+++ b/examples/12-canvas-drawing-language.lisp
@@ -53,25 +53,26 @@
;; draws a "flower" like pinwheel using bezier curves
(defun flower (&optional (petals 5))
- (ww::canvas-pen-width 1)
- (let ((r ; radius
- (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
- ;; curve. the curve uses two control points that are R away from
- ;; the starting point and PSW radians on either side of the line
- ;; at angle a
- (loop for a from 0 to (* 2 pi) by (/ (* 2 pi) petals)
- for ls = (list (list (* r (sin (- a psw)))
- (* r (cos (- a psw))))
- (list (* r (sin (+ a psw)))
- (* r (cos (+ a psw))))
- (list 0 0))
- do
- (ww::fill-rel-bezier ls 12)
- (ww::with-pen (:color (list 0 0 0 255) :width 1)
- (ww::stroke-rel-bezier ls 12)))))
+ (ww::with-pen (:width 1)
+ (let ((r ; radius
+ (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
+ ;; curve. the curve uses two control points that are R away from
+ ;; the starting point and PSW radians on either side of the line
+ ;; at angle a
+ (loop for a from 0 to (* 2 pi) by (/ (* 2 pi) petals)
+ for ls = (list (list (* r (sin (- a psw)))
+ (* r (cos (- a psw))))
+ (list (* r (sin (+ a psw)))
+ (* r (cos (+ a psw))))
+ (list 0 0))
+ do
+ (ww::fill-rel-bezier ls 12)
+ ;; draw border of each petal
+ (ww::with-pen (:color (list 0 50 200 255))
+ (ww::stroke-rel-bezier ls 12))))))
(defun draw-stuff (canvas)
(ww::with-canvas canvas