Class Line

a line segment Object

origin point of the Line

origin point of the Line

array of vectors defining the Line

Hierarchy (view full)

Constructors

Properties

_bounds: undefined | object
points: Vector2d[]

Array of points defining the Polygon
Note: If you manually change points, you must call recalcafterwards so that the changes get applied correctly.

origin point of the Polygon

type: string

the shape type (used internally)

"Polygon"

Methods

  • Returns true if the Line contains the given point

    Parameters

    • Rest...args: any

    Returns boolean

    true if contains

    if (line.contains(10, 10)) {
    // do something
    }
    // or
    if (line.contains(myVector2d)) {
    // do something
    }
  • returns a list of indices for all triangles defined in this polygon

    Returns number[]

    an array of vertex indices for all triangles forming this polygon.

  • Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).

    Returns boolean

    true if the vertices are convex, false if not, null if not computable

  • Computes the calculated collision edges and normals. This must be called if the points array, angle, or offset is modified manually.

    Returns Line

    this instance for objecf chaining

  • set new value to the Polygon

    Parameters

    • x: number

      position of the Polygon

    • y: number

      position of the Polygon

    • points: number[] | Vector2d[]

      array of vector or vertice defining the Polygon

    Returns Polygon

    this instance for objecf chaining

  • Shifts the Polygon to the given position vector.

    Parameters

    • Rest...args: any

    Returns void

    polygon.shift(10, 10);
    // or
    polygon.shift(myVector2d);
  • translate the Polygon by the specified offset

    Parameters

    • Rest...args: any

    Returns Polygon

    Reference to this object for method chaining

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