addSmoothCurveTo method

void addSmoothCurveTo(
  1. Vector3 anchorOrHandle, [
  2. Vector3? maybeAnchor
])

Implementation

void addSmoothCurveTo(Vector3 anchorOrHandle, [Vector3? maybeAnchor]) {
  var handle2 = maybeAnchor == null ? null : anchorOrHandle;
  var anchor = maybeAnchor ?? anchorOrHandle;

  if (hasNewPathStarted()) {
    addLineTo(anchor);
  } else {
    throwErrorIfNoPoints('addSmoothCurveTo');
    var lastH2 = points[points.length - 2];
    var lastA2 = points[points.length - 1];
    var lastTangent = lastA2 - lastH2;
    var handle1 = lastA2 + lastTangent;

    if (handle2 == null) {
      var toAnchorVec = anchor - lastA2;
      var tangent = lastTangent.rotate(PI, axis: toAnchorVec);
      handle2 = anchor - tangent;
    }

    appendPoints([lastH2, handle1, handle2, anchor]);
  }
}