You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When applying offsetStroke to Paths consisting of only straight lines it will occasionally produce end caps on the outlined shape that are "inverted". In the example below, the black line is the input Path and the red fill is the outlined shape produced from the parameters PaperOffset.offsetStroke(st1, 5, { cap: 'round' })...
The root cause of the issue appears to be the reliance on the clockwise attribute of the input Path, which in turn relies on the area to determine the direction of the Path. The area of Path containing only a straight line should, by definition, always be zero, but floating point math makes this fact unreliable. In turn, this makes this clockwise attribute unreliable and calling reverse() on this Path will likely produce a new Path with the same direction as the original. The end result is a Path that is counter-clockwise and un-reverse()able, which seems to mess with some of the logic in paperjs-offset that assumes calling reverse() on a counter-clockwise Path will always produce a clockwise Path. The Path in the example above has an area of -1.7763568394002505e-14.
My (incomplete) workaround is to outline straight lines manually with a much more simplistic algorithm that does not rely on on the path direction. Also currently assumes round caps (though could probably be generalized to support other caps) and does not need to support joins because the lines are assumed to be straight...
When applying
offsetStroke
to Paths consisting of only straight lines it will occasionally produce end caps on the outlined shape that are "inverted". In the example below, the black line is the input Path and the red fill is the outlined shape produced from the parametersPaperOffset.offsetStroke(st1, 5, { cap: 'round' })
...The root cause of the issue appears to be the reliance on the
clockwise
attribute of the input Path, which in turn relies on the area to determine the direction of the Path. The area of Path containing only a straight line should, by definition, always be zero, but floating point math makes this fact unreliable. In turn, this makes thisclockwise
attribute unreliable and callingreverse()
on this Path will likely produce a new Path with the same direction as the original. The end result is a Path that is counter-clockwise and un-reverse()
able, which seems to mess with some of the logic in paperjs-offset that assumes callingreverse()
on a counter-clockwise Path will always produce a clockwise Path. The Path in the example above has an area of-1.7763568394002505e-14
.My (incomplete) workaround is to outline straight lines manually with a much more simplistic algorithm that does not rely on on the path direction. Also currently assumes
round
caps (though could probably be generalized to support other caps) and does not need to support joins because the lines are assumed to be straight...Example used to produce the screenshot...
The text was updated successfully, but these errors were encountered: