aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/11-canvas-geometry.lisp
blob: 1147ed9f14aafd13338246a00cd4a1a4fb3a4708 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)))