AxisAlignedBounds
class AxisAlignedBounds
Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its width and its height.
Constructor
new AxisAlignedBounds(x: number, y: number, width: number, height: number) → {}
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
| x | number |
<optional> |
0 |
The X coordinate of the upper-left corner of the rectangle |
| y | number |
<optional> |
0 |
The Y coordinate of the upper-left corner of the rectangle |
| width | number |
<optional> |
0 |
The overall width of this rectangle |
| height | number |
<optional> |
0 |
The overall height of this rectangle |
Summary
Properties from AxisAlignedBounds
Methods from AxisAlignedBounds
| this |
Enlarges rectangle that way its corners lie on grid |
| AxisAlignedBounds |
Creates a clone of this Rectangle |
| boolean |
Checks whether the x and y coordinates given are contained within this Rectangle |
| AxisAlignedBounds |
Copies another rectangle to this one. |
| AxisAlignedBounds |
Copies this rectangle to another one. |
| this |
Enlarges this rectangle to include the passed rectangle. |
| boolean |
Checks whether the given |
| this |
Fits this rectangle around the passed one. |
| this |
|
Public Properties
Public Methods
ceil(resolution: number, eps: number) → {this}
Enlarges rectangle that way its corners lie on grid
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
| resolution | number |
<optional> |
1 |
resolution |
| eps | number |
<optional> |
0.001 |
precision |
| Type | Description |
|---|---|
| this |
Returns itself. |
clone() → {AxisAlignedBounds}
Creates a clone of this Rectangle
| Type | Description |
|---|---|
| AxisAlignedBounds |
A copy of this AxisAlignedBounds. |
contains(x: number, y: number) → {boolean}
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 |
| Type | Description |
|---|---|
| boolean |
Whether the x/y coordinates are within this Rectangle |
copyFrom(rectangle: AxisAlignedBounds) → {AxisAlignedBounds}
Copies another rectangle to this one.
| Name | Type | Description |
|---|---|---|
| rectangle | AxisAlignedBounds |
The rectangle to copy from. |
| Type | Description |
|---|---|
| AxisAlignedBounds |
Returns itself. |
copyTo(rectangle: AxisAlignedBounds) → {AxisAlignedBounds}
Copies this rectangle to another one.
| Name | Type | Description |
|---|---|---|
| rectangle | AxisAlignedBounds |
The rectangle to copy to. |
| Type | Description |
|---|---|
| AxisAlignedBounds |
Returns given parameter. |
enlarge(rectangle: AxisAlignedBounds) → {this}
Enlarges this rectangle to include the passed rectangle.
| Name | Type | Description |
|---|---|---|
| rectangle | AxisAlignedBounds |
The rectangle to include. |
| Type | Description |
|---|---|
| this |
Returns itself. |
equals(bounds: AxisAlignedBounds) → {boolean}
Checks whether the given bounds are equal to this.
| Name | Type | Description |
|---|---|---|
| bounds | AxisAlignedBounds |
| Type | Description |
|---|---|
| boolean |
fit(rectangle: AxisAlignedBounds) → {this}
Fits this rectangle around the passed one.
| Name | Type | Description |
|---|---|---|
| rectangle | AxisAlignedBounds |
The rectangle to fit. |
| Type | Description |
|---|---|
| this |
Returns itself. |
pad(paddingX: number, paddingY) → {this}
Pads the rectangle making it grow in all directions. If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
| paddingX | number |
<optional> |
0 |
The horizontal padding amount. |
| paddingY |
<optional> |
0 |
The vertical padding amount. |
| Type | Description |
|---|---|
| this |
Returns itself. |