Path2d
The Path2d class describes a series of points in a plane, that are connected by straight lines. It can be either open or closed. It is derived from the VisionElement base class.
Constructors
Empty constructor.
new Path2d(): Path2d;
Constructor with the list of points and an optional flag indicating if the path is closed.
new Path2d(points: Point2d[], closed?: boolean): Path2d;
Methods
addPoints()
Appends a list of points at the end of the current list.
addPoints(points: Point2d[]): void;
addPoint()
Appends a point at the end of the current list
addPoint(point: Point2d): void;
insertPoint()
Try to insert a point at the given index. If index is out of bounds throws exception. Index -1, appends at the end.
insertPoint(point: Point2d, index?: number): void;
getPoint()
Get the point at the given index. If index is out of bounds throws exception.
getPoint(index: number): Point2d;
getPoints()
Get the list of points.
getPoints(): Point2d[];
removePoints()
Clears the list of points.
removePoints(): void;
removePoint()
Try to remove a point in the given index. If index is out of bounds throws exception.
removePoint(index: number): void;
numPoints()
Returns number of points.
numPoints(): number;
Props
color
The color of the line in hexadecimal format.
color: string;
filled
If true, the path will be filled with the color if it is closed.
filled: string;