Constructor
new Bounds(from, to)
Create a new bounding box (parameters do not have to necessarily be min and max).
- Source
Members
bottom
Get the y value of the bottom side of the bounds.
- Source
bottomLeft
Get the bottom-left corner of the bounding box.
- Source
height
Get the height of the bounding box.
- Source
left
Get the x value of the left side of the bounds.
- Source
max
Maximum (bottom-right) point
- Source
min
Minimum (top-left) point
- Source
right
Get the x value of the right side of the bounds.
- Source
top
Get the y value of the top side of the bounds.
- Source
topRight
Get the top-right corner of the bounding box.
- Source
width
Get the width of the bounding box.
- Source
Methods
add(offset) → {Bounds}
Offset the bounding box.
Parameters:
Name | Type | Description |
---|---|---|
offset | Vec2 | Vector to offset by |
- Source
Returns:
Offset bounding box
- Type:
- Bounds
copy() → {Bounds}
Get a copy of the bounding box.
- Source
Returns:
Copied bounding box
- Type:
- Bounds
merge(other) → {Bounds}
Merge the bounds with another.
Parameters:
Name | Type | Description |
---|---|---|
other | Bounds | Other bounding box to merge with |
- Source
Returns:
Merged/combined bounding box
- Type:
- Bounds
overlaps(other) → {boolean}
Check if the bounding box overlaps another.
Parameters:
Name | Type | Description |
---|---|---|
other | Bounds | Other bounding box to check with |
- Source
Returns:
Whether bounding boxes overlap
- Type:
- boolean
scale(val) → {Bounds}
Scale the bounding box.
Parameters:
Name | Type | Description |
---|---|---|
val | number | | Value to scale bounds by |
- Source
Returns:
Scaled bounding box
- Type:
- Bounds
within(pos) → {boolean}
Check if a point is within the bounding box.
Parameters:
Name | Type | Description |
---|---|---|
pos | Vec2 | Point to check for |
- Source
Returns:
Whether point is within bounds
- Type:
- boolean
(static) fromWidthAndHeight(width, height) → {Bounds}
Create a bounding box from width and height (centered)
Parameters:
Name | Type | Description |
---|---|---|
width | number | Width of bounding box |
height | number | Height of bounding box |
- Source
Returns:
Resulting bounding box
- Type:
- Bounds