Ho do I convert HSB color to HSL?
Photoshop shows HSB color in its color picker. HSL color can be used in CSS.
I tried this JS:
function hsb2hsl(h, s, b) { return { h: h, s: s, l: b-s/2 } }
But hsb2hsl(0, 100, 50).l == 0
instead of 25
Update: Can I do that without converting HSB → RGB → HSL?
Let's picture what actually are HSB(V), HSL, and how are constructed:
Hue color value goes from
0
to360
degrees (where0
is red) for both HSB and HSL.On top of HUE are applied this linear gradient layers
HSB (also known as HSV)
HSL
Let's see how to do the SB > SL > SB having:
Conversion
To convert to non-floated
%
percent values do like:Here's a practical example:
Stephen Morley seems to have nailed it here.
Specifically:
He uses [0-360] for hue and [0-100] for the other values.