drawing method

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

绘制过程中调用(手指移动时)

Called during drawing (when finger is moving)

Implementation

@override
void drawing(Offset nowPoint) {
  // 点过滤优化:跳过距离过近的点
  if (_lastPoint != null) {
    final double distance = (nowPoint - _lastPoint!).distance;

    // 如果距离小于最小点距离,跳过此点
    if (distance < minPointDistance) {
      return;
    }
  }

  if (useBezierCurve) {
    // 添加到点列表
    points?.add(nowPoint);
  } else {
    // 添加到路径
    path.lineTo(nowPoint.dx, nowPoint.dy);
  }

  _lastPoint = nowPoint;
}