mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-17 05:49:30 -07:00
Matrix React component 1.0.0
This commit is contained in:
12
js/utils/colorToRGB.js
Normal file
12
js/utils/colorToRGB.js
Normal file
@@ -0,0 +1,12 @@
|
||||
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)];
|
||||
};
|
||||
Reference in New Issue
Block a user