💄 Add hue preview circle to Aura Glow preferences

This commit is contained in:
lstrsrt
2025-03-20 14:58:14 +01:00
parent 18d22e1b11
commit f4fbe3b64f
3 changed files with 75 additions and 2 deletions
+39
View File
@@ -195,3 +195,42 @@ export function parseColor(string) {
return [color.red / 255, color.green / 255, color.blue / 255, color.alpha / 255];
}
// Converts a color in hsv space into rgb.
// https://stackoverflow.com/a/17243070
export function hsvToRgb(h, s, v) {
var r, g, b, i, f, p, q, t;
if (arguments.length === 1) {
(s = h.s), (v = h.v), (h = h.h);
}
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0:
(r = v), (g = t), (b = p);
break;
case 1:
(r = q), (g = v), (b = p);
break;
case 2:
(r = p), (g = v), (b = t);
break;
case 3:
(r = p), (g = q), (b = v);
break;
case 4:
(r = t), (g = p), (b = v);
break;
case 5:
(r = v), (g = p), (b = q);
break;
}
return {
r,
g,
b,
};
}