gradient function

List<List<num>> gradient (
  1. Function ease,
  2. int n,
  3. List<num> color1,
  4. List<num> color2
)

returns an length n array of Vector3 colours. colours are between color1 and color2, and are spaced according to the easing function easeFn.

Implementation

List<List<num>> gradient(
    Function ease, int n, List<num> color1, List<num> color2) {
  var d = (n - 1 != 0) ? n - 1 : 1;
  var result =
      List.generate(n, (i) => lerp3(ease(i / d), color1, color2)).toList();
  return result;
}