diff options
-rw-r--r-- | catbird/node-2d.scm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/catbird/node-2d.scm b/catbird/node-2d.scm index ca5311e..0a1f683 100644 --- a/catbird/node-2d.scm +++ b/catbird/node-2d.scm @@ -55,6 +55,9 @@ align-left align-right align-top + center + center-horizontal + center-vertical default-height default-width expire-local-matrix @@ -704,6 +707,24 @@ A." (- (local-y a) (- (local-y b) (local-origin-y b))))) +(define (center-horizontal a b) + "Move the x position of A so that it is centered with B." + (set! (position-x b) + (+ (local-x a) + (/ (- (local-width a) (local-width b)) 2.0) + (- (local-x b) (local-origin-x b))))) + +(define (center-vertical a b) + "Move the y position of A so that it is centered with B." + (set! (position-y b) + (+ (local-y a) + (/ (- (local-height a) (local-height b)) 2.0) + (- (local-y b) (local-origin-y b))))) + +(define (center a b) + "Center B within A." + (center-horizontal a b) + (center-vertical a b)) ;;; |