Skip to content

Commit e2c1a4d

Browse files
committed
revert to v1.0.4
1 parent 65c4713 commit e2c1a4d

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Vector based fill tool (like floodfill) build with [Clipper](https://www.npmjs.c
77
Include `fillPath` in your project. `fillPath` accepts two arguments, `paths` and `point`.
88

99
```javascript
10-
fillPath( Paths, Point, [ { LineWidth = 1.0, Precision = 0.1, MiterLimit = 2.0, FillOffset = 'center' } ] );
10+
fillPath( Paths, Point, [ { LineWidth = 1.0, Scale = 10.0, MiterLimit = 2.0, FillOffset = 'center' } ] );
1111

1212
Paths = [...[...Point];
1313
Point = { x: Number, y: Number };
1414

1515
LineWidth = Float;
16-
Precision = Float;
16+
Scale = Float;
1717
MiterLimit = Float;
1818
FillOffset = String;
1919
```

package.json

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fill-path",
3-
"version": "1.1.1",
3+
"version": "1.0.4",
44
"description": "Vector based fill tool (like floodfill)",
55
"main": "lib/index.js",
66
"scripts": {

preview.gif

100644100755
File mode changed.

src/index.js

100644100755
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ const OUTSIDE = 'outside';
66

77
export default function(paths, point, {
88
lineWidth = 1.0,
9-
precision = 0.1,
10-
miterLimit = 5.0,
9+
scale = 10.0,
10+
miterLimit = 2.0,
1111
fillOffset = CENTER
1212
} = {}) {
1313
// calculate linewith
14-
lineWidth /= precision * 2.0;
14+
lineWidth *= scale / 2.0;
1515
// convert point to uppercase
16-
point = { X: point.x / precision, Y: point.y / precision };
16+
point = { X: point.x * scale, Y: point.y * scale };
1717

1818
// create clipper shape
1919
const shape = new Shape(paths, false, true, true, true)
2020
// scale up for precision
21-
.scaleDown(precision)
21+
.scaleUp(scale)
2222
// convert lines to polygons (this gives lines width)
23-
.offset(2.0, { jointType: 'jtMiter', endType: 'etOpenSquare', miterLimit: 1.0 })
23+
.offset(lineWidth, { jointType: 'jtMiter', endType: 'etOpenSquare', miterLimit })
2424
// union all overlapping paths
2525
.removeOverlap()
2626
// make all holes outlines and all outlines holes
2727
.reverse()
2828
// seperate all shapes into (these all all plausible fills)
2929
.seperateShapes()
3030
// find shape with hit
31-
.find(shape => shape.pointInShape(point));
31+
.find(fill => fill.pointInShape(point));
3232

3333
// if no fill has been found return empty shape
3434
if (!shape) return [];
@@ -37,24 +37,24 @@ export default function(paths, point, {
3737
let offset;
3838
switch (fillOffset) {
3939
case CENTER:
40-
offset = 2.0;
40+
offset = lineWidth;
4141
break;
4242
case INSIDE:
43-
offset = 2.0 - lineWidth;
43+
offset = 0;
4444
break;
4545
case OUTSIDE:
46-
offset = 2.0 + lineWidth;
46+
offset = lineWidth * 2.0;
4747
break;
4848
default:
49-
offset = 2.0;
49+
offset = lineWidth;
5050
break;
5151
}
5252

5353
return shape
5454
// offset result to account for converting to polygon
5555
.offset(offset, { jointType: 'jtMiter', endType: 'etClosedPolygon', miterLimit })
5656
// scale down to accout for scale up
57-
.scaleUp(precision)
57+
.scaleDown(scale)
5858
// convert uppercase points to lowercase points
5959
.mapToLower();
6060
}

0 commit comments

Comments
 (0)