I've noticed an issue with the latest release where a single point will result in a stroke of NaNs 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?
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 thelast
parameter is false. E.g: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: https://github.com/steveruizok/perfect-freehand/blob/8c5a9907e7df2a44c5cdf46a93678a2f7e65e104/src/index.ts#L323