diff --git a/src/utils.ts b/src/utils.ts index f102c6a704f..e02d95473d8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -449,7 +449,17 @@ export function rgbaToInt(rgba: integer[]): integer { return (rgba[0] << 24) + (rgba[1] << 16) + (rgba[2] << 8) + rgba[3]; } -export function hslToHex(h: number, s: number, l: number) { +/** + * Provided valid HSV values, calculates and stitches together a string of that + * HSV color's corresponding hex code. + * + * Sourced from {@link https://stackoverflow.com/a/44134328}. + * @param h Hue in degrees, must be in a range of [0, 360] + * @param s Saturation percentage, must be in a range of [0, 1] + * @param l Ligthness percentage, must be in a range of [0, 1] + * @returns a string of the corresponding color hex code with a "#" prefix + */ +export function hslToHex(h: number, s: number, l: number): string { const a = s * Math.min(l, 1 - l); const f = (n: number) => { const k = (n + h / 30) % 12;