getPiecewiseValue static method

double getPiecewiseValue(
  1. Hct sourceColorHct,
  2. List<double> hueBreakpoints,
  3. List<double> hues
)

Implementation

static double getPiecewiseValue(
  Hct sourceColorHct,
  List<double> hueBreakpoints,
  List<double> hues,
) {
  final size = math.min(hueBreakpoints.length - 1, hues.length);
  final sourceHue = sourceColorHct.hue;
  for (var i = 0; i < size; i++) {
    if (sourceHue >= hueBreakpoints[i] && sourceHue < hueBreakpoints[i + 1]) {
      return MathUtils.sanitizeDegreesDouble(hues[i]);
    }
  }
  // No condition matched, return the source value.
  return sourceHue;
}