Construct a WeilerAthertonClipper instance used to perform the calculation.
Polygon to clip
Object used to clip the polygon
Type of clip to use
Object passed to the clippingObject methods toPolygon and pointsBetween
Configuration settings
Static
CLIP_The supported clip types. Values are equivalent to those in ClipperLib.ClipType.
Static
INTERSECTION_The supported intersection types.
Static
combineClip a given clipObject using the Weiler-Atherton algorithm.
At the moment, this will return a single PIXI.Polygon in the array unless clipType is a union and the polygon and clipObject do not overlap, in which case the [polygon, clipObject.toPolygon()] array will be returned. If this algorithm is expanded in the future to handle holes, an array of polygons may be returned.
Polygon to clip
Object to clip against the polygon
Options which configure how the union or intersection is computed
Optional
canMutate?: booleanIf the WeilerAtherton constructor could mutate or not the subject polygon points
options
(besides clipType and canMutate)
are captured by the rest operator (...clipOpts
) and passed to the WeilerAthertonClipper constructor.Array of polygons and clipObjects
Static
intersectIntersect a polygon and clipObject using the Weiler Atherton algorithm.
Polygon to clip
Object to clip against the polygon
Options passed to the clipping object methods toPolygon and pointsBetween
Static
testTest if one shape envelops the other. Assumes the shapes do not intersect.
Polygon to clip
Object to clip against the polygon
One of CLIP_TYPES
Clip options which are forwarded to toPolygon methods
Returns the polygon, the clipObject.toPolygon(), both, or neither.
Static
unionUnion a polygon and clipObject using the Weiler Atherton algorithm.
Polygon to clip
Object to clip against the polygon
Options passed to the clipping object methods toPolygon and pointsBetween
An implementation of the Weiler Atherton algorithm for clipping polygons. This currently only handles combinations that will not result in any holes. Support may be added for holes in the future.
This algorithm is faster than the Clipper library for this task because it relies on the unique properties of the circle, ellipse, or convex simple clip object. It is also more precise in that it uses the actual intersection points between the circle/ellipse and polygon, instead of relying on the polygon approximation of the circle/ellipse to find the intersection points.
For more explanation of the underlying algorithm, see: https://en.wikipedia.org/wiki/Weiler–Atherton_clipping_algorithm https://www.geeksforgeeks.org/weiler-atherton-polygon-clipping-algorithm https://h-educate.in/weiler-atherton-polygon-clipping-algorithm/