Line

class Line extends Polygon

a line segment Object

Constructor


new Line(x: number, y: number, points: Array<Vector2d>) → {}
Parameters:
Name Type Description
x number

origin point of the Line

y number

origin point of the Line

points Array<Vector2d>

array of vectors defining the Line

Public Methods


clone line.js:87
clone() → {Line}

clone this line segment

Returns:
Type Description
Line

new Line

contains line.js:15
contains(x: number | Vector2d, y: number) → {boolean}

Returns true if the Line contains the given point

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

recalc line.js:53
recalc() → {Line}

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

Returns:
Type Description
Line

this instance for objecf chaining


Powered by webdoc!