aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-20 08:43:16 -0500
committerColin Okay <colin@cicadas.surf>2022-07-20 08:43:16 -0500
commitd8ce1f0a9cfea879864fb93b7ef960b5490cf50c (patch)
tree1b3612081f3e1e25dafc4d5b8a91743690242307
parente65d4756e667128f3708e3938587ecfde0736e09 (diff)
[example] added flower
-rw-r--r--examples/12-canvas-drawing-language.lisp35
1 files changed, 25 insertions, 10 deletions
diff --git a/examples/12-canvas-drawing-language.lisp b/examples/12-canvas-drawing-language.lisp
index c87876c..24008c2 100644
--- a/examples/12-canvas-drawing-language.lisp
+++ b/examples/12-canvas-drawing-language.lisp
@@ -21,11 +21,11 @@
(defun triangle-at (x y)
(ww::move-to x y)
- (ww::canvas-pen-color 0 200 200 255)
+ (ww::canvas-pen-color (list 0 200 200 255))
(ww::stroke-rel 150 0)
- (ww::canvas-pen-color 0 0 200 255)
+ (ww::canvas-pen-color (list 0 0 200 255))
(ww::stroke-rel -50 100)
- (ww::canvas-pen-color 0 200 0 255)
+ (ww::canvas-pen-color (list 0 200 0 255))
(ww::stroke-rel -100 -100))
(defun filled-triangle-at (x y)
@@ -46,17 +46,32 @@
(mod (* x y) 256)
255))
+(defun flower (&optional (petals 5))
+ (ww::canvas-pen-width 1)
+ (let ((r (sqrt (+ (* 25 25) (* 100 100))))
+ (psw (* pi 0.08)))
+ (loop for a from 0 to (* 2 pi) by (/ (* 2 pi) petals) do
+ (ww::stroke-rel-bezier
+ (list (list (* r (sin (- a psw)))
+ (* r (cos (- a psw))))
+ (list (* r (sin (+ a psw)))
+ (* r (cos (+ a psw))))
+ (list 0 0))
+ 12))))
+
(defun draw-stuff (canvas)
(ww::with-canvas canvas
- (ww::canvas-pen-color-function #'plaid1)
+ (ww::canvas-pen-color #'plaid1)
(filled-triangle-at 250 200)
- (ww::canvas-pen-color-function #'lower-the-bluer)
(ww::canvas-pen-width 2)
- (ww::stroke-bezier
- '((0 0) (200 120) (50 350) (200 100) (300 400))
- 1000)
- ()
- (ww::canvas-pen-color-function)
+
+ ;; temporarily use a different pen
+ (ww::with-pen-color #'lower-the-bluer
+ (ww::stroke-bezier
+ '((0 0) (200 120) (50 350) (200 100) (300 400))
+ 12)) ;; back to plaid pen after this
+
+ (flower 28)
(ww::canvas-pen-width 1)
(dotimes (x 50)
(when (evenp x)