The location and size of a rectangle region.
The width and height of a <GrapheneRect> can be
negative; for instance, a <GrapheneRect> with an
origin of [ 0, 0 ] and a size of [ 10, 10 ] is equivalent to a
<GrapheneRect> with an origin of [ 10, 10 ] and a
size of [ -10, -10 ].
Application code can normalize rectangles using rect:normalize; this function will ensure that the width
and height of a rectangle are positive values. All functions taking a
<GrapheneRect> as an argument will internally operate
on a normalized copy; all functions returning a
<GrapheneRect> will always return a normalized
rectangle.
originthe coordinates of the origin of the rectangle
sizethe size of the rectangle
Allocates a new <GrapheneRect>.
The contents of the returned rectangle are undefined.
Returned: a <GrapheneRect>.
the newly allocated rectangle
Checks whether a <GrapheneRect> contains the given
coordinates.
Passed: a <GrapheneRect>.
Passed: a <GraphenePoint>.
Returned: a boolean.
true if the rectangle contains the point
Checks whether a <GrapheneRect> fully contains the
given rectangle.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
Returned: a boolean.
true if the rectangle self fully contains b
Checks whether the two given rectangle are equal.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
Returned: a boolean.
true if the rectangles are equal
Expands a <GrapheneRect> to contain the given
<GraphenePoint>.
Passed: a <GrapheneRect>.
Passed: a <GraphenePoint>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for the expanded rectangle
Frees the resources allocated by rect-alloc.
Passed: a <GrapheneRect>.
Compute the area of given normalized rectangle.
Passed: a <GrapheneRect>.
Returned: a real number.
the area of the normalized rectangle
Retrieves the coordinates of the bottom-left corner of the given rectangle.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for a <GraphenePoint>
Retrieves the coordinates of the bottom-right corner of the given rectangle.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for a <GraphenePoint>
Retrieves the coordinates of the center of the given rectangle.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for a <GraphenePoint>
Retrieves the normalized height of the given rectangle.
Passed: a <GrapheneRect>.
Returned: a real number.
the normalized height of the rectangle
Retrieves the coordinates of the top-left corner of the given rectangle.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for a <GraphenePoint>
Retrieves the coordinates of the top-right corner of the given rectangle.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for a <GraphenePoint>
Computes the four vertices of a <GrapheneRect>.
Passed: a <GrapheneRect>.
Passed: a list or vector, each a <GrapheneVec2>. It
is filled in, and returned: a vector, each a
<GrapheneVec2>.
return location for an array of 4 <GrapheneVec2>
Retrieves the normalized width of the given rectangle.
Passed: a <GrapheneRect>.
Returned: a real number.
the normalized width of the rectangle
Retrieves the normalized X coordinate of the origin of the given rectangle.
Passed: a <GrapheneRect>.
Returned: a real number.
the normalized X coordinate of the rectangle
Retrieves the normalized Y coordinate of the origin of the given rectangle.
Passed: a <GrapheneRect>.
Returned: a real number.
the normalized Y coordinate of the rectangle
Initializes the given <GrapheneRect> with the given
values.
This function will implicitly normalize the
<GrapheneRect> before returning.
Passed: a <GrapheneRect>.
Passed: a real number.
the X coordinate of the graphene-rect-t.origin
Passed: a real number.
the Y coordinate of the graphene-rect-t.origin
Passed: a real number.
the width of the graphene-rect-t.size
Passed: a real number.
the height of the graphene-rect-t.size
Returned: a <GrapheneRect>.
the initialized rectangle
Initializes self using the given src rectangle.
This function will implicitly normalize the
<GrapheneRect> before returning.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
Returned: a <GrapheneRect>.
the initialized rectangle
Changes the given rectangle to be smaller, or larger depending on the given inset parameters.
To create an inset rectangle, use positive d-x or d-y values; to create a larger, encompassing rectangle, use negative d-x or d-y values.
The origin of the rectangle is offset by d-x and d-y, while
the size is adjusted by (2 * @d_x, 2 * @d_y). If d-x and
d-y are positive values, the size of the rectangle is decreased;
if d-x and d-y are negative values, the size of the
rectangle is increased.
If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.
Passed: a <GrapheneRect>.
Passed: a real number.
the horizontal inset
Passed: a real number.
the vertical inset
Returned: a <GrapheneRect>.
the inset rectangle
Changes the given rectangle to be smaller, or larger depending on the given inset parameters.
To create an inset rectangle, use positive d-x or d-y values; to create a larger, encompassing rectangle, use negative d-x or d-y values.
The origin of the rectangle is offset by d-x and d-y, while
the size is adjusted by (2 * @d_x, 2 * @d_y). If d-x and
d-y are positive values, the size of the rectangle is decreased;
if d-x and d-y are negative values, the size of the
rectangle is increased.
If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.
Passed: a <GrapheneRect>.
Passed: a real number.
the horizontal inset
Passed: a real number.
the vertical inset
Passed, filled in, and returned: a <GrapheneRect>.
return location for the inset rectangle
Linearly interpolates the origin and size of the two given rectangles.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
Passed: a real number.
the linear interpolation factor
Passed, filled in, and returned: a <GrapheneRect>.
return location for the interpolated rectangle
Computes the intersection of the two given rectangles.

The intersection in the image above is the blue outline.
If the two rectangles do not intersect, res will contain a degenerate rectangle with origin in (0, 0) and a size of 0.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for a <GrapheneRect>
Returned: a boolean.
true if the two rectangles intersect
Normalizes the passed rectangle.
This function ensures that the size of the rectangle is made of positive values, and that the origin is the top-left corner of the rectangle.
Passed: a <GrapheneRect>.
Returned: a <GrapheneRect>.
the normalized rectangle
Normalizes the passed rectangle.
This function ensures that the size of the rectangle is made of positive values, and that the origin is in the top-left corner of the rectangle.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
the return location for the normalized rectangle
Offsets the origin by d-x and d-y.
The size of the rectangle is unchanged.
Passed: a <GrapheneRect>.
Passed: a real number.
the horizontal offset
Passed: a real number.
the vertical offset
Returned: a <GrapheneRect>.
the offset rectangle
Offsets the origin of the given rectangle by d-x and d-y.
The size of the rectangle is left unchanged.
Passed: a <GrapheneRect>.
Passed: a real number.
the horizontal offset
Passed: a real number.
the vertical offset
Passed, filled in, and returned: a <GrapheneRect>.
return location for the offset rectangle
Rounds the origin and size of the given rectangle to their nearest
integer values; the rounding is guaranteed to be large enough to have an
area bigger or equal to the original rectangle, but might not fully
contain its extents. Use rect:round-extents! in case you need to round to a
rectangle that covers fully the original one.
This function is the equivalent of calling floor on the
coordinates of the origin, and ceil on the size.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for the rounded rectangle
Rounds the origin of the given rectangle to its nearest integer value and and recompute the size so that the rectangle is large enough to contain all the conrners of the original rectangle.
This function is the equivalent of calling floor on the
coordinates of the origin, and recomputing the size calling ceil
on the bottom-right coordinates.
If you want to be sure that the rounded rectangle completely covers the area that was covered by the original rectangle — i.e. you want to cover the area including all its corners — this function will make sure that the size is recomputed taking into account the ceiling of the coordinates of the bottom-right corner. If the difference between the original coordinates and the coordinates of the rounded rectangle is greater than the difference between the original size and and the rounded size, then the move of the origin would not be compensated by a move in the anti-origin, leaving the corners of the original rectangle outside the rounded one.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for the rectangle with rounded extents
Rounds the origin and the size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to contain the original rectangle.
Passed: a <GrapheneRect>.
Returned: a <GrapheneRect>.
the pixel-aligned rectangle.
Scales the size and origin of a rectangle horizontaly by s-h, and vertically by s-v. The result res is normalized.
Passed: a <GrapheneRect>.
Passed: a real number.
horizontal scale factor
Passed: a real number.
vertical scale factor
Passed, filled in, and returned: a <GrapheneRect>.
return location for the scaled rectangle
Computes the union of the two given rectangles.

The union in the image above is the blue outline.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for a <GrapheneRect>
Returns a degenerate rectangle with origin fixed at (0, 0) and a size of 0, 0.
Returned: a <GrapheneRect>.
a fixed rectangle