Class Bounds

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

Hierarchy (view full)

Constructors

Properties

_center: Vector2d
max: undefined | {
    x: number;
    y: number;
}
min: undefined | {
    x: number;
    y: number;
}
type: string

the object type (used internally)

"Bounds"

Accessors

Methods

  • add the given vertices to the bounds definition.

    Parameters

    • vertices: Vector2d[] | Point[]

      an array of Vector2d or Point

    • Optionalclear: boolean = false

      either to reset the bounds before adding the new vertices

    Returns void

  • add the given bounds to the bounds definition.

    Parameters

    • bounds: Bounds
    • Optionalclear: boolean = false

      either to reset the bounds before adding the new vertices

    Returns void

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

    Parameters

    • 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

    • Optionalm: any

      an optional transform to apply to the given frame coordinates

    Returns void

  • add the given point to the bounds definition.

    Parameters

    • point: Vector2d | Point

      the vector or point to be added to the bounds

    • Optionalm: any

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

    Returns void

  • center the bounds position around the given coordinates

    Parameters

    • x: number

      the x coordinate around which to center this bounds

    • y: number

      the y coordinate around which to center this bounds

    Returns Bounds

  • Returns true if the bounds contains the given point.

    Parameters

    • Rest...args: any

    Returns boolean

    True if the bounds contain the point, otherwise false

    if (bounds.contains(10, 10)) {
    // do something
    }
    // or
    if (bounds.contains(myVector2d)) {
    // do something
    }
  • 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.

  • Returns true if the two bounds intersect.

    Parameters

    Returns boolean

    True if the bounds overlap, otherwise false

  • sets the bounds to the given min and max value

    Parameters

    • minX: number
    • minY: number
    • maxX: number
    • maxY: number

    Returns void

  • Shifts the bounds to the given x, y position.

    Parameters

    • Rest...args: any

    Returns void

    bounds.shift(10, 10);
    // or
    bounds.shift(myVector2d);
  • Translates the bounds by the given point

    Parameters

    • Rest...args: any

    Returns void

    bounds.translate(10, 10);
    // or
    bounds.translate(myVector2d);