A Port of the General Polygon Clipper library by the University of Manchester (http://www.cs.man.ac.uk/~toby/gpc/)
This module exports a single data type, Polygon, which can represent euclidean polygons of arbitrary complexity and perform binary set operations on them. Polygons are not directly constructable with new; new Polygon instances can be created with Polygon.fromPoints() or Polygon.fromVertices(), described below. Polygons are also immutable; all geometric operations return new Polygon instances as their results.
readonly isEmpty: booleanIndicates whether the polygon has non-zero area.readonly isHole: booleanIndicates whether the polygon has negative area / is the boundary of a hole in a complex polygon.bounds: { minx: number, maxx: number, miny: number, maxy: number }Returns the minimal coordinate-aligned rectangular bounding box for the polygon.equals(obj: Polygon): booleanDetermine whether two polygons have the same vertex set, including the categorization of vertices as belonging to positive boundaries or holes.toVertices(): { bounds: { x: number, y: number }[][], holes: { x: number, y: number }[][] }Exports a description of the polygon as a set of vanilla JS objects.boundsis a list of lists of vertices representing the boundaries of positive-area sub-polygons, while holes is a list of lists of vertices representing the boundaries of interior holes.static fromVertices({ bounds, holes }: { bounds: Vertex[][], holes: Vertex[][] }): PolygonCreates a complex polygon from an object of the same shape as returned bytoVertices(). AVertexcan be an object of the form{ x: number, y: number }or a two-element array of[x, y].static fromPoints(points: Vertex[]): PolygonCreates a simple polygon from a list of vertices, where aVertexcan be an object of the form{ x: number, y: number }or a two-element array of[x, y].static intersection(...p: Polygon[]): PolygonComputes the geometric set intersection of a list ofPolygons.intersection(...p: Polygon[]): PolygonComputes the geometric set intersection ofthiswith a list of additionalPolygons.static union(...p: Polygon[]): PolygonComputes the geometric set union of a list ofPolygons.union(...p: Polygon[]): PolygonComputes the geometric set union ofthiswith a list of additionalPolygons.static xor(...p: Polygon[]): PolygonComputes the geometric symmetric set difference of a list ofPolygons.xor(...p: Polygon[]): PolygonComputes the geometric symmetric set difference ofthiswith a list of additionalPolygons.static difference(first: Polygon, ...p: Polygon[]): PolygonComputes the geometric set difference of the firstPolygonwith a list of additionalPolygons.difference(...p: Polygon[]): PolygonComputes the geometric set difference ofthiswith a list of additionalPolygons.