multiGradient function
returns a length n
array of Vector3 colours. colours are the ones formed from the linearGradient(n/(numColours-1), color1, color2)
for all colours color1, color2, ..., colorN
Implementation
List<List<num>> multiGradient(num n, List<List<num>> colors) {
var i = -1;
return colors.fold([], (grad, color) {
i = i + 1;
if (i == 0) {
return grad;
}
var color1 = colors[i - 1];
var color2 = color;
var values = (n / (colors.length - 1)).round();
if (i == colors.length - 1 || i == 1) {
values = (n / (colors.length - 1)).ceil();
}
return [...grad, ...linearGradient(values, color1, color2)];
});
}