lerp3 function

List<num> lerp3 (
  1. num t,
  2. List<num> color1,
  3. List<num> color2
)

returns a Vector3 colour somewhere between c1 and c2. t is the "time" value in the range [0, 1]

Implementation

List<num> lerp3(num t, List<num> color1, List<num> color2) {
  var r1 = color1[0];
  var g1 = color1[1];
  var b1 = color1[2];

  var r2 = color2[0];
  var g2 = color2[1];
  var b2 = color2[2];

  return [
    r1 + (t * (r2 - r1)),
    g1 + (t * (g2 - g1)),
    b1 + (t * (b2 - b1)),
  ].toList();
}