linearGradient function
returns an length n
array of Vector3 colours. colours are evenly spaced between color1
and color2
.
Implementation
List<List<num>> linearGradient(
num n,
List<num> color1,
List<num> color2,
) {
var d = (n - 1 != 0) ? n - 1 : 1;
var result = List.generate(n, (i) => lerp3(i / d, color1, color2)).toList();
return result;
}