Next: Transforms, Previous: Vectors, Up: Math [Contents][Index]
(use-modules (sly math rect))
Rects are 2D axis-aligned bounding boxes. They are useful for defining rectangular regions, such as the hitbox of a game entity, or the viewport of a camera. Because rects are axis-aligned, they provide a cheap means to perform simple collision detection.
The <rect>
type descriptor has been exposed for use with
Guile’s (ice-9 match)
pattern matching module.
Rectangle data type with fields x
, y
, width
,
height
, in that order.
Create a new rectangle with position (x, y), and dimensions (width, height).
Rectangle with x
, y
, width
, and height
of 0.
Return #t
if obj is a rectangle.
Return the x coordinate of rect.
Return the x coordinate of rect.
Return the width of rect.
Return the height of rect.
Return the left-hand x coordinate of rect.
Return the right-hand x coordinate of rect.
Return the top y coordinate of rect
Return the bottom y coordinate of rect.
Return the top-left corner of rect.
Return the top-right corner of rect.
Return the bottom-left corner of rect
Return the bottom-right corner of rect.
Return the center x coordinate of rect.
Return the center y coordinate of rect.
Return the center of rect.
Return the half width of rect.
Return the half height of rect.
Return the size of rect.
Create a new rectangle by moving rect by the given 2D vector offset v, or the coordinates x and y.
Create a new rectangle by growing rect by the 2D vector size (or width and height) without changing the center point.
Create a new rectangle that covers the area of both rect1 and rect2.
Create a new rectangle that is the overlapping region of rect1 and rect2. If the rects do not overlap, a rect of size 0 is returned.
Return a new 2D vector by constraining v to the bounds of rect.
Return #t
if rect2 is completely within rect1.
Return #t
if rect2 overlaps rect1.
Return #t
if the 2D vector v (or the coordinates x
and y) is within rect.
Next: Transforms, Previous: Vectors, Up: Math [Contents][Index]