mixOklab function

Color mixOklab(
  1. Color a,
  2. Color b,
  3. double t
)

Mixes a and b in OKLab at t (0 returns a, 1 returns b).

Alpha is interpolated alongside the color. OKLab keeps midpoints as saturated as the endpoints where sRGB would muddy them, which is why the derived role tokens are mixed here rather than channel-wise.

Implementation

Color mixOklab(Color a, Color b, double t) {
  final (double al, double aa, double ab) = _toOklab(a);
  final (double bl, double ba, double bb) = _toOklab(b);
  return _fromOklab(
    al + (bl - al) * t,
    aa + (ba - aa) * t,
    ab + (bb - ab) * t,
    alpha: a.a + (b.a - a.a) * t,
  );
}