diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-15 16:35:06 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-15 16:35:06 -0500 |
commit | b70a404c640785010ecad52af29b4a96184b2c7e (patch) | |
tree | 939b271a963786e649eb0fc1c8aa7e640eb4c89f /examples/10-canvas.lisp | |
parent | f2f49f3beae4fb62292e9a80e7ddda64de098771 (diff) |
[add] working canvas demo!
Diffstat (limited to 'examples/10-canvas.lisp')
-rw-r--r-- | examples/10-canvas.lisp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/10-canvas.lisp b/examples/10-canvas.lisp new file mode 100644 index 0000000..cdade2b --- /dev/null +++ b/examples/10-canvas.lisp @@ -0,0 +1,47 @@ +;;;; examples/10-canvas.lisp + +(defpackage #:ww.examples/10 + (:use #:cl) + (:export #:start) + (:import-from #:defclass-std #:defclass/std)) + +(in-package #:ww.examples/10) + +;;; CLASSES + +(defclass/std canvas-example (ww::application) + ()) + +(defmethod ww::boot ((app canvas-example)) + "Adds the intro text and sets up the start button handler." + (let ((c (make-instance + 'ww::canvas + :x 100 :y 100 + :pixel-height 100 + :pixel-width 100))) + + (ww::with-pixels-rect (x y r g b a) (c) + (setf r (- 255 x) + g (- 255 y) + b (+ x y))) + + (ww::blit c) + ;(ww:scale-by c 100) + (ww:add-unit app c))) + +(defun start (&optional (scale 1.0)) + (ww::start + (make-instance + 'canvas-example + :fps 30 + :width (round (* 800 scale)) + :height (round (* 600 scale)) + :scale scale + :refocus-on-mousedown-p nil + :title "canvas demo" + :asset-root + (merge-pathnames + "examples/" + (asdf:system-source-directory :wheelwork))))) + + |