From c2a7defe0d13b20e50dbaf8aa48ffef5f65de65b Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 3 May 2014 09:45:12 -0400 Subject: Allow make-rect to accept two vector2s as arguments. * 2d/rect.scm (make-rect): Use case-lambda to accept four numbers or two vector2s. --- 2d/rect.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 - (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) -- cgit v1.2.3