mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-15 21:02:18 +02:00
Add Documentation to hslToHex
Function
This commit is contained in:
parent
c3e85d2812
commit
5e640436a2
12
src/utils.ts
12
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];
|
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 a = s * Math.min(l, 1 - l);
|
||||||
const f = (n: number) => {
|
const f = (n: number) => {
|
||||||
const k = (n + h / 30) % 12;
|
const k = (n + h / 30) % 12;
|
||||||
|
Loading…
Reference in New Issue
Block a user