MCPcopy Create free account
hub / github.com/Prejudice-Studio/Twilight / hueToRgb

Function hueToRgb

webui/src/lib/theme-custom.ts:53–61  ·  view source on GitHub ↗
(t: number)

Source from the content-addressed store, hash-verified

51 const sat = clamp(s, 0, 100) / 100;
52 const light = clamp(l, 0, 100) / 100;
53 const q = light < 0.5 ? light * (1 + sat) : light + sat - light * sat;
54 const p = 2 * light - q;
55 const hueToRgb = (t: number) => {
56 let next = t;
57 if (next < 0) next += 1;
58 if (next > 1) next -= 1;
59 if (next < 1 / 6) return p + (q - p) * 6 * next;
60 if (next < 1 / 2) return q;
61 if (next < 2 / 3) return p + (q - p) * (2 / 3 - next) * 6;
62 return p;
63 };
64 const toHex = (n: number) => Math.round(n * 255).toString(16).padStart(2, "0");

Callers 1

hslToHexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected