Class Clipper
This unit has been designed to hide the library's complexities behind a number of simple functions. However, not all of the library's features are accessible here. Less commonly needed features that provide more flexibility can still be accessed from the other units.
Boolean operations for polygon clipping:
- AND (intersection) - regions covered by both subject and clip polygons
- OR (union) - regions covered by subject or clip polygons, or both polygons
- NOT (difference) - regions covered by subject, but not clip polygons
- XOR (exclusive or) - regions covered by subject or clip polygons, but not both
difference is non-commutative.
This means that subject and clip paths are
interchangeable except when performing difference operations (and as long as
subject paths are closed).
All polygon clipping is performed with a Clipper object with the specific
boolean operation indicated by the ClipType parameter passed in
its Execute method. With regard to open paths (polylines), clipping
rules generally match those of closed paths (polygons). However, when there
are both polyline and polygon subjects, the following clipping rules apply:
- union operations - polylines will be clipped by any overlapping polygons so that only non-overlapped portions will be returned in the solution, together with solution polygons
- intersection, difference and xor operations - polylines will be clipped by 'clip' polygons, and there will be no interaction between polylines and any subject polygons
Polygon Offsetting:
Geometric offsetting refers to the process of creating parallel curves that are offset a specified distance from their starting positions.
While all offsetting is performed by the ClipperOffset class in
the Clipper.Offset unit, the complexities of constructing and
using this class can usually be avoided by using instead the
inflatePaths() function in this class. This function can both inflate and
shrink polygons (using positive and negative offsets respectively).
Offsetting can be performed using a number of JoinTypes and EndTypes. While
both open paths and closed paths can be offset, logically only closed paths
can be shrunk (ie with negative offsets).
Note: Offsetting shouldn't be confused with the process of polygon translation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPolyNodeToPathsD(PolyPathD polyPath, PathsD paths) Flattens a floating-point polytree into a path collection.static doubleReturns the area of the supplied polygon.static doubleReturns the signed area of the supplied floating-point polygon.static doubleReturns the area of the supplied polygon.static doubleReturns the combined signed area of the supplied floating-point polygons.static voidbooleanOp(ClipType clipType, @Nullable Paths64 subject, @Nullable Paths64 clip, PolyTree64 polytree, FillRule fillRule) This function is a generic alternative to the Intersect, Difference, Union and XOR functions.static voidbooleanOp(ClipType clipType, @Nullable PathsD subject, @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule) Applies the requested boolean operation to floating-point paths and stores the result in aPolyTreeDusing the default precision.static voidbooleanOp(ClipType clipType, @Nullable PathsD subject, @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule, int precision) Applies the requested boolean operation to floating-point paths and stores the result in aPolyTreeD.static Paths64Applies the requested boolean operation to integer subject and clip paths.static PathsDbooleanOp(ClipType clipType, PathsD subject, @Nullable PathsD clip, FillRule fillRule, int precision) This function is a generic alternative to the Intersect, Difference, Union and XOR functions.static PathsDApplies the requested boolean operation to floating-point subject and clip paths using the default precision.static Paths64difference(Paths64 subject, Paths64 clip, FillRule fillRule) Subtracts the clip paths from the subject paths.static PathsDdifference(PathsD subject, PathsD clip, FillRule fillRule) Subtracts the clip paths from the subject paths using the default precision.static PathsDdifference(PathsD subject, PathsD clip, FillRule fillRule, int precision) Subtracts the clip paths from the subject paths.static doubledistanceSqr(Point64 pt1, Point64 pt2) Returns the squared distance between two integer points.static Path64Approximates an integer circle using an automatically chosen step count.static Path64Approximates an integer ellipse using an automatically chosen step count.static Path64Approximates an integer ellipse.static PathDApproximates a floating-point circle using an automatically chosen step count.static PathDApproximates a floating-point ellipse using an automatically chosen step count.static PathDApproximates a floating-point ellipse.static Rect64Returns the bounds of an integer path.static RectDReturns the bounds of a floating-point path.static Rect64Returns the bounds of multiple integer paths.static RectDReturns the bounds of multiple floating-point paths.static Paths64inflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType) Inflates or shrinks integer paths with default miter and arc settings.static Paths64inflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance) Inflates or shrinks integer paths.static PathsDinflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType) Inflates or shrinks floating-point paths with default settings.static PathsDinflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit) Inflates or shrinks floating-point paths with a custom miter limit.static PathsDinflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance, int precision) These functions encapsulateClipperOffset, the class that performs both polygon and open path offsetting.static voidinflateRect(Rect64 rec, int dx, int dy) Expands or contracts an integer rectangle in place.static voidinflateRect(RectD rec, double dx, double dy) Expands or contracts a floating-point rectangle in place.static Paths64Intersects two sets of integer paths.static PathsDIntersects two sets of floating-point paths using the default precision.static PathsDIntersects two sets of floating-point paths.static booleanisPositive(Path64 poly) This function assesses the winding orientation of closed paths.static booleanisPositive(PathD poly) This function assesses the winding orientation of closed paths.static PathDmakePath(double[] arr) Creates a floating-point path from alternatingx,ycoordinate pairs.static Path64makePath(int[] arr) Creates an integer path from alternatingx,ycoordinate pairs.static Path64makePath(long[] arr) static Point64static PointDstatic Paths64minkowskiDiff(Path64 pattern, Path64 path, boolean isClosed) static PathsDminkowskiDiff(PathD pattern, PathD path, boolean isClosed) static Paths64minkowskiSum(Path64 pattern, Path64 path, boolean isClosed) static PathsDminkowskiSum(PathD pattern, PathD path, boolean isClosed) static Path64offsetPath(Path64 path, long dx, long dy) static Path64static Stringpath64ToString(Path64 path) static PathDstatic StringpathDToString(PathD path) static Paths64static Stringpaths64ToString(Paths64 paths) static PathsDstatic StringpathsDToString(PathsD paths) static doubleperpendicDistFromLineSqrd(Point64 pt, Point64 line1, Point64 line2) static doubleperpendicDistFromLineSqrd(PointD pt, PointD line1, PointD line2) static PointInPolygonResultpointInPolygon(Point64 pt, Path64 polygon) static PointInPolygonResultpointInPolygon(PointD pt, PathD polygon) static PointInPolygonResultpointInPolygon(PointD pt, PathD polygon, int precision) static booleanpointsNearEqual(PointD pt1, PointD pt2, double distanceSqrd) static Paths64polyTreeToPaths64(PolyTree64 polyTree) static PathsDpolyTreeToPathsD(PolyTreeD polyTree) static PathDramerDouglasPeucker(PathD path, double epsilon) Simplifies a floating-point path using the Ramer-Douglas-Peucker algorithm.static Paths64ramerDouglasPeucker(Paths64 paths, double epsilon) The Ramer-Douglas-Peucker algorithm is very useful in removing path segments that don't contribute meaningfully to the path's shape.static PathsDramerDouglasPeucker(PathsD paths, double epsilon) Simplifies floating-point paths using the Ramer-Douglas-Peucker algorithm.static Path64ramerDouglasPeuckerPath(Path64 path, double epsilon) The Ramer-Douglas-Peucker algorithm is very useful in removing path segments that don't contribute meaningfully to the path's shape.static voidstatic voidstatic Paths64static Paths64static PathsDstatic PathsDstatic PathsDstatic PathsDstatic Paths64rectClipLines(Rect64 rect, Path64 path) static Paths64rectClipLines(Rect64 rect, Paths64 paths) static PathsDrectClipLines(RectD rect, PathD path) static PathsDrectClipLines(RectD rect, PathD path, int precision) static PathsDrectClipLines(RectD rect, PathsD paths) static PathsDrectClipLines(RectD rect, PathsD paths, int precision) static Path64reversePath(Path64 path) static PathDreversePath(PathD path) static Paths64reversePaths(Paths64 paths) static PathsDreversePaths(PathsD paths) static Path64static PathDstatic Path64scalePath64(PathD path, double scale) static PathDscalePathD(Path64 path, double scale) static Paths64scalePaths(Paths64 paths, double scale) static PathsDscalePaths(PathsD paths, double scale) static Paths64scalePaths64(PathsD paths, double scale) static PathsDscalePathsD(Paths64 paths, double scale) static Point64scalePoint64(Point64 pt, double scale) static PointDscalePointD(Point64 pt, double scale) static Rect64static Path64simplifyPath(Path64 path, double epsilon) Simplifies a path assuming an open path by default.static Path64simplifyPath(Path64 path, double epsilon, boolean isClosedPath) Removes vertices that are less than the specified epsilon distance from an imaginary line that passes through its 2 adjacent vertices.static PathDsimplifyPath(PathD path, double epsilon) Simplifies a floating-point path assuming an open path by default.static PathDsimplifyPath(PathD path, double epsilon, boolean isClosedPath) Removes vertices that are less than the specified epsilon distance from an imaginary line that passes through its 2 adjacent vertices.static Paths64simplifyPaths(Paths64 paths, double epsilon) Simplifies multiple integer paths assuming open paths by default.static Paths64simplifyPaths(Paths64 paths, double epsilon, boolean isClosedPath) Simplifies multiple integer paths.static PathsDsimplifyPaths(PathsD paths, double epsilon) Simplifies multiple floating-point paths assuming open paths by default.static PathsDsimplifyPaths(PathsD paths, double epsilon, boolean isClosedPath) Simplifies multiple floating-point paths.static doublesqr(double value) static doublesqr(long value) static Path64stripDuplicates(Path64 path, boolean isClosedPath) static PathDstripNearDuplicates(PathD path, double minEdgeLenSqrd, boolean isClosedPath) static Path64translatePath(Path64 path, long dx, long dy) static PathDtranslatePath(PathD path, double dx, double dy) static Paths64translatePaths(Paths64 paths, long dx, long dy) static PathsDtranslatePaths(PathsD paths, double dx, double dy) static Path64trimCollinear(Path64 path) This function removes the vertices between adjacent collinear segments.static Path64trimCollinear(Path64 path, boolean isOpen) This function removes the vertices between adjacent collinear segments.static PathDtrimCollinear(PathD path, int precision) This function removes the vertices between adjacent collinear segments.static PathDtrimCollinear(PathD path, int precision, boolean isOpen) This function removes the vertices between adjacent collinear segments.static Paths64Unites the supplied integer subject paths.static Paths64Unites two sets of integer paths.static PathsDUnites the supplied floating-point subject paths using the default precision.static PathsDUnites two sets of floating-point paths using the default precision.static PathsDUnites two sets of floating-point paths.static Paths64Computes the exclusive-or of two sets of integer paths.static PathsDComputes the exclusive-or of two sets of floating-point paths using the default precision.static PathsDComputes the exclusive-or of two sets of floating-point paths.
-
Field Details
-
Constructor Details
-
Clipper
public Clipper()
-
-
Method Details
-
intersect
Intersects two sets of integer paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the intersected paths.
-
intersect
Intersects two sets of floating-point paths using the default precision.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the intersected paths.
-
intersect
Intersects two sets of floating-point paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.precision- the decimal precision to use when scaling coordinates.- Returns:
- the intersected paths.
-
union
Unites the supplied integer subject paths.- Parameters:
subject- the subject paths.fillRule- the polygon fill rule to apply.- Returns:
- the unioned paths.
-
union
Unites two sets of integer paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the unioned paths.
-
union
Unites the supplied floating-point subject paths using the default precision.- Parameters:
subject- the subject paths.fillRule- the polygon fill rule to apply.- Returns:
- the unioned paths.
-
union
Unites two sets of floating-point paths using the default precision.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the unioned paths.
-
union
Unites two sets of floating-point paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.precision- the decimal precision to use when scaling coordinates.- Returns:
- the unioned paths.
-
difference
Subtracts the clip paths from the subject paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the difference of the subject and clip paths.
-
difference
Subtracts the clip paths from the subject paths using the default precision.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the difference of the subject and clip paths.
-
difference
Subtracts the clip paths from the subject paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.precision- the decimal precision to use when scaling coordinates.- Returns:
- the difference of the subject and clip paths.
-
xor
Computes the exclusive-or of two sets of integer paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the exclusive-or of the subject and clip paths.
-
xor
Computes the exclusive-or of two sets of floating-point paths using the default precision.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the exclusive-or of the subject and clip paths.
-
xor
Computes the exclusive-or of two sets of floating-point paths.- Parameters:
subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.precision- the decimal precision to use when scaling coordinates.- Returns:
- the exclusive-or of the subject and clip paths.
-
booleanOp
public static Paths64 booleanOp(ClipType clipType, Paths64 subject, Paths64 clip, FillRule fillRule) Applies the requested boolean operation to integer subject and clip paths.- Parameters:
clipType- the boolean operation to perform.subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the resulting paths.
-
booleanOp
public static void booleanOp(ClipType clipType, @Nullable @Nullable Paths64 subject, @Nullable @Nullable Paths64 clip, PolyTree64 polytree, FillRule fillRule) This function is a generic alternative to the Intersect, Difference, Union and XOR functions.- Parameters:
clipType- the boolean operation to perform.subject- the subject paths.clip- the clip paths, ornull.polytree- the destination polytree that receives the result.fillRule- the polygon fill rule to apply.
-
booleanOp
Applies the requested boolean operation to floating-point subject and clip paths using the default precision.- Parameters:
clipType- the boolean operation to perform.subject- the subject paths.clip- the clip paths.fillRule- the polygon fill rule to apply.- Returns:
- the resulting paths.
-
booleanOp
public static PathsD booleanOp(ClipType clipType, PathsD subject, @Nullable @Nullable PathsD clip, FillRule fillRule, int precision) This function is a generic alternative to the Intersect, Difference, Union and XOR functions.- Parameters:
clipType- the boolean operation to perform.subject- the subject paths.clip- the clip paths, ornull.fillRule- the polygon fill rule to apply.precision- The desired coordinate precision (up to 8 decimal places).- Returns:
- the resulting paths.
-
booleanOp
public static void booleanOp(ClipType clipType, @Nullable @Nullable PathsD subject, @Nullable @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule) Applies the requested boolean operation to floating-point paths and stores the result in aPolyTreeDusing the default precision.- Parameters:
clipType- the boolean operation to perform.subject- the subject paths.clip- the clip paths, ornull.polytree- the destination polytree that receives the result.fillRule- the polygon fill rule to apply.
-
booleanOp
public static void booleanOp(ClipType clipType, @Nullable @Nullable PathsD subject, @Nullable @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule, int precision) Applies the requested boolean operation to floating-point paths and stores the result in aPolyTreeD.- Parameters:
clipType- the boolean operation to perform.subject- the subject paths.clip- the clip paths, ornull.polytree- the destination polytree that receives the result.fillRule- the polygon fill rule to apply.precision- the decimal precision to use when scaling coordinates.
-
inflatePaths
Inflates or shrinks integer paths with default miter and arc settings.- Parameters:
paths- the paths to offset.delta- the offset distance.joinType- the join type to apply at vertices.endType- the end treatment to apply.- Returns:
- the offset paths.
- See Also:
-
inflatePaths
public static Paths64 inflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance) Inflates or shrinks integer paths.- Parameters:
paths- the paths to offset.delta- the offset distance.joinType- the join type to apply at vertices.endType- the end treatment to apply.miterLimit- the miter limit in multiples ofdelta.arcTolerance- the tolerance used when flattening round joins.- Returns:
- the offset paths.
- See Also:
-
inflatePaths
public static PathsD inflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit) Inflates or shrinks floating-point paths with a custom miter limit.- Parameters:
paths- the paths to offset.delta- the offset distance.joinType- the join type to apply at vertices.endType- the end treatment to apply.miterLimit- the miter limit in multiples ofdelta.- Returns:
- the offset paths.
- See Also:
-
inflatePaths
Inflates or shrinks floating-point paths with default settings.- Parameters:
paths- the paths to offset.delta- the offset distance.joinType- the join type to apply at vertices.endType- the end treatment to apply.- Returns:
- the offset paths.
- See Also:
-
inflatePaths
public static PathsD inflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance, int precision) These functions encapsulateClipperOffset, the class that performs both polygon and open path offsetting.When using this function to inflate polygons (ie closed paths), it's important that you select
EndType.Polygon. If instead you select one of the open path end types (includingEndType.Joined), you'll inflate the polygon's outline.With closed paths (polygons), a positive delta specifies how much outer polygon contours will expand and how much inner "hole" contours will contract (and the converse with negative deltas).
With open paths (polylines), including
EndType.Joined, delta specifies the width of the inflated line.Caution: Offsetting self-intersecting polygons may produce unexpected results.
- Parameters:
paths- A Paths object that is to undergo offsetting.delta- With closed paths (polygons), a positivedeltaspecifies how much outer polygon contours will expand and how much inner "hole" contours will contract (and the converse with negative deltas).With open paths (polylines), including EndType.Join,
deltaspecifies the width of the inflated line.joinType- seeJoinTypeendType- seeEndTypemiterLimit- Sets the maximum distance in multiples of delta that vertices can be offset from their original positions before squaring is applied. (Squaring truncates a miter by 'cutting it off' at 1 × delta distance from the original vertex.)The default value for MiterLimit is 2 (ie twice delta). This is also the smallest MiterLimit that's allowed. If mitering was unrestricted (ie without any squaring), then offsets at very acute angles would generate unacceptably long 'spikes'.
arcTolerance- Sets the distance the flattened path will deviate from the 'true' arc (only relevant when offsetting with JoinType.Round and/or EndType.Round).precision- The number of decimal places of precision to consider when paths is type PathsD. (Maximum is 8 decimal places)- Returns:
- the offset paths.
-
rectClip
-
rectClip
-
rectClip
-
rectClip
-
rectClip
-
rectClip
-
rectClipLines
-
rectClipLines
-
rectClipLines
-
rectClipLines
-
rectClipLines
-
rectClipLines
-
minkowskiSum
-
minkowskiSum
-
minkowskiDiff
-
minkowskiDiff
-
area
Returns the area of the supplied polygon. It's assumed that the path is closed and does not self-intersect. Depending on the path's winding orientation, this value may be positive or negative. If the winding is clockwise, then the area will be positive and conversely, if winding is counter-clockwise, then the area will be negative.- Parameters:
path- the path whose area will be calculated.- Returns:
- the signed area of the path.
-
area
Returns the area of the supplied polygon. It's assumed that the path is closed and does not self-intersect. Depending on the path's winding orientation, this value may be positive or negative. If the winding is clockwise, then the area will be positive and conversely, if winding is counter-clockwise, then the area will be negative.- Parameters:
paths- the paths whose total area will be calculated.- Returns:
- the sum of the signed areas of all supplied paths.
-
area
Returns the signed area of the supplied floating-point polygon.- Parameters:
path- the path whose area will be calculated.- Returns:
- the signed area of the path.
-
area
Returns the combined signed area of the supplied floating-point polygons.- Parameters:
paths- the paths whose total area will be calculated.- Returns:
- the sum of the signed areas of all supplied paths.
-
isPositive
This function assesses the winding orientation of closed paths.Positive winding paths will be oriented in an anti-clockwise direction in Cartesian coordinates (where coordinate values increase when heading rightward and upward). Nevertheless it's common for graphics libraries to use inverted Y-axes (where Y values decrease heading upward). In these libraries, paths with Positive winding will be oriented clockwise.
Note: Self-intersecting polygons have indeterminate orientation since some path segments will commonly wind in opposite directions to other segments.
- Parameters:
poly- the polygon to test.- Returns:
truewhen the polygon has positive winding.
-
isPositive
This function assesses the winding orientation of closed paths.Positive winding paths will be oriented in an anti-clockwise direction in Cartesian coordinates (where coordinate values increase when heading rightward and upward). Nevertheless it's common for graphics libraries to use inverted Y-axes (where Y values decrease heading upward). In these libraries, paths with Positive winding will be oriented clockwise.
Note: Self-intersecting polygons have indeterminate orientation since some path segments will commonly wind in opposite directions to other segments.
- Parameters:
poly- the polygon to test.- Returns:
truewhen the polygon has positive winding.
-
path64ToString
-
paths64ToString
-
pathDToString
-
pathsDToString
-
offsetPath
-
scalePoint64
-
scalePointD
-
scaleRect
-
scalePath
-
scalePaths
-
scalePath
-
scalePaths
-
scalePath64
-
scalePaths64
-
scalePathD
-
scalePathsD
-
path64
-
paths64
-
pathsD
-
pathD
-
translatePath
-
translatePaths
-
translatePath
-
translatePaths
-
reversePath
-
reversePath
-
reversePaths
-
reversePaths
-
getBounds
Returns the bounds of an integer path.- Parameters:
path- the path to measure.- Returns:
- the path bounds, or an empty rectangle when the path is empty.
-
getBounds
Returns the bounds of multiple integer paths.- Parameters:
paths- the paths to measure.- Returns:
- the combined bounds, or an empty rectangle when no points are supplied.
-
getBounds
Returns the bounds of a floating-point path.- Parameters:
path- the path to measure.- Returns:
- the path bounds, or an empty rectangle when the path is empty.
-
getBounds
Returns the bounds of multiple floating-point paths.- Parameters:
paths- the paths to measure.- Returns:
- the combined bounds, or an empty rectangle when no points are supplied.
-
makePath
Creates an integer path from alternatingx,ycoordinate pairs.- Parameters:
arr- the coordinate array.- Returns:
- the constructed path.
-
makePath
-
makePath
Creates a floating-point path from alternatingx,ycoordinate pairs.- Parameters:
arr- the coordinate array.- Returns:
- the constructed path.
-
sqr
public static double sqr(double value) -
sqr
public static double sqr(long value) -
distanceSqr
Returns the squared distance between two integer points.- Parameters:
pt1- the first point.pt2- the second point.- Returns:
- the squared Euclidean distance between the two points.
-
midPoint
-
midPoint
-
inflateRect
Expands or contracts an integer rectangle in place.- Parameters:
rec- the rectangle to modify.dx- the horizontal delta to apply on both sides.dy- the vertical delta to apply on both sides.
-
inflateRect
Expands or contracts a floating-point rectangle in place.- Parameters:
rec- the rectangle to modify.dx- the horizontal delta to apply on both sides.dy- the vertical delta to apply on both sides.
-
pointsNearEqual
-
stripNearDuplicates
-
stripDuplicates
-
polyTreeToPaths64
-
addPolyNodeToPathsD
Flattens a floating-point polytree into a path collection.- Parameters:
polyPath- the current polytree node.paths- the destination path collection.
-
polyTreeToPathsD
-
perpendicDistFromLineSqrd
-
perpendicDistFromLineSqrd
-
rDP
-
ramerDouglasPeuckerPath
The Ramer-Douglas-Peucker algorithm is very useful in removing path segments that don't contribute meaningfully to the path's shape. The algorithm's aggressiveness is determined by the epsilon parameter, with larger values removing more vertices. (Somewhat simplistically, the algorithm removes vertices that are less than epsilon distance from imaginary lines passing through their adjacent vertices.)This function can be particularly useful when offsetting paths (ie inflating/shrinking) where the offsetting process often creates tiny segments. These segments don't enhance curve quality, but they will slow path processing (whether during file storage, or when rendering, or in subsequent offsetting procedures).
- Parameters:
path- the path to simplify.epsilon- the maximum permitted deviation from the original path.- Returns:
- the simplified path.
-
ramerDouglasPeucker
The Ramer-Douglas-Peucker algorithm is very useful in removing path segments that don't contribute meaningfully to the path's shape. The algorithm's aggressiveness is determined by the epsilon parameter, with larger values removing more vertices. (Somewhat simplistically, the algorithm removes vertices that are less than epsilon distance from imaginary lines passing through their adjacent vertices.)This function can be particularly useful when offsetting paths (ie inflating/shrinking) where the offsetting process often creates tiny segments. These segments don't enhance curve quality, but they will slow path processing (whether during file storage, or when rendering, or in subsequent offsetting procedures).
- Parameters:
paths- the paths to simplify.epsilon- the maximum permitted deviation from the original paths.- Returns:
- the simplified paths.
-
rDP
-
ramerDouglasPeucker
Simplifies a floating-point path using the Ramer-Douglas-Peucker algorithm.- Parameters:
path- the path to simplify.epsilon- the maximum permitted deviation from the original path.- Returns:
- the simplified path.
-
ramerDouglasPeucker
Simplifies floating-point paths using the Ramer-Douglas-Peucker algorithm.- Parameters:
paths- the paths to simplify.epsilon- the maximum permitted deviation from the original paths.- Returns:
- the simplified paths.
-
simplifyPath
Simplifies a path assuming an open path by default.- Parameters:
path- the path to simplify.epsilon- the maximum permitted deviation from the original path.- Returns:
- the simplified path.
-
simplifyPath
Removes vertices that are less than the specified epsilon distance from an imaginary line that passes through its 2 adjacent vertices. Logically, smaller epsilon values will be less aggressive in removing vertices than larger epsilon values.This function is strongly recommended before offsetting (ie before inflating/shrinking) when paths may contain redundant segments. And removing redundant segments is especially important when offsetting paths that have themselves been offset.
- Parameters:
path- the path to simplify.epsilon- the maximum permitted deviation from the original path.isClosedPath- whether the path should be treated as closed.- Returns:
- the simplified path.
-
simplifyPaths
Simplifies multiple integer paths assuming open paths by default.- Parameters:
paths- the paths to simplify.epsilon- the maximum permitted deviation from the original paths.- Returns:
- the simplified paths.
-
simplifyPaths
Simplifies multiple integer paths.- Parameters:
paths- the paths to simplify.epsilon- the maximum permitted deviation from the original paths.isClosedPath- whether the paths should be treated as closed.- Returns:
- the simplified paths.
-
simplifyPath
Simplifies a floating-point path assuming an open path by default.- Parameters:
path- the path to simplify.epsilon- the maximum permitted deviation from the original path.- Returns:
- the simplified path.
-
simplifyPath
Removes vertices that are less than the specified epsilon distance from an imaginary line that passes through its 2 adjacent vertices. Logically, smaller epsilon values will be less aggressive in removing vertices than larger epsilon values.This function is strongly recommended before offsetting (ie before inflating/shrinking) when paths may contain redundant segments. And removing redundant segments is especially important when offsetting paths that have themselves been offset.
- Parameters:
path- the path to simplify.epsilon- the maximum permitted deviation from the original path.isClosedPath- whether the path should be treated as closed.- Returns:
- the simplified path.
-
simplifyPaths
Simplifies multiple floating-point paths assuming open paths by default.- Parameters:
paths- the paths to simplify.epsilon- the maximum permitted deviation from the original paths.- Returns:
- the simplified paths.
-
simplifyPaths
Simplifies multiple floating-point paths.- Parameters:
paths- the paths to simplify.epsilon- the maximum permitted deviation from the original paths.isClosedPath- whether the paths should be treated as closed.- Returns:
- the simplified paths.
-
trimCollinear
This function removes the vertices between adjacent collinear segments. It will also remove duplicate vertices (adjacent vertices with identical coordinates).Note: Duplicate vertices will be removed automatically from clipping solutions, but not collinear edges unless the Clipper object's PreserveCollinear property had been disabled.
- Parameters:
path- the path to trim.- Returns:
- the trimmed path.
-
trimCollinear
This function removes the vertices between adjacent collinear segments. It will also remove duplicate vertices (adjacent vertices with identical coordinates).Note: Duplicate vertices will be removed automatically from clipping solutions, but not collinear edges unless the Clipper object's PreserveCollinear property had been disabled.
- Parameters:
path- the path to trim.isOpen- whether the path should be treated as open.- Returns:
- the trimmed path.
-
trimCollinear
This function removes the vertices between adjacent collinear segments. It will also remove duplicate vertices (adjacent vertices with identical coordinates).With floating point paths, the precision parameter indicates the decimal precision that's required when determining collinearity.
Note: Duplicate vertices will be removed automatically from clipping solutions, but not collinear edges unless the Clipper object's PreserveCollinear property had been disabled.
- Parameters:
path- the path to trim.precision- the decimal precision used to test collinearity.- Returns:
- the trimmed path.
-
trimCollinear
This function removes the vertices between adjacent collinear segments. It will also remove duplicate vertices (adjacent vertices with identical coordinates).With floating point paths, the precision parameter indicates the decimal precision that's required when determining collinearity.
Note: Duplicate vertices will be removed automatically from clipping solutions, but not collinear edges unless the Clipper object's PreserveCollinear property had been disabled.
- Parameters:
path- the path to trim.precision- the decimal precision used to test collinearity.isOpen- whether the path should be treated as open.- Returns:
- the trimmed path.
-
pointInPolygon
-
pointInPolygon
-
pointInPolygon
-
ellipse
Approximates an integer ellipse using an automatically chosen step count.- Parameters:
center- the ellipse center.radiusX- the horizontal radius.radiusY- the vertical radius.- Returns:
- the approximated ellipse path.
-
ellipse
Approximates an integer circle using an automatically chosen step count.- Parameters:
center- the circle center.radiusX- the radius to use on both axes.- Returns:
- the approximated circle path.
-
ellipse
Approximates an integer ellipse.- Parameters:
center- the ellipse center.radiusX- the horizontal radius.radiusY- the vertical radius.steps- the number of vertices to generate, or0to choose automatically.- Returns:
- the approximated ellipse path.
-
ellipse
Approximates a floating-point ellipse using an automatically chosen step count.- Parameters:
center- the ellipse center.radiusX- the horizontal radius.radiusY- the vertical radius.- Returns:
- the approximated ellipse path.
-
ellipse
Approximates a floating-point circle using an automatically chosen step count.- Parameters:
center- the circle center.radiusX- the radius to use on both axes.- Returns:
- the approximated circle path.
-
ellipse
Approximates a floating-point ellipse.- Parameters:
center- the ellipse center.radiusX- the horizontal radius.radiusY- the vertical radius.steps- the number of vertices to generate, or0to choose automatically.- Returns:
- the approximated ellipse path.
-