Rect
public sealed struct Rect Represents a rectangle.
Constructors
Properties
| Name | Type | Description |
|---|---|---|
Width | Single | Width of the rect. |
Height | Single | Height of the rect. |
Left | Single | Position of rect's left edge relative to its parent, can also be interpreted as its position on the X axis. |
Top | Single | Position of rect's top edge relative to its parent, can also be interpreted as its position on the Y axis. |
Right | Single | Position of rect's right edge relative to its parent. |
Bottom | Single | Position of rect's bottom edge relative to its parent. |
Position | Vector2 | Position of this rect. |
Center | Vector2 | Center of this rect. |
Size | Vector2 | Size of this rect. |
WithoutPosition | Rect | Returns this rect with position set to 0 on both axes. |
BottomLeft | Vector2 | Position of the bottom left edge of this rect. |
BottomRight | Vector2 | Position of the bottom right edge of this rect. |
TopRight | Vector2 | Position of the top right edge of this rect. |
TopLeft | Vector2 | Position of the top left edge of this rect. |
Methods
Boolean IsInside(Rect rect, Boolean fullyInside = False) Return true if the passed rect is partially or fully inside this rect.
rect — The passed rect to test. fullyInside — to test if the given rect is completely inside this rect. to test for an intersection. Boolean IsInside(Vector2 pos) Return true if the passed point is inside this rect.
Rect Shrink(Single left, Single top, Single right, Single bottom) Returns a Rect shrunk in every direction by given values.
Rect Shrink(Single x, Single y) Returns a Rect shrunk in every direction by given values on each axis.
Rect Shrink(Single amt) Returns a Rect shrunk in every direction by given amount.
Rect Grow(Single left, Single top, Single right, Single bottom) Returns a Rect grown in every direction by given amounts.
Rect Grow(Single x, Single y) Returns a Rect grown in every direction by given values on each axis.
Rect Grow(Single amt) Returns a Rect grown in every direction by given amount.
Rect Floor() Returns a Rect with position and size rounded down.
Rect Round() Returns a Rect with position and size rounded to closest integer values.
Rect Ceiling() Returns a Rect with position and size rounded up.
static Rect FromPoints(Vector2 a, Vector2 b) Create a rect between two points. The order of the points doesn't matter.
Vector4 ToVector4() Returns this rect as a Vector4, where X/Y/Z/W are Left/Top/Right/Bottom respectively.
Void Add(Rect r) Expand this Rect to contain the other rect
Void Add(Vector2 point) Expand this Rect to contain the point
Rect Align(Vector2 size, TextFlag align) Align the smaller rect inside this rect. Default alignment on each axis is Top, Left.
Rect SnapToGrid() Align to a grid
Rect Contain(Vector2 size, TextFlag align = 132, Boolean stretch = False) Contain a given rectangle (image) within this rectangle (frame), preserving aspect ratio.
size — Size of the rectagle (image) to try to contain within this frame rectangle. align — Where to align the given box within this rectangle. stretch — Whether to stretch the given rectagle (image) should its size be smaller than largest rectagle (image) size possible within this rectangle (frame).