pointOnCurve method

Point pointOnCurve(
  1. double t
)

Returns a point on the curve for parameter t, representing the proportional distance along the curve between its starting point at anchor0 and ending point at anchor1.

t is the distance along the curve between the anchor points, where 0 is at anchor0 and 1 is at anchor1

Implementation

Point pointOnCurve(double t) {
  final u = 1 - t;
  return Point(
    anchor0X * (u * u * u) +
        control0X * (3 * t * u * u) +
        control1X * (3 * t * t * u) +
        anchor1X * (t * t * t),
    anchor0Y * (u * u * u) +
        control0Y * (3 * t * u * u) +
        control1Y * (3 * t * t * u) +
        anchor1Y * (t * t * t),
  );
}