Skip to content Skip to sidebar Skip to footer

Hex To Hsl Convert Javascript

Hello I'm trying to create HEX to HSL converter function. I know that at first I should convert HEX to RGB and then from RGB to HSL. I've done so using some script from StackOverfl

Solution 1:

You forgot to multiply the hue by 360.

s = s*100;
s = Math.round(s);
l = l*100;
l = Math.round(l);
h = Math.round(360*h);

var colorInHSL = 'hsl(' + h + ', ' + s + '%, ' + l + '%)';

Post a Comment for "Hex To Hsl Convert Javascript"