summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--starling/node-2d.scm65
1 files changed, 60 insertions, 5 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index 43e073e..93d02c8 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -59,10 +59,18 @@
<node-2d>
origin
+ origin-x
+ origin-y
position
+ position-x
+ position-y
rotation
scale
+ scale-x
+ scale-y
skew
+ skew-x
+ skew-y
local-matrix
world-matrix
dirty!
@@ -215,11 +223,58 @@
;;;
(define-class <node-2d> (<node>)
- (origin #:getter origin #:init-form (vec2 0.0 0.0) #:init-keyword #:origin)
- (position #:getter position #:init-form (vec2 0.0 0.0) #:init-keyword #:position)
- (rotation #:accessor rotation #:init-form 0.0 #:init-keyword #:rotation)
- (scale #:getter scale #:init-form (vec2 1.0 1.0) #:init-keyword #:scale)
- (skew #:getter skew #:init-form (vec2 0.0 0.0) #:init-keyword #:skew)
+ ;; Transformation components: origin, position, rotation, scale, and
+ ;; skew.
+ (origin #:accessor origin #:init-form (vec2 0.0 0.0) #:init-keyword #:origin
+ #:watch? #t)
+ (origin-x #:accessor origin-x #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-x (origin node)))
+ #:slot-set! (lambda (node x)
+ (set-vec2-x! (origin node) x)
+ (dirty! node)))
+ (origin-y #:accessor origin-y #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-y (origin node)))
+ #:slot-set! (lambda (node y)
+ (set-vec2-y! (origin node) y)
+ (dirty! node)))
+ (position #:accessor position #:init-form (vec2 0.0 0.0)
+ #:init-keyword #:position #:watch? #t)
+ (position-x #:accessor position-x #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-x (position node)))
+ #:slot-set! (lambda (node x)
+ (set-vec2-x! (position node) x)
+ (dirty! node)))
+ (position-y #:accessor y #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-y (position node)))
+ #:slot-set! (lambda (node y)
+ (set-vec2-y! (position node) y)
+ (dirty! node)))
+ (rotation #:accessor rotation #:init-form 0.0 #:init-keyword #:rotation
+ #:watch? #t)
+ (scale #:accessor scale #:init-form (vec2 1.0 1.0) #:init-keyword #:scale
+ #:watch? #t)
+ (scale-x #:accessor scale-x #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-x (scale node)))
+ #:slot-set! (lambda (node x)
+ (set-vec2-x! (scale node) x)
+ (dirty! node)))
+ (scale-y #:accessor scale-y #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-y (scale node)))
+ #:slot-set! (lambda (node y)
+ (set-vec2-y! (scale node) y)
+ (dirty! node)))
+ (skew #:accessor skew #:init-form (vec2 0.0 0.0) #:init-keyword #:skew
+ #:watch? #t)
+ (skew-x #:accessor skew-x #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-x (skew node)))
+ #:slot-set! (lambda (node x)
+ (set-vec2-x! (skew node) x)
+ (dirty! node)))
+ (skew-y #:accessor skew-y #:allocation #:virtual
+ #:slot-ref (lambda (node) (vec2-y (skew node)))
+ #:slot-set! (lambda (node y)
+ (set-vec2-y! (skew node) y)
+ (dirty! node)))
;; Some extra position vectors for defeating "temporal aliasing"
;; when rendering.
(last-position #:getter last-position #:init-form (vec2 0.0 0.0))