mixedWith method

PosColor mixedWith(
  1. PosColor other,
  2. double fraction
)

Mischt zu other hin; fraction 0 = diese Farbe, 1 = die andere.

Implementation

PosColor mixedWith(PosColor other, double fraction) {
  final t = fraction < 0 ? 0.0 : (fraction > 1 ? 1.0 : fraction);
  int misch(int a, int b) => (a + (b - a) * t).round();
  return PosColor(misch(r, other.r), misch(g, other.g), misch(b, other.b));
}