Class: Rect
An object which represents a rectangle in terms of its origin and size. Rect
instances are frozen
and cannot be modified.
Constructor
new Rect(originopt, sizeopt, xopt, yopt, widthopt, heightopt)
Create a new Rect
instance.
Note: Use either new Rect(origin, size)
or new Rect(x, y, width, height)
Methods
translate(pointopt, xopt, yopt) → {Rect}
Create a new Rect
with same dimensions and translated relative to this instance.
Note: Use either rect.translate(point)
or rect.translate(x, y)
Parameters
point
{Point}Translate by this argument's position
x
{number}X value to translate
y
{number}Y value to translate
Returns {Rect}
New translated instance
flipX() → {Rect}
Create a new Rect
with same dimensions and flipped horizontally across to the Y-axis.
Returns {Rect}
New flipped instance
intersects(that) → {boolean}
Evaluates if two rects intersect.
Parameters
that
{Rect}Another rect
equalTo(that) → {boolean}
Returns whether two instances have the same value.
Parameters
that
{Rect}Another rect