Class Path2
Constructors
constructor
-
Creates a Path2 object from the starting 2D coordinates x and y.
Parameters
- x: number
the starting points x value
- y: number
the starting points y value
Returns Path2
- x: number
Methods
add Arc To
-
addArcTo(
midX: number,
midY: number,
endX: number,
endY: number,
numberOfSegments?: number,
): Path2Adds 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.
Parameters
- midX: number
middle point x value
- midY: number
middle point y value
- endX: number
end point x value
- endY: number
end point y value
- numberOfSegments: number = 36
(default: 36)
Returns Path2
the updated Path2.
- midX: number
add Bezier Curve To
-
addBezierCurveTo(
originTangentX: number,
originTangentY: number,
destinationTangentX: number,
destinationTangentY: number,
endX: number,
endY: number,
numberOfSegments?: number,
): Path2Adds numberOfSegments segments according to the bezier curve definition to the current Path2.
Parameters
- originTangentX: number
tangent vector at the origin point x value
- originTangentY: number
tangent vector at the origin point y value
- destinationTangentX: number
tangent vector at the destination point x value
- destinationTangentY: number
tangent vector at the destination point y value
- endX: number
end point x value
- endY: number
end point y value
- numberOfSegments: number = 36
(default: 36)
Returns Path2
the updated Path2.
- originTangentX: number
add Line To
-
Adds a new segment until the given coordinates (x, y) to the current Path2.
Parameters
- x: number
the added points x value
- y: number
the added points y value
Returns Path2
the updated Path2.
- x: number
add Quadratic Curve To
-
addQuadraticCurveTo(
controlX: number,
controlY: number,
endX: number,
endY: number,
numberOfSegments?: number,
): Path2Adds numberOfSegments segments according to the quadratic curve definition to the current Path2.
Parameters
- controlX: number
control point x value
- controlY: number
control point y value
- endX: number
end point x value
- endY: number
end point y value
- numberOfSegments: number = 36
(default: 36)
Returns Path2
the updated Path2.
- controlX: number
area
-
Gets the area of the polygon defined by the path
Returns number
area value
close
get Point At Length Position
-
Retrieves the point at the distance aways from the starting point
Parameters
- normalizedLengthPosition: number
the length along the path to retrieve the point from
Returns Vector2
a new Vector2 located at a percentage of the Path2 total length on this path.
- normalizedLengthPosition: number
get Points
is Point Inside
-
Defines if a given point is inside the polygon defines by the path
Parameters
- point: Vector2
defines the point to test
Returns boolean
true if the point is inside
- point: Vector2
length
-
Gets the sum of the distance between each sequential point in the path
Returns number
the Path2 total length (float).
StaticStarting At
-
Creates a new path starting from an x and y position
Parameters
- x: number
starting x value
- y: number
starting y value
Returns Path2
a new Path2 starting at the coordinates (x, y).
- x: number
Represents a 2D path made up of multiple 2D points