diff options
-rw-r--r-- | catbird/node-2d.scm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/catbird/node-2d.scm b/catbird/node-2d.scm index 0a1f683..05393fa 100644 --- a/catbird/node-2d.scm +++ b/catbird/node-2d.scm @@ -56,8 +56,11 @@ align-right align-top center + center-in-parent center-horizontal + center-horizontal-in-parent center-vertical + center-vertical-in-parent default-height default-width expire-local-matrix @@ -726,6 +729,23 @@ A." (center-horizontal a b) (center-vertical a b)) +(define (center-horizontal-in-parent node) + "Center x position of NODE within its parent." + (set! (position-x node) + (+ (/ (- (width (parent node)) (local-width node)) 2.0) + (- (local-origin-x node) (local-x node))))) + +(define (center-vertical-in-parent node) + "Center y position of NODE within its parent." + (set! (position-y node) + (+ (/ (- (height (parent node)) (local-height node)) 2.0) + (- (local-origin-y node) (local-y node))))) + +(define (center-in-parent node) + "Center NODE within its parent." + (center-horizontal-in-parent node) + (center-vertical-in-parent node)) + ;;; ;;; Sprite |