Update HSLToRGB.md

This commit is contained in:
Angelos Chalaris
2020-10-04 11:24:27 +03:00
committed by GitHub
parent 70fc77a65d
commit 06ca974715

View File

@ -13,13 +13,14 @@ Converts a HSL color tuple to RGB format.
const HSLToRGB = (h, s, l) => { const HSLToRGB = (h, s, l) => {
s /= 100; s /= 100;
l /= 100; l /= 100;
const k = (n) => (n + h / 30) % 12; const k = n => (n + h / 30) % 12;
const a = s * Math.min(l, 1 - l); const a = s * Math.min(l, 1 - l);
const f = (n) => l - a*Math.max(-1, Math.min(k(n)-3, Math.min(9-k(n), 1))); const f = n =>
l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
return [255 * f(0), 255 * f(8), 255 * f(4)]; return [255 * f(0), 255 * f(8), 255 * f(4)];
}; };
``` ```
```js ```js
HSLToRGB(13, 100, 11); // [56.1, 12.155000000000006, 0] HSLToRGB(13, 100, 11); // [56.1, 12.155, 0]
``` ```