polygon2.toJSON

The polygon as plain JSON: its flat ring.

Value helperSince 0.4.0

Usage

TypeScript
polygon.toJSON(): { xy: number[] }

Returns

{ xy } with the corners as a plain number array, not closed.

Example

TypeScript
JSON.stringify(Polygon2.rectangle(2, 2).value) // → '{"xy":[-1,-1,1,-1,1,1,-1,1]}'

See also