Bounds

class Bounds

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

Constructor


new Bounds(vertices: Array<Vector2d> | Array<Point>) → {}
Parameters:
Name Type Attributes Description
vertices Array<Vector2d> | Array<Point>

<optional>

an array of Vector2d or Point

Public Properties


bottom bounds.js:140
bottom: number

number

bottom coordinate of the bound

center bounds.js:164
center: Vector2d

Vector2d

return the center position of the bound

centerX bounds.js:148
centerX: number

number

center position of the bound on the x axis

centerY bounds.js:156
centerY: number

number

center position of the bound on the y axis

height bounds.js:104
height: number

number

width of the bounds

left bounds.js:116
left: number

number

left coordinate of the bound

top bounds.js:132
top: number

number

top coordinate of the bound

type bounds.js:17
type: string = "Bounds"

string

the object type (used internally)

width bounds.js:92
width: number

number

width of the bounds

x bounds.js:63
x: number

number

x position of the bound

y bounds.js:77
y: number

number

y position of the bounds

Public Methods


add bounds.js:190
add(vertices: Array<Vector2d> | Array<Point>, clear: boolean) → {}

add the given vertices to the bounds definition.

Parameters:
Name Type Attributes Default Description
vertices Array<Vector2d> | Array<Point>

an array of Vector2d or Point

clear boolean

<optional>

false

either to reset the bounds before adding the new vertices

addBounds bounds.js:209
addBounds(bounds: Bounds, clear: boolean) → {}

add the given bounds to the bounds definition.

Parameters:
Name Type Attributes Default Description
bounds Bounds
clear boolean

<optional>

false

either to reset the bounds before adding the new vertices

addFrame bounds.js:244
addFrame(x0: number, y0: number, x1: number, y1: number, m: Matrix2d) → {}

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

m Matrix2d

<optional>

an optional transform to apply to the given frame coordinates

addPoint bounds.js:228
addPoint(point: Vector2d | Point, m: Matrix2d) → {}

add the given point to the bounds definition.

Parameters:
Name Type Attributes Description
point Vector2d | Point

the vector or point to be added to the bounds

m Matrix2d

<optional>

an optional transform to apply to the given point (if the given point is a Vector2d)

centerOn bounds.js:172
centerOn(x: number, y: number) → {}

center the bounds position around the given coordinates

Parameters:
Name Type Description
x number

the x coordinate around which to center this bounds

y number

the y coordinate around which to center this bounds

clear bounds.js:40
clear() → {}

reset the bound

clone bounds.js:377
clone() → {Bounds}

clone this bounds

Returns:
Type Description
Bounds
contains bounds.js:263
contains(x: number | Vector2d, y: number) → {boolean}

Returns true if the bounds contains the given point.

if (bounds.contains(10, 10)) {
  // do something
}
// or
if (bounds.contains(myVector2d)) {
  // do something
}
Parameters:
Name Type Attributes Description
x number | Vector2d

x coordinate or a vector point to check

y number

<optional>

y coordinate

Returns:
Type Description
boolean

True if the bounds contain the point, otherwise false

isFinite bounds.js:312
isFinite() → {boolean}

determines whether all coordinates of this bounds are finite numbers.

Returns:
Type Description
boolean

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

overlaps bounds.js:302
overlaps(bounds: Bounds | Rect) → {boolean}

Returns true if the two bounds intersect.

Parameters:
Name Type Description
bounds Bounds | Rect
Returns:
Type Description
boolean

True if the bounds overlap, otherwise false

setMinMax bounds.js:48
setMinMax(minX: number, minY: number, maxX: number, maxY: number) → {}

sets the bounds to the given min and max value

Parameters:
Name Type Description
minX number
minY number
maxX number
maxY number
shift bounds.js:346
shift(x: number | Vector2d, y: number) → {}

Shifts the bounds to the given x, y position.

bounds.shift(10, 10);
// or
bounds.shift(myVector2d);
Parameters:
Name Type Attributes Description
x number | Vector2d

x coordinate or a vector point to shift to

y number

<optional>

toPolygon bounds.js:387
toPolygon() → {Polygon}

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

Returns:
Type Description
Polygon

a new Polygon that represents this bounds.

translate bounds.js:320
translate(x: number | Vector2d, y: number) → {}

Translates the bounds by the given point

bounds.translate(10, 10);
// or
bounds.translate(myVector2d);
Parameters:
Name Type Attributes Description
x number | Vector2d

x coordinate or a vector point to translate by

y number

<optional>

update bounds.js:182
update(vertices: Array<Vector2d> | Array<Point>) → {}

Updates bounds using the given vertices

Parameters:
Name Type Description
vertices Array<Vector2d> | Array<Point>

an array of Vector2d or Point


Powered by webdoc!