Class: Rectangle

Rectangle(x, y, width, height)

Represents a rectangle in 2D Cartesian coordinates.

Constructor

new Rectangle(x, y, width, height)

Constructs a rectangle with a specified origin and size.
Parameters:
Name Type Description
x Number The X coordinate of the rectangle's origin.
y Number The Y coordinate of the rectangle's origin.
width Number The rectangle's width.
height Number The rectangle's height.
Source:

Members

height :Number

This rectangle's height.
Type:
  • Number
Source:

width :Number

This rectangle's width.
Type:
  • Number
Source:

x :Number

The X coordinate of this rectangle's origin.
Type:
  • Number
Source:

y :Number

The Y coordinate of this rectangle's origin.
Type:
  • Number
Source:

Methods

containsPoint(point) → {Boolean}

Indicates whether this rectangle contains a specified point.
Parameters:
Name Type Description
point Vec2 The point to test.
Source:
Returns:
true if this rectangle contains the specified point, otherwise false.
Type
Boolean

getMaxX() → {Number}

Returns the maximum X value of this rectangle.
Source:
Returns:
The rectangle's maximum X value.
Type
Number

getMaxY() → {Number}

Returns the maximum Y value of this rectangle.
Source:
Returns:
The rectangle's maximum Y value.
Type
Number

getMinX() → {Number}

Returns the minimum X value of this rectangle.
Source:
Returns:
The rectangle's minimum X value.
Type
Number

getMinY() → {Number}

Returns the minimum Y value of this rectangle.
Source:
Returns:
The rectangle's minimum Y value.
Type
Number

intersects(that) → {Boolean}

Indicates whether this rectangle intersects a specified one.
Parameters:
Name Type Description
that Rectangle The rectangle to test.
Source:
Returns:
true if this triangle and the specified one intersect, otherwise false.
Type
Boolean

intersectsRectangles(rectangles) → {Boolean}

Indicates whether this rectangle intersects any rectangle in a specified array of rectangles.
Parameters:
Name Type Description
rectangles Array.<Rectangle> The rectangles to test intersection with.
Source:
Returns:
true if this rectangle intersects any rectangle in the array, otherwise false.
Type
Boolean

set(x, y, width, height)

Sets all this rectangle's properties.
Parameters:
Name Type Description
x Number The X coordinate of the rectangle's origin.
y Number The Y coordinate of the rectangle's origin.
width Number The rectangle's width.
height Number The rectangle's height.
Source:

toString() → {String}

Returns a string representation of this object.
Source:
Returns:
A string representation of this object.
Type
String