Data type
Rect
A value that represents a two-dimensional rectangle.
Rect describes a rectangle on a 2D plane. It is constructed using two
corners, either two Vector2 positions or four numbers:
local rect1 = Rect.new(Vector2.new(10, 10), Vector2.new(80, 80))
local rect2 = Rect.new(10, 10, 80, 80)This data type is used in the ImageLabel.SliceCenter property which
determines the center area of a scaled image.
Constructors 3#
| new | Returns a new Rect with zero Vector2 positions. |
| new | Returns a new Rect from the given Vector2 positions. |
| new | Returns a new Rect using the first and last two arguments as coordinates for corners. |
new()#
Constructs a new Rect with two zero Vector2 positions.
new(min: Vector2, max: Vector2)#
Constructs a new Rect given two Vector2 positions: min as
the top-left corner and max as the bottom-right corner.
| Name | Type | Default | Description |
|---|---|---|---|
min | Vector2 | One corner of the rectangle as a Vector2. The constructor
computes the component-wise minimum of min and max to determine
the top-left corner. | |
max | Vector2 | The other corner of the rectangle as a Vector2. The
constructor computes the component-wise maximum of min and max to
determine the bottom-right corner. |
new(minX: number, minY: number, maxX: number, maxY: number)#
Constructs a new Rect using minX and minY as coordinates for the
top-left corner, and maxX and maxY as coordinates for the bottom-right
corner.
| Name | Type | Default | Description |
|---|---|---|---|
minX | number | The X coordinate of the top-left corner of the rectangle. | |
minY | number | The Y coordinate of the top-left corner of the rectangle. | |
maxX | number | The X coordinate of the bottom-right corner of the rectangle. | |
maxY | number | The Y coordinate of the bottom-right corner of the rectangle. |
Properties 4#
Widthnumber | The width of the Rect. |
Heightnumber | The height of the Rect. |
MinVector2 | The coordinates of the top-left corner. |
MaxVector2 | The coordinates of the bottom-right corner. |