Constructor
new Rectangle(x, y, w, h)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
x |
number | |
y |
number | |
w |
number | width |
h |
number | height |
Members
(readonly) center
- Source:
(readonly) x1
- Source:
(readonly) x2
- Source:
(readonly) y1
- Source:
(readonly) y2
- Source:
Methods
clone() → {Rectangle}
- Source:
clone this instance
Returns:
- Type
- Rectangle
contains(x, y, pad) → {boolean}
- Source:
Check if the given Point (x,y) is inside the rectangle, padding is added in each direction
Parameters:
Name | Type | Default | Description |
---|---|---|---|
x |
number | ||
y |
number | ||
pad |
number |
0
|
padding |
Returns:
- Type
- boolean
getLines() → {Array}
- Source:
get the lines of this rectangle as a nested array of line-points, clockwise e.g. [[[0,0],[10,0]], [[10,0],[10,10]], [[10,10],[0,10]], [[0,10],[0,0]]]
Returns:
- Type
- Array
intersectsLine(x1, y1, x2, y2, pad) → {boolean}
- Source:
check if this rectangle intersects or contains the given line from Point (x1,y1) to Point (x2, y2)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
x1 |
number | ||
y1 |
number | ||
x2 |
number | ||
y2 |
number | ||
pad |
number |
0
|
padding |
Returns:
- Type
- boolean
intersectsRect(other) → {boolean}
- Source:
check if this rectangle intersects the given Rectangle
Parameters:
Name | Type | Description |
---|---|---|
other |
Rectangle |
Returns:
- Type
- boolean
multiply(x, yopt) → {Rectangle}
- Source:
multiply position and size of the rectangle by amount x on the x-axis and amount y on the y-axis if y is null, y is set to the value of x
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number | |||
y |
number |
<optional> |
null
|
Returns:
- Type
- Rectangle
scale(x, yopt) → {Rectangle}
- Source:
multiply the size of the rectangle by amount x on the x-axis and amount y on the y-axis if y is null, y is set to the value of x
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number | |||
y |
number |
<optional> |
null
|
Returns:
- Type
- Rectangle
shrink(x, yopt) → {Rectangle}
- Source:
shrink the rectangle from each side by amount x on the x-axis and amount y on the y-axis if y is null, y is set to the value of x
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number | |||
y |
number |
<optional> |
null
|
Returns:
- Type
- Rectangle