Implement a simple 2d Rectangle.
Kind: global class
Number
Number
Number
Number
Rectangle
Rectangle
Vector2
Vector2
Vector2
Rectangle
Vector2
Vector2
Vector2
Vector2
Boolean
Boolean
Boolean
Boolean
Circle
Rectangle
\*
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. |
Number
Get left value.
Kind: instance property of Rectangle
Returns: Number
- rectangle left.
Number
Get right value.
Kind: instance property of Rectangle
Returns: Number
- rectangle right.
Number
Get top value.
Kind: instance property of Rectangle
Returns: Number
- rectangle top.
Number
Get bottom value.
Kind: instance property of Rectangle
Returns: Number
- rectangle bottom.
Rectangle
Set 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. |
Rectangle
Copy another rectangle.
Kind: instance method of Rectangle
Returns: Rectangle
- this.
Param | Type | Description |
---|---|---|
other | other |
Rectangle to copy. |
Vector2
Get position as Vector2.
Kind: instance method of Rectangle
Returns: Vector2
- Position vector.
Vector2
Get size as Vector2.
Kind: instance method of Rectangle
Returns: Vector2
- Size vector.
Vector2
Get center position.
Kind: instance method of Rectangle
Returns: Vector2
- Position vector.
Rectangle
Return a clone of this rectangle.
Kind: instance method of Rectangle
Returns: Rectangle
- Cloned rectangle.
Vector2
Get top-left corner.
Kind: instance method of Rectangle
Returns: Vector2
- Corner position vector.
Vector2
Get top-right corner.
Kind: instance method of Rectangle
Returns: Vector2
- Corner position vector.
Vector2
Get bottom-left corner.
Kind: instance method of Rectangle
Returns: Vector2
- Corner position vector.
Vector2
Get bottom-right corner.
Kind: instance method of Rectangle
Returns: Vector2
- Corner position vector.
Convert to string.
Kind: instance method of Rectangle
Boolean
Check 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. |
Boolean
Check 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. |
Boolean
Check 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. |
Boolean
Checks 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. |
Circle
Get the smallest circle containing this rectangle.
Kind: instance method of Rectangle
Returns: Circle
- Bounding circle.
Rectangle
Return 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. |
Rectangle
Build 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. |
Rectangle
Lerp 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). |
Rectangle
Create rectangle from a dictionary.
Kind: static method of Rectangle
Returns: Rectangle
- Newly created rectangle.
Param | Type | Description |
---|---|---|
data | \* |
Dictionary with {x,y,width,height}. |