addPoint(point, [insertAt])

Class: Polygon.

Description:

Adds a point to the Polygon as a last point or at a specified index.

Parameters:

Name Type Description

point

Point

A Point formatted object with X and Y coordinates (e.g., {x: 20, y:30});

[insertAt]

number

If specified, the point will be added at this position; otherwise at the end.

Returns:

Returns this Polygon shape object for chaining.

Type: Polygon

Examples:

Adding a point to the end of the points array:

polygon.addPoint({x:20, y:30});

Adding a point at a specified index:

polygon.addPoint({x:30, y:60}, 0); // adds a point the beginning of points array

Also See: