1
0
Fork 0

fix(core): Handle path.offset() for very short curves

This path.offset method used to travel 2mm along the path to find
out the direction at the start/end of paths.
That caused errors when the curve being offsetted was less then 2mm.
So now, it checks and if it's shorter will use 10% of the path length instead.

This closes #1257
This commit is contained in:
joostdecock 2021-09-04 14:45:29 +02:00
parent 27922027ec
commit 4efc780fc4

View file

@ -348,14 +348,20 @@ function pathOffset(path, distance, raise) {
.withRaise(path.raise)
.move(current)
.curve(op.cp1, op.cp2, op.to)
.shiftAlong(2)
cp1 = cp1.shiftAlong(cp1.length() > 2
? 2
: cp1.length()/10
)
} else cp1 = op.cp1
if (op.cp2.sitsRoughlyOn(op.to)) {
cp2 = new Path(path.debug)
.withRaise(path.raise)
.move(op.to)
.curve(op.cp2, op.cp1, current)
.shiftAlong(2)
cp2 = cp2.shiftAlong(cp2.length() > 2
? 2
: cp2.length()/10
)
} else cp2 = op.cp2
let b = new Bezier(
{ x: current.x, y: current.y },