diff options
Diffstat (limited to 'starling/node-2d.scm')
-rw-r--r-- | starling/node-2d.scm | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm index 142da31..6d83da2 100644 --- a/starling/node-2d.scm +++ b/starling/node-2d.scm @@ -31,7 +31,7 @@ #:use-module (chickadee graphics font) #:use-module (chickadee graphics framebuffer) #:use-module (chickadee graphics particles) - #:use-module (chickadee graphics shapes) + #:use-module (chickadee graphics path) #:use-module (chickadee graphics sprite) #:use-module (chickadee graphics texture) #:use-module (chickadee graphics tiled) @@ -99,9 +99,8 @@ <sprite-batch> batch - <filled-rect> - region - color + <path> + painter <label> font @@ -123,13 +122,13 @@ ;; node and follow it around. (define (default-resolution) - (match (current-window-size) - ((width height) - (vec2 width height)))) + (call-with-values current-window-size + (lambda (width height) + (vec2 width height)))) (define (default-viewport) - (match (current-window-size) - ((width height) + (call-with-values current-window-size + (lambda (width height) (make-viewport 0 0 width height)))) (define-class <camera-2d> () @@ -533,15 +532,23 @@ ;;; -;;; Filled Rectangle +;;; Vector Path ;;; -(define-class <filled-rect> (<node-2d>) - (region #:accessor region #:init-keyword #:region) - (color #:accessor color #:init-form black #:init-keyword #:color)) +(define-class <path> (<node-2d>) + (painter #:accessor painter #:init-keyword #:painter) + (canvas #:accessor canvas #:init-thunk make-empty-canvas)) -(define-method (render (r <filled-rect>) alpha) - (draw-filled-rect (region r) (color r) #:matrix (world-matrix r))) +(define-method (initialize (path <path>) args) + (next-method) + (set-canvas-painter! (canvas path) (painter path))) + +(define-method ((setter painter) (path <path>) p) + (slot-set! path 'painter p) + (set-canvas-painter! (canvas path) p)) + +(define-method (render (path <path>) alpha) + (draw-canvas* (canvas path) (world-matrix path))) ;;; |