summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-05-03 09:45:12 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-05-03 09:45:12 -0400
commitc2a7defe0d13b20e50dbaf8aa48ffef5f65de65b (patch)
treef7519d89ae5aa6dd741a4a1cf058293fec34a19d
parent84aa43d4606a99bc18d8d32d2506598f9452e970 (diff)
Allow make-rect to accept two vector2s as arguments.
* 2d/rect.scm (make-rect): Use case-lambda to accept four numbers or two vector2s.
-rw-r--r--2d/rect.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/2d/rect.scm b/2d/rect.scm
index 6d3594c..e3584d3 100644
--- a/2d/rect.scm
+++ b/2d/rect.scm
@@ -64,13 +64,21 @@
;; immutable.
(define-record-type <rect>
- (make-rect x y width height)
+ (%make-rect x y width height)
rect?
(x rect-x)
(y rect-y)
(width rect-width)
(height rect-height))
+(define make-rect
+ (case-lambda
+ ((x y width height)
+ (%make-rect x y width height))
+ ((position size)
+ (%make-rect (vx position) (vy position)
+ (vx size) (vy size)))))
+
(define null-rect (make-rect 0 0 0 0))
(define (rect-right rect)