summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/rect.scm18
1 files changed, 17 insertions, 1 deletions
diff --git a/2d/rect.scm b/2d/rect.scm
index 1257142..4cabac3 100644
--- a/2d/rect.scm
+++ b/2d/rect.scm
@@ -32,6 +32,10 @@
rect-y
rect-x2
rect-y2
+ rect-center-x
+ rect-center-y
+ rect-half-width
+ rect-half-height
rect-width
rect-height
rect-position
@@ -41,7 +45,7 @@
rect-union
rect-clip
rect-within?
- rect-intesects?
+ rect-intersects?
rect-contains?))
;;;
@@ -65,6 +69,18 @@
(define (rect-y2 rect)
(+ (rect-y rect) (rect-height rect) -1))
+(define (rect-center-x rect)
+ (+ (rect-x rect) (rect-half-width rect)))
+
+(define (rect-center-y rect)
+ (+ (rect-y rect) (rect-half-height rect)))
+
+(define (rect-half-width rect)
+ (/ (rect-width rect) 2))
+
+(define (rect-half-height rect)
+ (/ (rect-height rect) 2))
+
(define (rect-position rect)
"Return the top-left corner of RECT as a vector2."
(vector2 (rect-x rect)