aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/11-canvas-geometry.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-17 12:42:42 -0500
committerColin Okay <colin@cicadas.surf>2022-07-17 12:42:42 -0500
commit53019e4770d1cf9999201e261fd6d93ab3c0d849 (patch)
treee3ff351b917577149705271c42aa877b665e6cd3 /examples/11-canvas-geometry.lisp
parentb72153a73875fc0081d072b90ac411c0eaef08a8 (diff)
[wip]
Diffstat (limited to 'examples/11-canvas-geometry.lisp')
-rw-r--r--examples/11-canvas-geometry.lisp32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/11-canvas-geometry.lisp b/examples/11-canvas-geometry.lisp
new file mode 100644
index 0000000..1147ed9
--- /dev/null
+++ b/examples/11-canvas-geometry.lisp
@@ -0,0 +1,32 @@
+;;;; examples/11-canvas-geometry.lisp
+
+(defpackage #:ww.examples/11
+ (:use #:cl)
+ (:export #:start))
+
+(in-package :ww.examples/11)
+
+(defclass geo-demo (ww:application) ())
+
+(defmethod ww:boot ((app geo-demo))
+ (let ((canvas
+ (make-instance 'ww:canvas
+ :pixel-width 500
+ :pixel-height 500)))
+ ;; stretch canvas over the whole app
+ (setf (ww:width canvas) (ww::application-width app)
+ (ww:height canvas) (ww::application-height app))
+
+ ;; add it to the display tree
+ (ww:add-unit app canvas)
+
+ ;; draw a circle
+ (ww::with-grid-circle (x y) (50 50 30)
+ (ww::with-pixel (r g b a) (ww::pixel canvas x y)
+ (setf r (mod (* x y) 255)
+ g x
+ b y)))
+
+
+ ;; blit the canvas
+ (ww::blit canvas)))