• Public
  • Public/Protected
  • All

Class Path2

Represents a 2D path made up of multiple 2D points


  • Path2




  • new Path2(x: number, y: number): Path2
  • Creates a Path2 object from the starting 2D coordinates x and y.


    • x: number

      the starting points x value

    • y: number

      the starting points y value

    Returns Path2


closedSearch playground for closed

closed: boolean

If the path start and end point are the same


addArcToSearch playground for addArcTo

  • addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2
  • Adds numberOfSegments segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.


    • midX: number

      middle point x value

    • midY: number

      middle point y value

    • endX: number

      end point x value

    • endY: number

      end point y value

    • Optional numberOfSegments: number

      (default: 36)

    Returns Path2

    the updated Path2.

addLineToSearch playground for addLineTo

  • addLineTo(x: number, y: number): Path2
  • Adds a new segment until the given coordinates (x, y) to the current Path2.


    • x: number

      the added points x value

    • y: number

      the added points y value

    Returns Path2

    the updated Path2.

closeSearch playground for close

  • Closes the Path2.

    Returns Path2

    the Path2.

getPointAtLengthPositionSearch playground for getPointAtLengthPosition

  • getPointAtLengthPosition(normalizedLengthPosition: number): Vector2
  • Retreives the point at the distance aways from the starting point


    • normalizedLengthPosition: number

      the length along the path to retreive the point from

    Returns Vector2

    a new Vector2 located at a percentage of the Path2 total length on this path.

getPointsSearch playground for getPoints

  • Gets the points which construct the path

    Returns Vector2[]

    the Path2 internal array of points.

lengthSearch playground for length

  • length(): number
  • Gets the sum of the distance between each sequential point in the path

    Returns number

    the Path2 total length (float).

Static StartingAtSearch playground for StartingAt

  • StartingAt(x: number, y: number): Path2
  • Creates a new path starting from an x and y position


    • x: number

      starting x value

    • y: number

      starting y value

    Returns Path2

    a new Path2 starting at the coordinates (x, y).


  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method