diff options
author | David Thompson <dthompson2@worcester.edu> | 2022-12-28 12:18:06 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2022-12-28 12:18:33 -0500 |
commit | 9b19ea91bd5672280238f4132153c5ef16ba127d (patch) | |
tree | 5d0fea4ce08defb20856cd3d32b854cf824e44e3 | |
parent | 13479fde47ce622a473eee876484c2fad74cb4a0 (diff) |
node-2d: Fix width/height init args bug.
-rw-r--r-- | catbird/node-2d.scm | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/catbird/node-2d.scm b/catbird/node-2d.scm index a81e2a6..9199536 100644 --- a/catbird/node-2d.scm +++ b/catbird/node-2d.scm @@ -336,7 +336,6 @@ ;; transformation matrix into consideration. (size #:getter size #:init-thunk make-null-rect) (width #:accessor width - #:init-keyword #:width #:observe? #t #:allocation #:virtual #:slot-ref (lambda (node) (rect-width (size node))) @@ -344,7 +343,6 @@ (set-rect-width! (size node) w) (expire-local-bounding-box node))) (height #:accessor height - #:init-keyword #:height #:observe? #t #:allocation #:virtual #:slot-ref (lambda (node) (rect-height (size node))) @@ -378,10 +376,11 @@ (slot-set! node 'scale (vec2 s s)))) ;; If caller doesn't specify a custom width and height, let the node ;; pick a reasonable default size. - (when (= (width node) 0.0) - (set! (width node) (default-width node))) - (when (= (height node) 0.0) - (set! (height node) (default-height node))) + (let ((r (size node))) + (set-rect-width! r (or (get-keyword #:width args) + (default-width node))) + (set-rect-height! r (or (get-keyword #:height args) + (default-height node)))) ;; Build an initial bounding box. (vec2-copy! (position node) (render-position node)) ;; Set the initial last position to the same as the initial position |