rgbToHsl
Converts an RGB(A) color into HSL(A).
h/s/l are rounded to 1 decimal place to avoid floating-point noise.
Available since next
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | RgbColor | The color to convert. r/g/b are expected in 0-255, a defaults to 1 (opaque) when omitted. |
Returns
Section titled “Returns”HslColor — The equivalent HSL(A) color: h in 0-360, s/l in 0-100
Examples
Section titled “Examples”Convert an RGB color to HSL
Section titled “Convert an RGB color to HSL”Useful for generating tints/shades by adjusting lightness.
Grayscale colors have no saturation
Section titled “Grayscale colors have no saturation”When r, g, and b are equal, the color is achromatic (s = 0).
