aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-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)