leftSubcurveAt method

Bezier leftSubcurveAt(
  1. double t
)

Returns the subcurve obtained by taking the portion of the curve to the left of parameter value t.

Implementation

Bezier leftSubcurveAt(double t) {
  if (t <= 0.0) {
    throw ArgumentError('Cannot split curve left of start point');
  }

  t = min(t, 1.0);

  final hullPoints = hullPointsAt(t);

  if (order == 2) {
    return QuadraticBezier([hullPoints[0], hullPoints[3], hullPoints[5]]);
  } else if (order == 3) {
    return CubicBezier(
        [hullPoints[0], hullPoints[4], hullPoints[7], hullPoints[9]]);
  } else {
    throw UnsupportedError('Unsupported curve order');
  }
}