getStroke cannot handle a single input point if there's no tapering or it's the last point
glenn-allen opened this issue · 2 comments
Firstly, thanks for the amazing library Steve!
I've noticed an issue with the latest release where a single point will result in a stroke of NaN
s if either the taper is 0 or the last
parameter is false. E.g:
const stroke = getStroke([ [1, 1, 0] ], {
size: 1,
thinning: 0.6,
smoothing: 0.5,
streamline: 0.5,
start: {
taper: 0,
},
end: {
taper: 0,
},
simulatePressure: true,
last: false,
});
// [ [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ], [ NaN, NaN ]]
This means that single clicks don't create a stroke.
I've tested this in the example app and while it works in your hosted version it doesn't seem to work locally, so I assume the hosted version is on a previous library version?
As far as I can gather it's due to the following line - I guess it's trying to take a unit vector of a point with 0 length, but I'm not really sure what the fix should be:
Line 323 in 8c5a990
Hey, looked at this today. Should be fixed on 0.4.10
!
Working perfectly, thanks Steve!