me.Bounds(verticesopt) → {me.Bounds}

a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).

new Bounds(verticesopt) → {me.Bounds}

Parameters:
Name Type Attributes Description
vertices Array.<me.Vector2d> <optional>

an array of me.Vector2d points

Returns:
me.Bounds -

A new bounds object

Members

static bottom :Number

bottom coordinate of the bound

static center :me.Vector2d

return the center position of the bound

static centerX :Number

center position of the bound on the x axis

static centerY :Number

center position of the bound on the y axis

static left :Number

left coordinate of the bound

static right :Number

right coordinate of the bound

static top :Number

top coordinate of the bound

static width :Number

width of the bounds

static width :Number

width of the bounds

static x :Number

x position of the bound

static y :Number

y position of the bounds

Methods

static add(vertices, clearopt)

add the given vertices to the bounds definition.

Parameters:
Name Type Attributes Default Description
vertices Array.<me.Vector2d>

an array of me.Vector2d points

clear boolean <optional>
false

either to reset the bounds before adding the new vertices

static addBounds(bounds, clearopt)

add the given bounds to the bounds definition.

Parameters:
Name Type Attributes Default Description
bounds me.Bounds
clear boolean <optional>
false

either to reset the bounds before adding the new vertices

static addFrame(x0, y0, x1, y1, matrixopt)

add the given quad coordinates to this bound definition, multiplied by the given matrix

Parameters:
Name Type Attributes Description
x0 Number

left X coordinates of the quad

y0 Number

top Y coordinates of the quad

x1 Number

right X coordinates of the quad

y1 Number

bottom y coordinates of the quad

matrix me.Matrix2d <optional>

an optional transform to apply to the given frame coordinates

static addPoint(vector, matrixopt)

add the given point to the bounds definition.

Parameters:
Name Type Attributes Description
vector me.Vector2d
matrix me.Matrix2d <optional>

an optional transform to apply to the given point

static clear()

reset the bound

static clone() → {me.Bounds}

clone this bounds

Returns:
me.Bounds

static contains(point) → {boolean}

Returns true if the bounds contains the given point.

Parameters:
Name Type Description
point me.Vector2d
Returns:
boolean -

True if the bounds contain the point, otherwise false

static contains(x, y) → {boolean}

Returns true if the bounds contains the given point.

Parameters:
Name Type Description
x Number
y Number
Returns:
boolean -

True if the bounds contain the point, otherwise false

static isFinite() → {boolean}

determines whether all coordinates of this bounds are finite numbers.

Returns:
boolean -

false if all coordinates are positive or negative Infinity or NaN; otherwise, true.

static overlaps(bounds) → {boolean}

Returns true if the two bounds intersect.

Parameters:
Name Type Description
bounds me.Bounds | me.Rect
Returns:
boolean -

True if the bounds overlap, otherwise false

static setMinMax(minX, minY, maxX, maxY)

sets the bounds to the given min and max value

Parameters:
Name Type Description
minX Number
minY Number
maxX Number
maxY Number

static shift(position)

Shifts the bounds to the given position vector.

Parameters:
Name Type Description
position me.Vector2d

static shift(x, y)

Shifts the bounds to the given x, y position.

Parameters:
Name Type Description
x Number
y Number

static toPolygon() → {me.Polygon}

Returns a polygon whose edges are the same as this bounds.

Returns:
me.Polygon -

a new Polygon that represents this bounds.

static translate(vector)

Translates the bounds by the given vector.

Parameters:
Name Type Description
vector me.Vector2d

static translate(x, y)

Translates the bounds by x on the x axis, and y on the y axis

Parameters:
Name Type Description
x Number
y Number

static update(vertices)

Updates bounds using the given vertices

Parameters:
Name Type Description
vertices Array.<me.Vector2d>

an array of me.Vector2d points