Defined in: geometry.ts:174
Polygon defined by ordered vertices.
contains includes boundary points. Polygons with fewer than three vertices reject all points.
Example
ts
const polygon = new Polygon([
{ x: 10, y: 10 },
{ x: 40, y: 10 },
{ x: 40, y: 30 },
{ x: 10, y: 30 },
])
polygon.contains({ x: 20, y: 20 }) // trueExtends
Shape<"polygon">
Constructors
Constructor
new Polygon(
points):Polygon
Defined in: geometry.ts:180
Parameters
| Parameter | Type | Description |
|---|---|---|
points | Point[] | Ordered polygon vertices. |
Returns
Polygon
Overrides
Properties
| Property | Modifier | Type | Default value | Description | Overrides | Defined in |
|---|---|---|---|---|---|---|
points | readonly | Point[] | undefined | Ordered polygon vertices. | - | geometry.ts:180 |
type | readonly | "polygon" | 'polygon' | - | Shape.type | geometry.ts:175 |
Methods
contains()
contains(
point):boolean
Defined in: geometry.ts:190
Checks whether a point is inside or on the polygon boundary.
Parameters
| Parameter | Type | Description |
|---|---|---|
point | Point | Point to test. |
Returns
boolean
Whether the point is contained by the polygon.
Overrides
svgPath()
svgPath():
string
Defined in: geometry.ts:215
Generates an SVG path string for the polygon.
Returns
string
SVG path data, or an empty string when no points are available.