summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-12-05 13:12:14 -0500
committerDavid Thompson <dthompson2@worcester.edu>2020-12-05 13:12:14 -0500
commitadaeccde0643649225a26044d9a588e49d403d85 (patch)
tree6835a715fd7d0d8cf99fc28c3d0305bcd0659ea8
parent1bad7879529103b97608cfdf3757ba5cd1186b61 (diff)
rect: Add setters.
-rw-r--r--doc/api.texi24
-rw-r--r--sdl2/rect.scm18
2 files changed, 37 insertions, 5 deletions
diff --git a/doc/api.texi b/doc/api.texi
index 1abaa87..16f57eb 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -835,22 +835,38 @@ Return a new rectangle whose upper-left corner is at (@var{x},
@var{y}) and is @var{width} pixels wide and @var{height} pixels high.
@end deffn
-@deffn {Procedure} rect-x @var{rect}
+@deffn {Procedure} rect-x rect
Return the X coordinate of @var{rect}.
@end deffn
-@deffn {Procedure} rect-y @var{rect}
+@deffn {Procedure} rect-y rect
Return the Y coordinate of @var{rect}.
@end deffn
-@deffn {Procedure} rect-width @var{rect}
+@deffn {Procedure} rect-width rect
Return the width of @var{rect}.
@end deffn
-@deffn {Procedure} rect-height @var{rect}
+@deffn {Procedure} rect-height rect
Return the height of @var{rect}.
@end deffn
+@deffn {Procedure} set-rect-x! rect x
+Set the x coordinate of @var{rect} to @var{x}.
+@end deffn
+
+@deffn {Procedure} set-rect-y! rect y
+Set the y coordinate of @var{rect} to @var{y}.
+@end deffn
+
+@deffn {Procedure} set-rect-width! rect w
+Set the width of @var{rect} to @var{w}.
+@end deffn
+
+@deffn {Procedure} set-rect-height! rect h
+Set the height of @var{rect} to @var{h}.
+@end deffn
+
@node Surfaces
@section Surfaces
diff --git a/sdl2/rect.scm b/sdl2/rect.scm
index 1fd3af9..8ec3cfa 100644
--- a/sdl2/rect.scm
+++ b/sdl2/rect.scm
@@ -33,7 +33,11 @@
rect-x
rect-y
rect-width
- rect-height))
+ rect-height
+ set-rect-x!
+ set-rect-y!
+ set-rect-width!
+ set-rect-height!))
(define-record-type <rect>
(%make-rect bv ptr)
@@ -56,3 +60,15 @@
(define-inlinable (rect-height rect)
(s32vector-ref (rect-bv rect) 3))
+
+(define-inlinable (set-rect-x! rect x)
+ (s32vector-set! (rect-bv rect) 0 x))
+
+(define-inlinable (set-rect-y! rect y)
+ (s32vector-set! (rect-bv rect) 1 y))
+
+(define-inlinable (set-rect-width! rect w)
+ (s32vector-set! (rect-bv rect) 2 w))
+
+(define-inlinable (set-rect-height! rect h)
+ (s32vector-set! (rect-bv rect) 3 h))