Rect
Description:
A rectangle object with a left-bottom origin position and a size.
Class Object: Rect Class.
Inherits from: ContainerItem.
origin
Type: Field.
Description:
The position of the origin of the rectangle.
Signature:
origin: Vec2
size
Type: Field.
Description:
The dimensions of the rectangle.
Signature:
size: Size
x
Type: Field.
Description:
The x-coordinate of the origin of the rectangle.
Signature:
x: number
y
Type: Field.
Description:
The y-coordinate of the origin of the rectangle.
Signature:
y: number
width
Type: Field.
Description:
The width of the rectangle.
Signature:
width: number
height
Type: Field.
Description:
The height of the rectangle.
Signature:
height: number
top
Type: Field.
Description:
The top edge in y-axis of the rectangle.
Signature:
top: number
bottom
Type: Field.
Description:
The bottom edge in y-axis of the rectangle.
Signature:
bottom: number
left
Type: Field.
Description:
The left edge in x-axis of the rectangle.
Signature:
left: number
right
Type: Field.
Description:
The right edge in x-axis of the rectangle.
Signature:
right: number
centerX
Type: Field.
Description:
The x-coordinate of the center of the rectangle.
Signature:
centerX: number
centerY
Type: Field.
Description:
The y-coordinate of the center of the rectangle.
Signature:
centerY: number
lowerBound
Type: Field.
Description:
The lower bound (left-bottom) of the rectangle.
Signature:
lowerBound: Vec2
upperBound
Type: Field.
Description:
The upper bound (right-top) of the rectangle.
Signature:
upperBound: Vec2
set
Type: Function.
Description:
Set the properties of the rectangle.
Signature:
set: function(self: Rect, x: number, y: number, width: number, height: number)
Parameters:
Parameter | Type | Description |
---|---|---|
x | number | The x-coordinate of the origin of the rectangle. |
y | number | The y-coordinate of the origin of the rectangle. |
width | number | The width of the rectangle. |
height | number | The height of the rectangle. |
containsPoint
Type: Function.
Description:
Check if a point is inside the rectangle.
Signature:
containsPoint: function(self: Rect, point: Vec2): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
point | Vec2 | The point to check, represented by a Vec2 object. |
Returns:
Return Type | Description |
---|---|
boolean | Whether or not the point is inside the rectangle. |
intersectsRect
Type: Function.
Description:
Check if the rectangle intersects with another rectangle.
Signature:
intersectsRect: function(self: Rect, rect: Rect): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
rect | Rect | The other rectangle to check for intersection with, represented by a Rect object. |
Returns:
Return Type | Description |
---|---|
boolean | Whether or not the rectangles intersect. |
equals
Type: Function.
Description:
Check if two rectangles are equal.
Signature:
equals: function(self: Rect, other: Rect): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
other | Rect | The other rectangle to compare to, represented by a Rect object. |
Returns:
Return Type | Description |
---|---|
boolean | Whether or not the two rectangles are equal. |
__eq
Type: Metamethod.
Description:
Check if two rectangles are equal.
Signature:
metamethod __eq: function(self: Rect, other: Rect): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
other | Rect | The other rectangle to compare to, represented by a Rect object. |
Returns:
Return Type | Description |
---|---|
boolean | Whether or not the two rectangles are equal. |