add method

void add(
  1. Offset point
)

Alters path with given point.

Implementation

void add(Offset point) {
  assert(_origin != null);

  final nextPoint = point is OffsetPoint ? point : OffsetPoint.from(point);

  if (_lastPoint == null || _lastPoint!.distanceTo(nextPoint) < threshold) {
    return;
  }

  _points.add(nextPoint);
  int count = _points.length;

  if (count < 3) {
    return;
  }

  int i = count - 3;

  final prev = i > 0 ? _points[i - 1] : _points[i];
  final start = _points[i];
  final end = _points[i + 1];
  final next = _points[i + 2];

  final cpStart = CubicLine.softCP(
    start,
    previous: prev,
    next: end,
    smoothing: smoothRatio,
  );

  final cpEnd = CubicLine.softCP(
    end,
    previous: start,
    next: next,
    smoothing: smoothRatio,
    reverse: true,
  );

  final line = CubicLine(
    start: start,
    cpStart: cpStart,
    cpEnd: cpEnd,
    end: end,
  );

  _addLine(line);
}