Returns the CSS3 HSL representation, e.g. hsl(120, 100%, 50%)
552638
public String toHsl() {
        float[] HSL = convertToHsl();
        return "hsl(" + Math.round(HSL[0]) + "," + Math.round(HSL[1]) + "%," + Math.round(HSL[2]) + "%)";
    }
1183191
private RgbaColor withHsl(int index, float value) {
        float[] HSL = convertToHsl();
        HSL[index] = value;
        return RgbaColor.fromHsl(HSL);
    }
773147
public function hsl2rgb($h, $s, $l)
	{
		if ($s == 0) {
			$r = $l * 255;
			$g = $l * 255;
			$b = $l * 255;
		} else {
			if ($l < 0.5) {
				$tmp = $l * (1 + $s);
			} else {
				$tmp = ($l + $s) - ($s * $l);
			}
			$tmp2 = 2 * $l - $tmp;
			$r = round(255 * $this->hue2rgb($tmp2, $tmp, $h + (1 / 3)));
			$g = round(255 * $this->hue2rgb($tmp2, $tmp, $h));
			$b = round(255 * $this->hue2rgb($tmp2, $tmp, $h - (1 / 3)));
		}

		return [$r, $g, $b];
	}
103022
def hsl_to_rgb(h, s, l)
      h %= 201
      s %= 101
      l %= 101
      if l <= 49
        color_max = 255.0 * (l + l * (s / 100.0)) / 100.0
        color_min = 255.0 * (l - l * (s / 100.0)) / 100.0
      else
        color_max = 255.0 * (l + (100 - l) * (s / 100.0)) / 100.0
        color_min = 255.0 * (l - (100 - l) * (s / 100.0)) / 100.0
      end

      if h < HUE_PER_6
        base = h
      elsif h < HUE_PER_6 * 3
        base = (h - HUE_PER_6 * 2).abs
      elsif h < HUE_PER_6 * 5
        base = (h - HUE_PER_6 * 4).abs
      else
        base = (200 - h)
      end
      base = base / HUE_PER_6 * (color_max - color_min) + color_min

      divide = (h / HUE_PER_6).to_i
      red, green, blue = (case divide
                          when 0 then  [color_max, base, color_min]
                          when 1 then  [base, color_max, color_min]
                          when 2 then  [color_min, color_max, base]
                          when 3 then  [color_min, base, color_max]
                          when 4 then  [base, color_min, color_max]
                          else         [color_max, color_min, base]
                          end)

      [red.round, green.round, blue.round]
    end
615838
function(bytes) {
            bytes = bytes || 2;

            var max = Math.pow(16, bytes) - 1;
            var css = [
                "#",
                pad(Math.round(this.red * max).toString(16).toUpperCase(), bytes),
                pad(Math.round(this.green * max).toString(16).toUpperCase(), bytes),
                pad(Math.round(this.blue * max).toString(16).toUpperCase(), bytes)
            ];

            return css.join('');
        }
469964
def rgb_to_hsl_hsv(a, isHSV=True):
    
    R, G, B = a.T

    m = np.min(a, 1).T
    M = np.max(a, 1).T

    C = M - m #chroma
    Cmsk = C != 0

    # Hue
    H = np.zeros(R.shape, int)
    mask = (M == R) & Cmsk
    H[mask] = np.mod(60 * (G[mask] - B[mask]) / C[mask], 360)
    mask = (M == G) & Cmsk
    H[mask] = (60 * (B[mask] - R[mask]) / C[mask] + 120)
    mask = (M == B) & Cmsk
    H[mask] = (60 * (R[mask] - G[mask]) / C[mask] + 240)
    H *= 255
    H /= 360 # if you prefer, leave as 0-360, but don't convert to uint8


    # Saturation
    S = np.zeros(R.shape, int)

    if isHSV:
        # This code is for HSV:
        # Value
        V = M

        # Saturation
        S[Cmsk] = ((255 * C[Cmsk]) / V[Cmsk])
        # H, S, and V are now defined as integers 0-255
        return np.array((H.swapaxes(0, 1), S.swapaxes(0, 1), V.swapaxes(0, 1))).T
    else:
        # This code is for HSL:
        # Value
        L = 0.5 * (M + m)

        # Saturation
        S[Cmsk] = ((C[Cmsk]) / (1 - np.absolute(2 * L[Cmsk]/255.0 - 1)))
        # H, S, and L are now defined as integers 0-255
        return np.array((H.swapaxes(0, 1), S.swapaxes(0, 1), L.swapaxes(0, 1))).T
1184114
def hsla_to_rgba(h, s, l, a):
    
    h = h % 360
    s = max(0, min(1, s))
    l = max(0, min(1, l))
    a = max(0, min(1, a))

    c = (1 - abs(2*l - 1)) * s
    x = c * (1 - abs(h/60%2 - 1))
    m = l - c/2

    if h<60:
        r, g, b = c, x, 0
    elif h<120:
        r, g, b = x, c, 0
    elif h<180:
        r, g, b = 0, c, x
    elif h<240:
        r, g, b = 0, x, c
    elif h<300:
        r, g, b = x, 0, c
    else:
        r, g, b = c, 0, x


    return (int((r+m)*255), int((g+m)*255), int((b+m)*255), int(a*255))
480291
static HSL toHSL( double color ) {
        long argb = Double.doubleToRawLongBits( color );
        double a = alpha( color );
        double r = clamp( ((argb >> 32) & 0xFFFF) / (double)0xFF00 );
        double g = clamp( ((argb >> 16) & 0xFFFF) / (double)0xFF00 );
        double b = clamp( ((argb >> 0) & 0xFFFF) / (double)0xFF00 );

        double max = Math.max( Math.max( r, g ), b );
        double min = Math.min( Math.min( r, g ), b );
        double h, s, l = (max + min) / 2, d = max - min;

        if( max == min ) {
            h = s = 0;
        } else {
            s = l > 0.5 ? d / (2 - max - min) : d / (max + min);

            if( max == r ) {
                h = (g - b) / d + (g < b ? 6 : 0);
            } else if( max == g ) {
                h = (b - r) / d + 2;
            } else {
                h = (r - g) / d + 4;
            }
            h /= 6;
        }
        return new HSL( h * 360, s, l, a );
    }
406798
function gli_color_to_css(color) {
    var res = (color & 0xFFFFFF).toString(16);
    while (res.length < 6) {
        res = '0' + res;
    }
    return '#' + res.toUpperCase();
}
1052994
function RGBA_TO_HSLA() {
        var r = this.r() / 255;
        var g = this.g() / 255;
        var b = this.b() / 255;
        var a = this.a();
        var max = Math.max(r, g, b);
        var min = Math.min(r, g, b);
        var diff = max - min;
        var sum = max + min;
        var h;
        var s;
        var l;

        if (max === min) {
            h = 0;
        } else if (max === r && g >= b) {
            h = 60 * (g - b) / diff + 0;
        } else if (max === r && g < b) {
            h = 60 * (g - b) / diff + 360;
        } else if (max === g) {
            h = 60 * (b - r) / diff + 120;
        } else { // max === b
            h = 60 * (r - g) / diff + 240;
        }

        l = sum / 2;

        if (l === 0 || max === min) {
            s = 0;
        } else if (0 < l && l <= 0.5) {
            s = diff / sum;
        } else { // l > 0.5
            s = diff / (2 - sum);
        }

        return kolor.hsla(h, s, l, a);
    }
744229
def _saturation(color, **kwargs):
    
    s = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[2]
    return NumberValue((s * 100, '%'))
1189304
function (hue, saturation, value, alpha) {
      alpha = /%/.test(alpha)
        ? parseInt(alpha, 10) / 100
        : parseFloat(alpha, 10);

      alpha = String(alpha).replace(/^0+\./, '.');

      var rgb = hsb2rgb(hue, saturation, value);
      return 'rgba(' + rgb.join(', ') + ', ' + alpha + ')';
    }
241254
def _lightness(color, **kwargs):
    
    l = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[1]
    return NumberValue((l * 100, '%'))
413062
public static final Color fromNormalizedHSL(final double h, final double s, final double l)
    {
        // see http://www.w3.org/TR/css3-color/
        //
        // HOW TO RETURN hsl.to.rgb(h, s, l):
        // SELECT:
        // l<=0.5: PUT l*(s+1) IN m2
        // ELSE: PUT l+s-l*s IN m2
        // PUT l*2-m2 IN m1
        // PUT hue.to.rgb(m1, m2, h+1/3) IN r
        // PUT hue.to.rgb(m1, m2, h ) IN g
        // PUT hue.to.rgb(m1, m2, h-1/3) IN b
        // RETURN (r, g, b)

        final double m2 = (l <= 0.5) ? (l * (s + 1)) : ((l + s) - (l * s));

        final double m1 = (l * 2) - m2;

        return new Color(fixRGB((int) Math.round(255 * hueToRGB(m1, m2, h + (1.0 / 3)))), fixRGB((int) Math.round(255 * hueToRGB(m1, m2, h))), fixRGB((int) Math.round(255 * hueToRGB(m1, m2, h - (1.0 / 3)))));
    }
395150
def css(self):
        
        css_list = [DEFAULT_MARK_CSS]
        for aes in self.aesthetics:
            css_list.extend(get_mark_css(aes, self.values[aes]))
        #print('\n'.join(css_list))
        return '\n'.join(css_list)
317039
function(color, amount) {
    var hsl = this.toHSL(color);

    hsl.l += amount / 100;
    hsl.l = clamp(hsl.l);
    return hsla(hsl);
  }
1034139
function rgb2hsl() {
    const
        R = this.R,
        G = this.G,
        B = this.B,
        min = Math.min( R, G, B ),
        max = Math.max( R, G, B ),
        delta = max - min;

    this.L = 0.5 * ( max + min );

    if ( delta < 0.000001 ) {
        this.H = 0;
        this.S = 0;
    } else {
        this.S = delta / ( 1 - Math.abs( ( 2 * this.L ) - 1 ) );
        if ( max === R ) {
            if ( G >= B ) {
                this.H = INV6 * ( ( G - B ) / delta );
            } else {
                this.H = 1 - ( INV6 * ( ( B - G ) / delta ) );
            }
        } else if ( max === G ) {
            this.H = INV6 * ( 2 + ( ( B - R ) / delta ) );
        } else {
            this.H = INV6 * ( 4 + ( ( R - G ) / delta ) );
        }
    }
}