drawing method
正在绘制
Implementation
@override
void drawing(Offset nowPoint) {
// 点过滤优化:跳过距离过近的点
if (points.isNotEmpty) {
final double distance = (nowPoint - points.last).distance;
// 如果距离小于最小点距离,跳过此点
if (distance < minPointDistance) {
return;
}
}
final double distance = (nowPoint - points.last).distance;
//原始画笔线条线宽
final double s = paint.strokeWidth;
double strokeWidth = s * (s * 2 / (s * distance));
if (strokeWidth > s * 2) {
strokeWidth = s * 2;
}
//上一个线宽
final double preWidth = strokeWidthList.last;
if (strokeWidth - preWidth > brushPrecision) {
strokeWidth = preWidth + brushPrecision;
} else if (preWidth - strokeWidth > brushPrecision) {
strokeWidth = preWidth - brushPrecision;
}
//记录点位
points.add(nowPoint);
strokeWidthList.add(strokeWidth);
}