lerp static method

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

Linearly interpolates between two font variations.

If the two variations have different axis tags, the interpolation switches abruptly from one to the other at t=0.5. Otherwise, the value is interpolated (see lerpDouble.

The value is not clamped to the valid values of the axis tag, but it is clamped to the valid range of font variations values in general (the range of signed 16.16 fixed point numbers).

The t argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning a (or something equivalent to a), 1.0 meaning that the interpolation has finished, returning b (or something equivalent to b), and values in between meaning that the interpolation is at the relevant point on the timeline between a and b. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves such as Curves.elasticInOut).

Values for t are usually obtained from an Animation<double>, such as an AnimationController.

Implementation

static FontVariation? lerp(FontVariation? a, FontVariation? b, double t) {
  if (a?.axis != b?.axis || (a == null && b == null)) {
    return t < 0.5 ? a : b;
  }
  return FontVariation(
    a!.axis,
    clampDouble(lerpDouble(a.value, b!.value, t)!, -32768.0, 32768.0 - 1.0/65536.0),
  );
}