Skip to content

Commit 4c31710

Browse files
authored
Enhance README
Expanded the description of Clipper2-java and added usage details.
1 parent cef4ace commit 4c31710

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
[![](https://jitpack.io/v/micycle1/Clipper2-java.svg)](https://jitpack.io/#micycle1/Clipper2-java)
22

3-
43
# Clipper2-java
5-
A Java port of _[Clipper2](https://github.com/AngusJohnson/Clipper2)_, an open source freeware software library that performs line and polygon clipping, and offsetting.
4+
A Java port of _[Clipper2](https://github.com/AngusJohnson/Clipper2)_, an open source freeware library that performs robust 2D line and polygon clipping, and offsetting.
5+
6+
## What is Clipper2-java?
7+
8+
Clipper2-java is a fast planar geometry library for:
9+
10+
- **Boolean clipping** of polygons and polylines: `Intersection`, `Union`, `Difference`, `Xor`
11+
- **Offsetting / buffering** (inflate/deflate) of closed polygons and open polylines (`ClipperOffset` / `Clipper.InflatePaths`)
12+
- **Rectangle clipping** for polygons and polylines (`RectClip`, `RectClipLines`)
13+
- **Minkowski sum/difference**
14+
- Utilities: area, bounds, orientation, simplification (RDP), trimming duplicates/collinear vertices
615

716
## Usage
817

918
### Overview
1019

11-
The interface of *Clipper2-java* is identical to the original C# version.
20+
The interface of *Clipper2-java* aims to match the original C# version closely.
1221

13-
The `Clipper` class provides static methods for clipping, path-offsetting, minkowski-sums and path simplification.
14-
For more complex clipping operations (e.g. when clipping open paths or when outputs are expected to include polygons nested within holes of others), use the `Clipper64` or `ClipperD` classes directly.
22+
For simple use cases, the static methods in `clipper2.Clipper` are sufficient.
1523

16-
### Maven
17-
*Clipper2-java* is available as Maven/Gradle artifact via [Jitpack](https://jitpack.io/#micycle1/Clipper2-java).
24+
For advanced scenarios (open paths, PolyTree nesting, reusing engines), use `Clipper64` / `ClipperD` directly.
1825

19-
### Example
26+
### Coordinates & precision
2027

21-
```java
22-
Paths64 subj = new Paths64();
23-
Paths64 clip = new Paths64();
24-
subj.add(Clipper.MakePath(new int[] { 100, 50, 10, 79, 65, 2, 65, 98, 10, 21 }));
25-
clip.add(Clipper.MakePath(new int[] { 98, 63, 4, 68, 77, 8, 52, 100, 19, 12 }));
26-
Paths64 solution = Clipper.Union(subj, clip, FillRule.NonZero);
27-
solution.get(0).forEach(p -> System.out.println(p.toString()));
28-
```
28+
Clipper2’s core algorithms operate on **integer coordinates** for numerical robustness.
29+
30+
- Use **`Path64` / `Paths64`** (with `long` coordinates) for best performance and robustness.
31+
- Use **`PathD` / `PathsD`** (with `double` coordinates) for convenience. These are **scaled and rounded to integers internally** using a user-specified precision.
32+
33+
### Installation (Maven / Gradle)
2934

35+
*Clipper2-java* is available as a Maven/Gradle artifact via [Jitpack](https://jitpack.io/#micycle1/Clipper2-java).
3036

3137
## Port Info
3238
* _tangiblesoftwaresolutions_' C# to Java Converter did the heavy lifting (but then a lot of manual work was required).

0 commit comments

Comments
 (0)