getColorAtValue static method

Color getColorAtValue(
  1. List<Color> colors,
  2. List<double> stops,
  3. double value
)

Implementation

static Color getColorAtValue(
    List<Color> colors, List<double> stops, double value) {
  for (int i = 0; i < stops.length - 1; i++) {
    if (value <= stops[i + 1]) {
      // Interpolate between the two colors
      return Color.lerp(colors[i], colors[i + 1],
          (value - stops[i]) / (stops[i + 1] - stops[i]))!;
    }
  }
  return colors.last;
}