Open ercgeek opened 2 years ago
An additional change is needed in lib\src\get_stroke_outline_points.dart
// Original code
// if (thinning != 0) {
// if (simulatePressure) {
// sp = min(1, curr.distance / size);
// rp = min(1, 1 - sp);
// pressure = min(
// 1,
// prevPressure + (rp - prevPressure) * (sp * rateOfPressureChange),
// );
// radius = getStrokeRadius(
// size,
// thinning,
// pressure,
// );
// } else {
// radius = size / 2;
// }
// }
// New code
if (thinning != 0) {
if (simulatePressure) {
sp = min(1, curr.distance / size);
rp = min(1, 1 - sp);
pressure = min(
1,
prevPressure + (rp - prevPressure) * (sp * rateOfPressureChange),
);
}
radius = getStrokeRadius(
size,
thinning,
pressure,
);
}
First big thanks for publishing this.
Using the library to render strokes passing on iPad stylus pressure, the stroke is incorrectly rendered with a constant pressure, whatever is passed on points[0].
I think I found the issue on the use of lrp() to smooth out the points. Seems lrp() returns the pressure of the first point and not the interpolation of the pressures from both points.
Changed lib\src\get_stroke_points.dart as follows and seems to corrects the issue. Using the pressure from the second point, not an interpolated value.
I'm not a dart expert, please let me know if I'm missing something here.