Skip to content

Commit

Permalink
replace remove overlap with simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo committed Apr 11, 2017
1 parent b653341 commit f2e6c98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ when given path with holes, outline must be clockwise and holes must be counter-
`Note: destructive`


**[Remove Overlap](https://sourceforge.net/p/jsclipper/wiki/documentation/#clipperlibclippersimplifypolygons)**
**[Simplify](https://sourceforge.net/p/jsclipper/wiki/documentation/#clipperlibclippersimplifypolygons)**
```javascript
Shape = Shape.removeOverlap()
Shape = Shape.simplify(fillType: String)
```
unions all self intersecting shapes. Only works with closed shapes.
Simplifies shape using filltype. Only works for closed shapes.


**Sperate Shapes**
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Shape {
pointInPath(index: number, point: Point | PointLower, capitalConversion: boolean, integerConversion?: boolean): boolean;

fixOrientation(): this;
removeOverlap(): Shape | this;
simplify(fillType: string): Shape | this;
separateShapes(): Shape[];
round(): Shape;
removeDuplicates(): Shape;
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,13 @@ export default class Shape {
}

removeOverlap() {
console.warn(`Shape.removeOverlap is being depricated, use Shape.simplify('pftNonZero') instead`);
this.simplify('pftNonZero');
}

simplify(fillType) {
if (this.closed) {
const shape = ClipperLib.Clipper.SimplifyPolygons(this.paths, ClipperLib.PolyFillType.pftNonZero);
const shape = ClipperLib.Clipper.SimplifyPolygons(this.paths, ClipperLib.PolyFillType[fillType]);
return new Shape(shape, true);
} else {
return this;
Expand Down

0 comments on commit f2e6c98

Please sign in to comment.