asCubics method

List<Cubic> asCubics(
  1. double progress
)

Implementation

List<Cubic> asCubics(double progress) {
  final result = <Cubic>[];

  // The first/last mechanism here ensures that the final anchor point in the shape
  // exactly matches the first anchor point. There can be rendering artifacts introduced
  // by those points being slightly off, even by much less than a pixel
  Cubic? firstCubic;
  Cubic? lastCubic;
  for (var i = 0; i < morphMatch.length; i++) {
    final cubic = Cubic.interpolate(
      morphMatch[i].$1,
      morphMatch[i].$2,
      progress,
    );
    firstCubic ??= cubic;
    if (lastCubic != null) result.add(lastCubic);
    lastCubic = cubic;
  }
  if (lastCubic != null && firstCubic != null) {
    result.add(
      .from(
        lastCubic.anchor0X,
        lastCubic.anchor0Y,
        lastCubic.control0X,
        lastCubic.control0Y,
        lastCubic.control1X,
        lastCubic.control1Y,
        firstCubic.anchor0X,
        firstCubic.anchor0Y,
      ),
    );
  }

  return result;
}