mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
13 lines
344 B
JavaScript
13 lines
344 B
JavaScript
export default ({ space, values }) => {
|
|
if (space === "rgb") {
|
|
return values;
|
|
}
|
|
const [hue, saturation, lightness] = values;
|
|
const a = saturation * Math.min(lightness, 1 - lightness);
|
|
const f = (n) => {
|
|
const k = (n + hue * 12) % 12;
|
|
return lightness - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
|
|
};
|
|
return [f(0), f(8), f(4)];
|
|
};
|