
Implement a simple 2d Rectangle.
Kind: global class
NumberNumberNumberNumberRectangleRectangleVector2Vector2Vector2RectangleVector2Vector2Vector2Vector2BooleanBooleanBooleanBooleanCircleRectangle\*Create the Rect.
| Param | Type | Description |
|---|---|---|
| x | Number |
Rect position X (top left corner). |
| y | Number |
Rect position Y (top left corner). |
| width | Number |
Rect width. |
| height | Number |
Rect height. |
NumberGet left value.
Kind: instance property of Rectangle
Returns: Number - rectangle left.
NumberGet right value.
Kind: instance property of Rectangle
Returns: Number - rectangle right.
NumberGet top value.
Kind: instance property of Rectangle
Returns: Number - rectangle top.
NumberGet bottom value.
Kind: instance property of Rectangle
Returns: Number - rectangle bottom.
RectangleSet rectangle values.
Kind: instance method of Rectangle
Returns: Rectangle - this.
| Param | Type | Description |
|---|---|---|
| x | Number |
Rectangle x position. |
| y | Number |
Rectangle y position. |
| width | Number |
Rectangle width. |
| height | Number |
Rectangle height. |
RectangleCopy another rectangle.
Kind: instance method of Rectangle
Returns: Rectangle - this.
| Param | Type | Description |
|---|---|---|
| other | other |
Rectangle to copy. |
Vector2Get position as Vector2.
Kind: instance method of Rectangle
Returns: Vector2 - Position vector.
Vector2Get size as Vector2.
Kind: instance method of Rectangle
Returns: Vector2 - Size vector.
Vector2Get center position.
Kind: instance method of Rectangle
Returns: Vector2 - Position vector.
RectangleReturn a clone of this rectangle.
Kind: instance method of Rectangle
Returns: Rectangle - Cloned rectangle.
Vector2Get top-left corner.
Kind: instance method of Rectangle
Returns: Vector2 - Corner position vector.
Vector2Get top-right corner.
Kind: instance method of Rectangle
Returns: Vector2 - Corner position vector.
Vector2Get bottom-left corner.
Kind: instance method of Rectangle
Returns: Vector2 - Corner position vector.
Vector2Get bottom-right corner.
Kind: instance method of Rectangle
Returns: Vector2 - Corner position vector.
Convert to string.
Kind: instance method of Rectangle
BooleanCheck if this rectangle contains a Vector2.
Kind: instance method of Rectangle
Returns: Boolean - if point is contained within the rectangle.
| Param | Type | Description |
|---|---|---|
| p | Vector2 |
Point to check. |
BooleanCheck if this rectangle collides with another rectangle.
Kind: instance method of Rectangle
Returns: Boolean - if rectangles collide.
| Param | Type | Description |
|---|---|---|
| other | Rectangle |
Rectangle to check collision with. |
BooleanCheck if this rectangle collides with a line.
Kind: instance method of Rectangle
Returns: Boolean - if rectangle collides with line.
| Param | Type | Description |
|---|---|---|
| line | Line |
Line to check collision with. |
BooleanChecks if this rectangle collides with a circle.
Kind: instance method of Rectangle
Returns: Boolean - if rectangle collides with circle.
| Param | Type | Description |
|---|---|---|
| circle | Circle |
Circle to check collision with. |
CircleGet the smallest circle containing this rectangle.
Kind: instance method of Rectangle
Returns: Circle - Bounding circle.
RectangleReturn a resized rectangle with the same center point.
Kind: instance method of Rectangle
Returns: Rectangle - resized rectangle.
| Param | Type | Description |
|---|---|---|
| amount | Number | Vector2 |
Amount to resize. |
Check if equal to another rectangle.
Kind: instance method of Rectangle
| Param | Type | Description |
|---|---|---|
| other | Rectangle |
Other rectangle to compare to. |
\*Convert to dictionary.
Kind: instance method of Rectangle
Returns: \* - Dictionary with {x,y,width,height}
| Param | Type | Description |
|---|---|---|
| minimized | Boolean |
If true, will not include keys that their values are 0. You can use fromDict on minimized dicts. |
RectangleBuild and return a rectangle from points.
Kind: static method of Rectangle
Returns: Rectangle - new rectangle from points.
| Param | Type | Description |
|---|---|---|
| points | Array.<Vector2> |
Points to build rectangle from. |
RectangleLerp between two rectangles.
Kind: static method of Rectangle
Returns: Rectangle - result rectangle.
| Param | Type | Description |
|---|---|---|
| p1 | Rectangle |
First rectangles. |
| p2 | Rectangle |
Second rectangles. |
| a | Number |
Lerp factor (0.0 - 1.0). |
RectangleCreate rectangle from a dictionary.
Kind: static method of Rectangle
Returns: Rectangle - Newly created rectangle.
| Param | Type | Description |
|---|---|---|
| data | \* |
Dictionary with {x,y,width,height}. |