point(index, [point_or_x], [y])

Class: Polygon.

Description:

Sets or gets a point of the Polygon {x:number, y:number} at a specified index.

Parameters:

Name Type Description

index

number

Index of the existing point to update.

[point_or_x]

Point | number

New point object or X coordinate of the new point.

[y]

number

Y coordinate of the new point.

Returns:

When getting a point, returns a point object or throws and Error. When setting the point, returns this Polygon or throws an Error.

Type: Point | Polygon

Examples:

Updating a point at index 3:

polygon.point(3, 50, 80); // x = 50, y = 80

// or...

polygon.point(3, {x:50, y:80});

Getting a point at index 3:

let p = polygon.point(3);

Also See: