subdivide static method

List<Point> subdivide(
  1. Point start,
  2. Point control1,
  3. Point control2,
  4. Point end,
  5. double t,
)

Subdivides the cubic curve described by start, control1, control2, end.

The returned list describes two cubics, where elements 0, 1, 2, 3 are the start, cp1, cp2, and end points of the first cubic and 3, 4, 5, 6 are the start, cp1, cp2, and end points of the second cubic.

Implementation

static List<Point> subdivide(
  Point start,
  Point control1,
  Point control2,
  Point end,
  double t,
) {
  final Point ab = Point.lerp(start, control1, t);
  final Point bc = Point.lerp(control1, control2, t);
  final Point cd = Point.lerp(control2, end, t);
  final Point abc = Point.lerp(ab, bc, t);
  final Point bcd = Point.lerp(bc, cd, t);
  final Point abcd = Point.lerp(abc, bcd, t);
  return <Point>[
    start,
    ab,
    abc,
    abcd,
    bcd,
    cd,
    end,
  ];
}