lerp static method

List<AnyPoint>? lerp(
  1. List<AnyPoint>? a,
  2. List<AnyPoint>? b,
  3. double t
)

Linearly interpolates two point lists for AnyDecorationTween.

If the lists have different lengths, one list is picked based on t because point-by-point interpolation is not possible.

Implementation

static List<AnyPoint>? lerp(List<AnyPoint>? a, List<AnyPoint>? b, double t) {
  if (a == null || b == null) return null;
  if (identical(a, b)) return a;
  if (a.length != b.length) return AnyUtils.pickLerp(a, b, t);

  AnyCorner? lerpInner(AnyCorner? a, AnyCorner? b) {
    if (a == null && b == null) return null;
    if (a == null || b == null) return AnyUtils.pickLerpNullable(a, b, t);
    return AnyCorner.lerp(a, b, t);
  }

  return List<AnyPoint>.generate(a.length, (index) {
    final pa = a[index];
    final pb = b[index];

    return AnyPoint(
      point: Offset.lerp(pa.point, pb.point, t)!,
      outer: AnyCorner.lerp(pa.outer, pb.outer, t),
      inner: lerpInner(pa.inner, pb.inner),
      side: AnySide.lerp(pa.side, pb.side, t),
      skip: AnyUtils.pickLerp(pa.skip, pb.skip, t),
    );
  }, growable: false);
}