adjustPoints method

Quality? adjustPoints(
  1. Point<num> mouse,
  2. bool click
)

Implementation

Quality? adjustPoints(Point mouse, bool click) {
  if (!click) return null;
  if (_points == null) return null;

  //print('--- adjustPoints ---');

  var point = _getMousePointInCanvas(mouse);

  var points = _points.value ?? [];

  var target = nearestPoint(points, point);

  if (target == null) {
    points.add(point);
  } else {
    var distance = target.distanceTo(point);

    if (distance <= 10) {
      points.remove(target);
    } else {
      points.add(point);
    }
  }

  _points.value = points;

  return Quality.high;
}