showing results for - "convert hsl to hex code javascript"
Paris
05 Feb 2018
1function hslToHex(h, s, l) {
2  l /= 100;
3  const a = s * Math.min(l, 1 - l) / 100;
4  const f = n => {
5    const k = (n + h / 30) % 12;
6    const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
7    return Math.round(255 * color).toString(16).padStart(2, '0');   // convert to Hex and prefix "0" if needed
8  };
9  return `#${f(0)}${f(8)}${f(4)}`;
10}
11