Clipper
High-level static API for common polygon clipping and offsetting operations. This module provides simple functions that cover most polygon boolean and offsetting needs while avoiding the inherent complexities of other modules.
Static Members
Computes the intersection of subject and clip paths.
| Name | Type |
|---|---|
subject |
Paths64 |
clip |
Paths64 |
fillRule |
FillRule |
| Returns |
|---|
| Paths64 |
Computes the intersection of subject and clip paths (floating-point).
| Name | Type | Default |
|---|---|---|
subject |
PathsD | |
clip |
PathsD | |
fillRule |
FillRule | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
Computes the union of subject paths.
| Name | Type |
|---|---|
subject |
Paths64 |
fillRule |
FillRule |
| Returns |
|---|
| Paths64 |
Computes the union of subject and clip paths.
| Name | Type |
|---|---|
subject |
Paths64 |
clip |
Paths64 |
fillRule |
FillRule |
| Returns |
|---|
| Paths64 |
Computes the union of subject paths (floating-point).
| Name | Type |
|---|---|
subject |
PathsD |
fillRule |
FillRule |
| Returns |
|---|
| PathsD |
Computes the union of subject and clip paths (floating-point).
| Name | Type | Default |
|---|---|---|
subject |
PathsD | |
clip |
PathsD | |
fillRule |
FillRule | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
Computes the difference of subject and clip paths (subject - clip).
| Name | Type |
|---|---|
subject |
Paths64 |
clip |
Paths64 |
fillRule |
FillRule |
| Returns |
|---|
| Paths64 |
Computes the difference of subject and clip paths (floating-point).
| Name | Type | Default |
|---|---|---|
subject |
PathsD | |
clip |
PathsD | |
fillRule |
FillRule | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
Computes the XOR (symmetric difference) of subject and clip paths.
| Name | Type |
|---|---|
subject |
Paths64 |
clip |
Paths64 |
fillRule |
FillRule |
| Returns |
|---|
| Paths64 |
Computes the XOR of subject and clip paths (floating-point).
| Name | Type | Default |
|---|---|---|
subject |
PathsD | |
clip |
PathsD | |
fillRule |
FillRule | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
booleanOp(clipType: ClipType, subject: Null<Paths64>, clip: Null<Paths64>, fillRule: FillRule): Paths64Performs a boolean operation on subject and clip paths.
| Name | Type |
|---|---|
clipType |
ClipType |
subject |
Null<Paths64> |
clip |
Null<Paths64> |
fillRule |
FillRule |
| Returns |
|---|
| Paths64 |
booleanOpD(clipType: ClipType, subject: PathsD, clip: Null<PathsD>, fillRule: FillRule, ?precision: Int = 2): PathsDPerforms a boolean operation on subject and clip paths (floating-point).
| Name | Type | Default |
|---|---|---|
clipType |
ClipType | |
subject |
PathsD | |
clip |
Null<PathsD> | |
fillRule |
FillRule | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
inflatePaths(paths: Paths64, delta: Float, joinType: JoinType, endType: EndType, ?miterLimit: Float = 2.0, ?arcTolerance: Float = 0.0): Paths64Inflates or deflates paths by the given delta.
| Name | Type | Default |
|---|---|---|
paths |
Paths64 | |
delta |
Float | |
joinType |
JoinType | |
endType |
EndType | |
miterLimit |
Float | 2.0 |
arcTolerance |
Float | 0.0 |
| Returns |
|---|
| Paths64 |
inflatePathsD(paths: PathsD, delta: Float, joinType: JoinType, endType: EndType, ?miterLimit: Float = 2.0, ?precision: Int = 2, ?arcTolerance: Float = 0.0): PathsDInflates or deflates paths by the given delta (floating-point).
| Name | Type | Default |
|---|---|---|
paths |
PathsD | |
delta |
Float | |
joinType |
JoinType | |
endType |
EndType | |
miterLimit |
Float | 2.0 |
precision |
Int | 2 |
arcTolerance |
Float | 0.0 |
| Returns |
|---|
| PathsD |
Clips paths to the given rectangle.
| Name | Type |
|---|---|
rect |
Rect64 |
paths |
Paths64 |
| Returns |
|---|
| Paths64 |
Clips a single path to the given rectangle.
| Name | Type |
|---|---|
rect |
Rect64 |
path |
Path64 |
| Returns |
|---|
| Paths64 |
Clips paths to the given rectangle (floating-point).
| Name | Type | Default |
|---|---|---|
rect |
RectD | |
paths |
PathsD | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
Clips lines (open paths) to the given rectangle.
| Name | Type |
|---|---|
rect |
Rect64 |
paths |
Paths64 |
| Returns |
|---|
| Paths64 |
Clips lines to the given rectangle (floating-point).
| Name | Type | Default |
|---|---|---|
rect |
RectD | |
paths |
PathsD | |
precision |
Int | 2 |
| Returns |
|---|
| PathsD |
Computes the Minkowski sum of pattern and path.
| Name | Type |
|---|---|
pattern |
Path64 |
path |
Path64 |
isClosed |
Bool |
| Returns |
|---|
| Paths64 |
Computes the Minkowski sum (floating-point).
| Name | Type | Default |
|---|---|---|
pattern |
PathD | |
path |
PathD | |
isClosed |
Bool | |
decimalPlaces |
Int | 2 |
| Returns |
|---|
| PathsD |
Computes the Minkowski difference of pattern and path.
| Name | Type |
|---|---|
pattern |
Path64 |
path |
Path64 |
isClosed |
Bool |
| Returns |
|---|
| Paths64 |
Computes the Minkowski difference (floating-point).
| Name | Type | Default |
|---|---|---|
pattern |
PathD | |
path |
PathD | |
isClosed |
Bool | |
decimalPlaces |
Int | 2 |
| Returns |
|---|
| PathsD |
Calculates the signed area of a path using the Shoelace formula.
| Name | Type |
|---|---|
path |
Path64 |
| Returns |
|---|
| Float |
Calculates the signed area of multiple paths.
| Name | Type |
|---|---|
paths |
Paths64 |
| Returns |
|---|
| Float |
Calculates the signed area of a path (floating-point).
| Name | Type |
|---|---|
path |
PathD |
| Returns |
|---|
| Float |
Calculates the signed area of multiple paths (floating-point).
| Name | Type |
|---|---|
paths |
PathsD |
| Returns |
|---|
| Float |
Returns true if the path has positive (counter-clockwise) area.
| Name | Type |
|---|---|
poly |
Path64 |
| Returns |
|---|
| Bool |
Returns true if the path has positive (counter-clockwise) area (floating-point).
| Name | Type |
|---|---|
poly |
PathD |
| Returns |
|---|
| Bool |
translatePath(path: Path64, dx: ClipperInt64, dy: ClipperInt64): Path64Translates a path by dx, dy.
| Name | Type |
|---|---|
path |
Path64 |
dx |
ClipperInt64 |
dy |
ClipperInt64 |
| Returns |
|---|
| Path64 |
translatePaths(paths: Paths64, dx: ClipperInt64, dy: ClipperInt64): Paths64Translates multiple paths by dx, dy.
| Name | Type |
|---|---|
paths |
Paths64 |
dx |
ClipperInt64 |
dy |
ClipperInt64 |
| Returns |
|---|
| Paths64 |
Translates a path by dx, dy (floating-point).
| Name | Type |
|---|---|
path |
PathD |
dx |
Float |
dy |
Float |
| Returns |
|---|
| PathD |
Translates multiple paths by dx, dy (floating-point).
| Name | Type |
|---|---|
paths |
PathsD |
dx |
Float |
dy |
Float |
| Returns |
|---|
| PathsD |
Returns a reversed copy of the path.
| Name | Type |
|---|---|
path |
Path64 |
| Returns |
|---|
| Path64 |
Returns a reversed copy of the path (floating-point).
| Name | Type |
|---|---|
path |
PathD |
| Returns |
|---|
| PathD |
Returns reversed copies of all paths.
| Name | Type |
|---|---|
paths |
Paths64 |
| Returns |
|---|
| Paths64 |
Returns reversed copies of all paths (floating-point).
| Name | Type |
|---|---|
paths |
PathsD |
| Returns |
|---|
| PathsD |
Scales a path by the given factor.
| Name | Type |
|---|---|
path |
Path64 |
scale |
Float |
| Returns |
|---|
| Path64 |
Scales multiple paths by the given factor.
| Name | Type |
|---|---|
paths |
Paths64 |
scale |
Float |
| Returns |
|---|
| Paths64 |
Scales a PathD to Path64 with the given scale.
| Name | Type |
|---|---|
path |
PathD |
scale |
Float |
| Returns |
|---|
| Path64 |
Scales PathsD to Paths64 with the given scale.
| Name | Type |
|---|---|
paths |
PathsD |
scale |
Float |
| Returns |
|---|
| Paths64 |
Scales a Path64 to PathD with the given scale.
| Name | Type |
|---|---|
path |
Path64 |
scale |
Float |
| Returns |
|---|
| PathD |
Scales Paths64 to PathsD with the given scale.
| Name | Type |
|---|---|
paths |
Paths64 |
scale |
Float |
| Returns |
|---|
| PathsD |
Scales a RectD to Rect64.
| Name | Type |
|---|---|
rect |
RectD |
scale |
Float |
| Returns |
|---|
| Rect64 |
Converts PathD to Path64 without scaling.
| Name | Type |
|---|---|
path |
PathD |
| Returns |
|---|
| Path64 |
Converts PathsD to Paths64 without scaling.
| Name | Type |
|---|---|
paths |
PathsD |
| Returns |
|---|
| Paths64 |
Converts Path64 to PathD without scaling.
| Name | Type |
|---|---|
path |
Path64 |
| Returns |
|---|
| PathD |
Converts Paths64 to PathsD without scaling.
| Name | Type |
|---|---|
paths |
Paths64 |
| Returns |
|---|
| PathsD |
Gets the bounding rectangle of a path.
| Name | Type |
|---|---|
path |
Path64 |
| Returns |
|---|
| Rect64 |
Gets the bounding rectangle of multiple paths.
| Name | Type |
|---|---|
paths |
Paths64 |
| Returns |
|---|
| Rect64 |
Gets the bounding rectangle of a path (floating-point).
| Name | Type |
|---|---|
path |
PathD |
| Returns |
|---|
| RectD |
Gets the bounding rectangle of multiple paths (floating-point).
| Name | Type |
|---|---|
paths |
PathsD |
| Returns |
|---|
| RectD |
Creates a path from an array of integers [x1, y1, x2, y2, ...].
| Name | Type |
|---|---|
arr |
Array<Int> |
| Returns |
|---|
| Path64 |
Creates a path from an array of floats [x1, y1, x2, y2, ...].
| Name | Type |
|---|---|
arr |
Array<Float> |
| Returns |
|---|
| PathD |
Calculates the squared distance between two points.
| Name | Type |
|---|---|
val |
Float |
| Returns |
|---|
| Float |
Calculates the squared distance between two Point64 values.
| Name | Type |
|---|---|
pt1 |
Point64 |
pt2 |
Point64 |
| Returns |
|---|
| Float |
Calculates the midpoint between two Point64 values.
| Name | Type |
|---|---|
pt1 |
Point64 |
pt2 |
Point64 |
| Returns |
|---|
| Point64 |
Calculates the midpoint between two PointD values.
| Name | Type |
|---|---|
pt1 |
PointD |
pt2 |
PointD |
| Returns |
|---|
| PointD |
Tests if a point is near equal to another point within a squared distance tolerance.
| Name | Type |
|---|---|
pt1 |
PointD |
pt2 |
PointD |
distanceSqrd |
Float |
| Returns |
|---|
| Bool |
Strips near-duplicate points from a path.
| Name | Type |
|---|---|
path |
PathD |
minEdgeLenSqrd |
Float |
isClosedPath |
Bool |
| Returns |
|---|
| PathD |
Strips duplicate points from a path.
| Name | Type |
|---|---|
path |
Path64 |
isClosedPath |
Bool |
| Returns |
|---|
| Path64 |
Returns perpendicular distance squared from a point to a line.
| Name | Type |
|---|---|
pt |
Point64 |
line1 |
Point64 |
line2 |
Point64 |
| Returns |
|---|
| Float |
Returns perpendicular distance squared from a point to a line (floating-point).
| Name | Type |
|---|---|
pt |
PointD |
line1 |
PointD |
line2 |
PointD |
| Returns |
|---|
| Float |
pointInPolygon(pt: Point64, polygon: Path64): PointInPolygonResultTests if a point is inside a polygon.
| Name | Type |
|---|---|
pt |
Point64 |
polygon |
Path64 |
| Returns |
|---|
| PointInPolygonResult |
Generates an ellipse path.
| Name | Type | Default |
|---|---|---|
center |
Point64 | |
radiusX |
Float | |
radiusY |
Float | 0 |
steps |
Int | 0 |
| Returns |
|---|
| Path64 |
Generates an ellipse path (floating-point).
| Name | Type | Default |
|---|---|---|
center |
PointD | |
radiusX |
Float | |
radiusY |
Float | 0 |
steps |
Int | 0 |
| Returns |
|---|
| PathD |
Trims collinear points from a path.
| Name | Type | Default |
|---|---|---|
path |
Path64 | |
isOpen |
Bool | false |
| Returns |
|---|
| Path64 |
Triangulates paths using Constrained Delaunay Triangulation.
| Name | Type | Default |
|---|---|---|
paths |
Paths64 | |
useDelaunay |
Bool | true |
| Returns |
|---|
| AnonStruct |