maxSafeChromaForL static method

double maxSafeChromaForL(
  1. double L
)

For given lightness, returns the maximum chroma. Keeping the chroma value below this number will ensure that for any hue, the color is within the RGB gamut.

Implementation

static double maxSafeChromaForL(double L) {
  List<Line> bounds = getBounds(L);
  double min = double.infinity;

  for (Line bound in bounds) {
    double length = Geometry.distanceLineFromOrigin(bound);
    min = math.min(min, length);
  }

  return min;
}