toHSL method

HSLColor toHSL()

Implementation

HSLColor toHSL() {
  final double v = value;
  final double s = saturation;
  final double h = hue;
  final double a = alpha;
  final double l = v * (1 - s / 2);
  double newH;
  double newS;
  if (l == 0 || l == 1) {
    newH = 0;
    newS = 0;
  } else {
    newS = (v - l) / min(l, 1 - l);
    newH = h;
  }
  return HSLColor.fromAHSL(a, newH, newS, l);
}