Name | Type | Default | Description |
---|---|---|---|
x |
string | number | 0 |
The X coordinate of the upper-left corner of the rectangle |
y |
string | number | 0 |
The Y coordinate of the upper-left corner of the rectangle |
width |
string | number | 0 |
The overall width of the rectangle |
height |
string | number | 0 |
The overall height of the rectangle |
Implements
Members
EMPTY Rectangle static
A constant empty rectangle. This is a new object every time the property is accessed
Returns the bottom edge of the rectangle.
The overall height of this rectangle
- Default Value:
- 0
Returns the left edge of the rectangle.
Returns the right edge of the rectangle.
Returns the top edge of the rectangle.
type SHAPE_PRIMITIVE readonly
The type of the object, mainly used to avoid instanceof
checks
- Default Value:
- 'rectangle'
The overall width of this rectangle
- Default Value:
- 0
The X coordinate of the upper-left corner of the rectangle
- Default Value:
- 0
The Y coordinate of the upper-left corner of the rectangle
- Default Value:
- 0
Methods
Enlarges rectangle that way its corners lie on grid
Name | Type | Default | Description |
---|---|---|---|
resolution |
number | 1 |
resolution |
eps |
number | 0.001 |
precision |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Creates a clone of this Rectangle
Returns:
Type | Description |
---|---|
Rectangle | a copy of the rectangle |
Checks whether the x and y coordinates given are contained within this Rectangle
Name | Type | Description |
---|---|---|
x |
number |
The X coordinate of the point to test |
y |
number |
The Y coordinate of the point to test |
Returns:
Type | Description |
---|---|
boolean | Whether the x/y coordinates are within this Rectangle |
Determines whether the other
Rectangle is contained within this
Rectangle object.
Rectangles that occupy the same space are considered to be containing each other.
Rectangles without area (width or height equal to zero) can't contain anything,
not even other arealess rectangles.
Note: Only available with pixi.js/math-extras.
Name | Type | Description |
---|---|---|
other |
Rectangle |
The Rectangle to fit inside |
Returns:
Type | Description |
---|---|
boolean | A value of true if this Rectangle contains other ; otherwise false . |
Copies another rectangle to this one.
Name | Type | Description |
---|---|---|
rectangle |
Rectangle |
The rectangle to copy from. |
Returns:
Type | Description |
---|---|
Rectangle | Returns itself. |
Converts a Bounds object to a Rectangle object.
Name | Type | Description |
---|---|---|
bounds |
Bounds |
The bounds to copy and convert to a rectangle. |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Copies this rectangle to another one.
Name | Type | Description |
---|---|---|
rectangle |
Rectangle |
The rectangle to copy to. |
Returns:
Type | Description |
---|---|
Rectangle | Returns given parameter. |
Enlarges this rectangle to include the passed rectangle.
Name | Type | Description |
---|---|---|
rectangle |
Rectangle |
The rectangle to include. |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Accepts other
Rectangle and returns true if the given Rectangle is equal to this
Rectangle.
Note: Only available with pixi.js/math-extras.
Name | Type | Description |
---|---|---|
other |
Rectangle |
The Rectangle to compare with |
Returns:
Type | Description |
---|---|
boolean | Returns true if all x , y , width , and height are equal. |
Fits this rectangle around the passed one.
Name | Type | Description |
---|---|---|
rectangle |
Rectangle |
The rectangle to fit. |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Returns the framing rectangle of the rectangle as a Rectangle object
Name | Type | Attributes | Description |
---|---|---|---|
out |
Rectangle |
<optional> |
optional rectangle to store the result |
Returns:
Type | Description |
---|---|
Rectangle | The framing rectangle |
If the area of the intersection between the Rectangles other
and this
is not zero,
returns the area of intersection as a Rectangle object. Otherwise, return an empty Rectangle
with its properties set to zero.
Rectangles without area (width or height equal to zero) can't intersect or be intersected
and will always return an empty rectangle with its properties set to zero.
Note: Only available with pixi.js/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
other |
Rectangle |
The Rectangle to intersect with |
|
outRect |
Rectangle |
<optional> |
A Rectangle object in which to store the value, optional (otherwise will create a new Rectangle). |
Returns:
Type | Description |
---|---|
Rectangle | The intersection of this and other . |
Determines whether the other
Rectangle transformed by transform
intersects with this
Rectangle object.
Returns true only if the area of the intersection is >0, this means that Rectangles
sharing a side are not overlapping. Another side effect is that an arealess rectangle
(width or height equal to zero) can't intersect any other rectangle.
Name | Type | Attributes | Description |
---|---|---|---|
other |
Rectangle |
The Rectangle to intersect with |
|
transform |
Matrix |
<optional> |
The transformation matrix of |
Returns:
Type | Description |
---|---|
boolean | A value of true if the transformed other Rectangle intersects with this ; otherwise false . |
Determines whether the Rectangle is empty.
Returns:
Type | Description |
---|---|
boolean |
Pads the rectangle making it grow in all directions. If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
Name | Type | Default | Description |
---|---|---|---|
paddingX |
number | 0 |
The horizontal padding amount. |
paddingY |
The vertical padding amount. |
Returns:
Type | Description |
---|---|
this | Returns itself. |
Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
Name | Type | Description |
---|---|---|
x |
number |
The X coordinate of the point to test |
y |
number |
The Y coordinate of the point to test |
strokeWidth |
number |
The width of the line to check |
Returns:
Type | Description |
---|---|
boolean | Whether the x/y coordinates are within this rectangle |
Adds this
and other
Rectangles together to create a new Rectangle object filling
the horizontal and vertical space between the two rectangles.
Note: Only available with pixi.js/math-extras.
Name | Type | Attributes | Description |
---|---|---|---|
other |
Rectangle |
The Rectangle to unite with |
|
outRect |
Rectangle |
<optional> |
A Rectangle object in which to store the value, optional (otherwise will create a new Rectangle). |
Returns:
Type | Description |
---|---|
Rectangle | The union of this and other . |