Constructor
new Rectangle(xopt, yopt, widthopt, heightopt)
Creates a new Rectangle object with the top-left corner specified by the x
and y parameters and with the specified width and height parameters.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number |
<optional> |
0.0 | The x coordinate of the top-left corner of the rectangle. |
y |
number |
<optional> |
0.0 | The y coordinate of the top-left corner of the rectangle. |
width |
number |
<optional> |
0.0 | The y coordinate of the top-left corner of the rectangle. |
height |
number |
<optional> |
0.0 | The height of the rectangle, in pixels. |
- Source:
Extends
Members
bottom :number
The sum of the y and height properties.
Type:
- number
- Source:
bottomLeft :rune.geom.Rectangle
The location of the Rectangle object's bottom-left corner, determined by the
values of the left and bottom properties.
Type:
- Source:
bottomRight :rune.geom.Rectangle
The location of the Rectangle object's bottom-right corner, determined by the
values of the right and bottom properties.
Type:
- Source:
center :rune.geom.Point
The center point of the rectangle object.
Type:
- Source:
centerX :number
The x coordinate of the center of the object.
Type:
- number
- Source:
centerY :number
The y coordinate of the center of the object.
Type:
- number
- Source:
height :number
The height of the rectangle, in pixels.
Type:
- number
- Source:
left :number
The x coordinate of the top-left corner of the rectangle.
Type:
- number
- Source:
right :number
The sum of the x and width properties.
Type:
- number
- Source:
size :rune.geom.Point
The size of the Rectangle object, expressed as a Point object with the values
of the width and height properties.
Type:
- Source:
top :number
The y coordinate of the top-left corner of the rectangle.
Type:
- number
- Source:
topLeft :rune.geom.Point
The location of the Rectangle object's top-left corner, determined by the x
and y coordinates of the point.
Type:
- Source:
topRight :rune.geom.Point
The location of the Rectangle object's top-right corner, determined by the x
and y coordinates of the point.
Type:
- Source:
width :number
The width of the rectangle, in pixels.
Type:
- number
- Source:
x :number
The horizontal coordinate of the point. The default value is 0.
Type:
- number
- Inherited From:
- Source:
y :number
The vertical coordinate of the point. The default value is 0.
Type:
- number
- Inherited From:
- Source:
Methods
(static) clone(from) → {rune.geom.Rectangle}
Creates a clone of a Rectangle object.
Parameters:
Name | Type | Description |
---|---|---|
from |
rune.geom.Rectangle | The Rectangle object to be cloned. |
- Source:
Returns:
The new, cloned Rectangle object.
- Type
- rune.geom.Rectangle
(static) containsPoint(x1, y1, w1, h1, x2, y2) → {boolean}
Determines whether a point is contained within a rectangular region.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the rectangle. |
y1 |
number | The y coordinate of the rectangle. |
w1 |
number | The width of the rectangle. |
h1 |
number | The height of the rectangle. |
x2 |
number | The x coordinate of the point. |
y2 |
number | The y coordinate of the point. |
- Source:
Returns:
A value of true if the rectangle contains the specified point; otherwise false.
- Type
- boolean
(static) containsRectangle(x1, y1, w1, h1, x2, y2, w2, h2) → {boolean}
Determines if a rectangle is contained by another rectangle.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the first rectangle. |
y1 |
number | The y coordinate of the first rectangle. |
w1 |
number | The width of the first rectangle. |
h1 |
number | The height of the first rectangle. |
x2 |
number | The x coordinate of the second rectangle. |
y2 |
number | The y coordinate of the second rectangle. |
w2 |
number | The width of the second rectangle. |
h2 |
number | The height of the second rectangle. |
- Source:
Returns:
A value of true if the rectangle is contained by another rectangle; otherwise false.
- Type
- boolean
(static) copy(from, to) → {rune.geom.Rectangle}
Copies the properties of one Rectangle object to another Rectangle object.
Parameters:
Name | Type | Description |
---|---|---|
from |
rune.geom.Rectangle | Rectangle objects to copy from. |
to |
rune.geom.Rectangle | Rectangle objects to copy to. |
- Source:
Returns:
The rectangle object that represents the copy.
- Type
- rune.geom.Rectangle
(static) intersection(x1, y1, w1, h1, x2, y2, w2, h2, oopt) → {rune.geom.Rectangle}
Returns the area of intersection as a Rectangle object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
x1 |
number | The x coordinate of the first rectangle. | |
y1 |
number | The x coordinate of the first rectangle. | |
w1 |
number | The width of the first rectangle. | |
h1 |
number | The height of the first rectangle. | |
x2 |
number | The x coordinate of the second rectangle. | |
y2 |
number | The y coordinate of the second rectangle. | |
w2 |
number | The width of the second rectangle. | |
h2 |
number | The height of the second rectangle. | |
o |
rune.geom.Rectangle |
<optional> |
Store results in this object. |
- Source:
Returns:
A Rectangle object that equals the area of intersection.
- Type
- rune.geom.Rectangle
(static) intersects(x1, y1, w1, h1, x2, y2, w2, h2) → {boolean}
Determine whether or not two rectangles intersects.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
number | The x coordinate of the first rectangle. |
y1 |
number | The x coordinate of the first rectangle. |
w1 |
number | The width of the first rectangle. |
h1 |
number | The height of the first rectangle. |
x2 |
number | The x coordinate of the second rectangle. |
y2 |
number | The y coordinate of the second rectangle. |
w2 |
number | The width of the second rectangle. |
h2 |
number | The height of the second rectangle. |
- Source:
Returns:
A value of true if the specified point intersects with this rectangle; otherwise false.
- Type
- boolean
containsPoint(point) → {boolean}
Determines whether the specified point is contained within the rectangular
region defined by this Rectangle object.
Parameters:
Name | Type | Description |
---|---|---|
point |
rune.geom.Point | The point, as represented by its x and y coordinates. |
- Source:
Returns:
A value of true if the Rectangle object contains the specified point; otherwise false.
- Type
- boolean
containsRectangle(rect) → {boolean}
Determines whether the Rectangle object specified by the rect parameter is
contained within this Rectangle object. A Rectangle object is said to contain
another if the second Rectangle object falls entirely within the boundaries
of the first.
Parameters:
Name | Type | Description |
---|---|---|
rect |
rune.geom.Rectangle | The Rectangle object being checked. |
- Source:
Returns:
A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false.
- Type
- boolean
distance(point) → {number}
Returns the distance between the current and specified point.
Parameters:
Name | Type | Description |
---|---|---|
point |
rune.geom.Point | The specified point. |
- Inherited From:
- Source:
Returns:
- Type
- number
interpolate(point, fractionopt, outputopt) → {rune.geom.Point}
Determines a point between two specified points. The parameter fraction
determines where the new interpolated point is located relative to the two
end points.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
point |
rune.geom.Point | The second point. | |
fraction |
number |
<optional> |
The level of interpolation between the two points. |
output |
rune.geom.Point |
<optional> |
Save results to this object. |
- Inherited From:
- Source:
Returns:
The new, interpolated point.
- Type
- rune.geom.Point
intersection(toIntersect, outputopt) → {rune.geom.Rectangle}
If the Rectangle object specified in the toIntersect parameter intersects
with this Rectangle object, returns the area of intersection as a Rectangle
object. If the rectangles do not intersect, this method returns an empty
Rectangle object with its properties set to 0.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
toIntersect |
rune.geom.Rectangle | The Rectangle object to compare against to see if it intersects with this Rectangle object. | |
output |
rune.geom.Rectangle |
<optional> |
A Rectangle object to store the intersection results in. |
- Source:
Returns:
A Rectangle object that equals the area of intersection.
- Type
- rune.geom.Rectangle
intersects(toIntersect) → {boolean}
Determines whether the object specified in the toIntersect parameter
intersects with this Rectangle object.
Parameters:
Name | Type | Description |
---|---|---|
toIntersect |
rune.geom.Rectangle | The Rectangle object to compare against this Rectangle object. |
- Source:
Returns:
A value of true if the specified object intersects with this Rectangle object; otherwise false.
- Type
- boolean
toString() → {string}
Returns a string representation of the hitbox. Useful for troubleshooting.
- Overrides:
- Source:
Returns:
- Type
- string
toString() → {string}
Builds and returns a string that lists the horizontal and vertical positions
and the width and height of the Rectangle object.
- Overrides:
- Source:
Returns:
- Type
- string