lerp static method

CornerSpec? lerp(
  1. CornerSpec? a,
  2. CornerSpec? b,
  3. double t
)

Linearly interpolate between two CornerSpec objects.

If either is null, defaults to CornerSpec.ROUNDED. (If both are null, this returns null.)

The radius is acquired by BorderRadiusGeometry.lerp.

For now, the four CornerSpec corners swap values from a to b according to an arbitrary keyframe along t.

  • TL: t < 0.5 returned Corners are from a, otherwise from b
  • TR: t < 0.65 returned Corners are from a, otherwise from b
  • BR: t < 0.8 returned Corners are from a, otherwise from b
  • BL: t < 0.95 returned Corners are from a, otherwise from b

TODO: Find help.

Implementation

static CornerSpec? lerp(CornerSpec? a, CornerSpec? b, double t) {
  if (a == null && b == null) return null;
  a ??= CornerSpec.ROUNDED;
  b ??= CornerSpec.ROUNDED;
  return CornerSpec(
    topLeft: t < 0.5 ? a.topLeft : b.topLeft,
    topRight: t < 0.65 ? a.topRight : b.topRight,
    bottomRight: t < 0.8 ? a.bottomRight : b.bottomRight,
    bottomLeft: t < 0.95 ? a.bottomLeft : b.bottomLeft,
    radius: BorderRadiusGeometry.lerp(a.radius, b.radius, t),
  );
}