drawing method

  1. @override
void drawing(
  1. Offset nowPoint
)
override

正在绘制

Implementation

@override
void drawing(Offset nowPoint) {
  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);
}