getRotatedHue static method

double getRotatedHue(
  1. Hct sourceColor,
  2. List<double> hues,
  3. List<double> rotations
)

Implementation

static double getRotatedHue(
    Hct sourceColor, List<double> hues, List<double> rotations) {
  final sourceHue = sourceColor.hue;
  assert(hues.length == rotations.length);
  if (rotations.length == 1) {
    return MathUtils.sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
  }
  final size = hues.length;
  for (var i = 0; i <= (size - 2); i++) {
    final thisHue = hues[i];
    final nextHue = hues[i + 1];
    if (thisHue < sourceHue && sourceHue < nextHue) {
      return MathUtils.sanitizeDegreesDouble(sourceHue + rotations[i]);
    }
  }
  // If this statement executes, something is wrong, there should have been a rotation
  // found using the arrays.
  return sourceHue;
}