Skip to content

@putianyi888/vue3-plots


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 }) // true

Extends ​

Constructors ​

Constructor ​

new Polygon(points): Polygon

Defined in: geometry.ts:180

Parameters ​

ParameterTypeDescription
pointsPoint[]Ordered polygon vertices.

Returns ​

Polygon

Overrides ​

Shape.constructor

Properties ​

PropertyModifierTypeDefault valueDescriptionOverridesDefined in
pointsreadonlyPoint[]undefinedOrdered polygon vertices.-geometry.ts:180
typereadonly"polygon"'polygon'-Shape.typegeometry.ts:175

Methods ​

contains() ​

contains(point): boolean

Defined in: geometry.ts:190

Checks whether a point is inside or on the polygon boundary.

Parameters ​

ParameterTypeDescription
pointPointPoint to test.

Returns ​

boolean

Whether the point is contained by the polygon.

Overrides ​

Shape.contains


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.

Overrides ​

Shape.svgPath