SixLabors.PolygonClipper
1.0.0
Prefix Reserved
dotnet add package SixLabors.PolygonClipper --version 1.0.0
NuGet\Install-Package SixLabors.PolygonClipper -Version 1.0.0
<PackageReference Include="SixLabors.PolygonClipper" Version="1.0.0" />
<PackageVersion Include="SixLabors.PolygonClipper" Version="1.0.0" />
<PackageReference Include="SixLabors.PolygonClipper" />
paket add SixLabors.PolygonClipper --version 1.0.0
#r "nuget: SixLabors.PolygonClipper, 1.0.0"
#:package SixLabors.PolygonClipper@1.0.0
#addin nuget:?package=SixLabors.PolygonClipper&version=1.0.0
#tool nuget:?package=SixLabors.PolygonClipper&version=1.0.0
![]()
SixLabors.PolygonClipper
SixLabors.PolygonClipper provides high-performance polygon clipping and stroking in C#.
Boolean operations (union, intersection, difference, xor) are implemented with a Martínez-Rueda sweep-line pipeline for complex polygons with holes and multiple contours.
Contour normalization is handled by a dedicated Vatti/Clipper2-inspired pipeline (PolygonClipper.Normalize) that resolves self-intersections/overlaps into positive-winding output.
PolygonStroker can optionally run that normalization pass on emitted stroke geometry.
Features
- Works with non-convex polygons, including holes and multiple disjoint regions
- Handles edge cases like overlapping edges and vertical segments
- Preserves topology: output polygons include hole/contour hierarchy
- Deterministic and robust sweep line algorithm with O((n + k) log n) complexity
- Includes
PolygonClipper.Normalize(Clipper2-inspired) for positive-winding contour normalization - Includes
PolygonStrokerfor configurable geometric stroking (joins, caps, miter limits) - Uses double precision geometry without coordinate quantization
Usage
The API centers around Polygon and Contour types. Construct input polygons using contours, then apply Boolean operations via PolygonClipper:
Polygon result = PolygonClipper.Union(subject, clipping);
Boolean operations can process self-intersecting inputs directly. Use normalization when you want canonical positive-winding contours (for example, before export or rendering pipelines that rely on winding semantics):
Polygon clean = PolygonClipper.Normalize(input);
Normalize uses a fixed positive-winding normalization path.
Stroking
Use PolygonStroker to generate filled stroke polygons from input contours:
Polygon stroked = PolygonStroker.Stroke(input, width: 12);
Configure join/cap behavior through StrokeOptions:
StrokeOptions options = new()
{
LineJoin = LineJoin.Round,
LineCap = LineCap.Round,
MiterLimit = 4,
ArcDetailScale = 1
};
Polygon stroked = PolygonStroker.Stroke(input, width: 12, options);
Algorithm References
This project draws on the following algorithm and implementation references:
- Martínez et al., "A simple algorithm for Boolean operations on polygons", Advances in Engineering Software, 64 (2013), pp. 11-19.
https://doi.org/10.1016/j.advengsoft.2013.04.004
- Vatti, "A generic solution to polygon clipping", Communications of the ACM, 35(7), 1992, pp. 56-63.
https://dl.acm.org/doi/pdf/10.1145/129902.129906
21re, rust-geo-booleanop (Rust Martínez-Rueda implementation reference).
https://github.com/21re/rust-geo-booleanop
Angus Johnson, Clipper2 polygon clipping library (reference implementation for the normalization pipeline).
https://github.com/AngusJohnson/Clipper2
License
Six Labors Split License. See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SixLabors.PolygonClipper:
| Package | Downloads |
|---|---|
|
SixLabors.ImageSharp.Drawing
Drawing extensions for ImageSharp with support for shapes, paths, text, and image rendering. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on SixLabors.PolygonClipper:
| Repository | Stars |
|---|---|
|
SixLabors/ImageSharp.Drawing
:pen: Extensions to ImageSharp containing a cross-platform 2D polygon manipulation API and drawing operations.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 0 | 5/12/2026 |