{"version":3,"file":"Color-9b9a0c78.js","sources":["../../src/structures/util/Color.ts"],"sourcesContent":["export const ConvertIntColorToHex = (color: number, alpha?: number) => {\n\treturn `#${color.toString(16)}` + (alpha ? SetHexAlpha(alpha) : \"\");\n};\n\nexport const SetHexAlpha = (alpha: number): string => {\n\tif (alpha > 1 || alpha < 0 || isNaN(alpha)) {\n\t\tthrow Error(\"alpha must be between 0 and 1\");\n\t}\n\n\treturn Math.ceil(255 * alpha)\n\t\t.toString(16)\n\t\t.toUpperCase();\n};\n\nexport const GetDecimalAlpha = (num: number): number => {\n\treturn num & 0xff;\n};\n\nexport const ConvertRGBAToDecimal = (r: number, g: number, b: number, a: number): number =>\n\t(r << 24) | (g << 16) | (b << 8) | a;\n\nexport const ConvertDecimalRGBAToString = (num: number): string => {\n\tconst r = (num >>> 24) & 0xff;\n\tconst g = (num >>> 16) & 0xff;\n\tconst b = (num >>> 8) & 0xff;\n\tconst a = num & 0xff;\n\n\treturn `rgba(${r}, ${g}, ${b}, ${(a / 255).toFixed(3)})`;\n};\n\nexport const ConvertHexToRGB = (hex: string): [number, number, number] => {\n\tconst t = parseInt(hex?.slice(1) ?? \"0\", 16);\n\tconst r = (t >> 16) & 255;\n\tconst g = (t >> 8) & 255;\n\tconst b = t & 255;\n\treturn [r, g, b];\n};\nexport const ConvertDecimalToHex = (num: number, alpha?: boolean): string => {\n\tconst r = (num >>> 24) & 0xff;\n\tconst g = (num >>> 16) & 0xff;\n\tconst b = (num >>> 8) & 0xff;\n\tconst a = num & 0xff;\n\n\treturn \"#\" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1) + (alpha ? SetHexAlpha(a / 255) : \"\");\n};\n\nexport const ConvertIntToHSVColor = (color: number) => {\n\tconst r = color >> 16;\n\tconst g = (color >> 8) & ((1 << 8) - 1);\n\tconst b = color & ((1 << 8) - 1);\n\treturn ConvertRGBToHSVColor(r, g, b);\n};\n\nexport const ConvertRGBToHSVColor = (r: number, g: number, b: number) => {\n\tconst rabs = r / 255;\n\tconst gabs = g / 255;\n\tconst babs = b / 255;\n\tconst v = Math.max(rabs, gabs, babs);\n\tconst diff = v - Math.min(rabs, gabs, babs);\n\tconst diffc = (c: number) => (v - c) / 6 / diff + 1 / 2;\n\tconst percentRoundFn = (num: number) => Math.round(num * 100) / 100;\n\tlet h = 0;\n\tlet s = 0;\n\tif (diff === 0) {\n\t\th = s = 0;\n\t} else {\n\t\ts = diff / v;\n\t\tconst rr = diffc(rabs);\n\t\tconst gg = diffc(gabs);\n\t\tconst bb = diffc(babs);\n\n\t\tif (rabs === v) {\n\t\t\th = bb - gg;\n\t\t} else if (gabs === v) {\n\t\t\th = 1 / 3 + rr - bb;\n\t\t} else if (babs === v) {\n\t\t\th = 2 / 3 + gg - rr;\n\t\t}\n\t\tif (h < 0) {\n\t\t\th += 1;\n\t\t} else if (h > 1) {\n\t\t\th -= 1;\n\t\t}\n\t}\n\treturn {\n\t\th: Math.round(h * 360),\n\t\ts: percentRoundFn(s * 100),\n\t\tv: percentRoundFn(v * 100),\n\t};\n};\n\nexport const hsv2hsl = (h: number, s: number, v: number, l = v - (v * s) / 2, m = Math.min(l, 1 - l)) => [\n\th,\n\tm ? (v - l) / m : 0,\n\tl,\n];\n\nexport const hsl2hsv = (h: number, s: number, l: number, v = s * Math.min(l, 1 - l) + l) => [\n\th,\n\tv ? 2 - (2 * l) / v : 0,\n\tv,\n];\n\nexport const NormalizeColor = (color: number, loweLight: number, upperLight: number) => {\n\tconst r = color >> 16;\n\tconst g = (color >> 8) & ((1 << 8) - 1);\n\tconst b = color & ((1 << 8) - 1);\n\tconst hsv = ConvertRGBToHSVColor(r, g, b);\n\tconst hsl = hsv2hsl(hsv.h / 360, hsv.s / 100, hsv.v / 100).map((v) => v * 100);\n\treturn `hsl(${hsl[0] * 3.6}deg, ${hsl[1]}%, ${\n\t\thsl[2] < loweLight ? loweLight : hsl[2] > upperLight ? upperLight : hsl[2]\n\t}%)`;\n};\n"],"names":["ConvertIntColorToHex","color","alpha","SetHexAlpha","GetDecimalAlpha","num","ConvertRGBAToDecimal","r","g","b","a","ConvertDecimalRGBAToString","ConvertHexToRGB","hex","t","ConvertDecimalToHex"],"mappings":"AAAa,MAAAA,EAAuB,CAACC,EAAeC,IAC5C,IAAID,EAAM,SAAS,EAAE,KAAOC,EAAQC,EAAYD,CAAK,EAAI,IAGpDC,EAAeD,GAA0B,CACrD,GAAIA,EAAQ,GAAKA,EAAQ,GAAK,MAAMA,CAAK,EACxC,MAAM,MAAM,+BAA+B,EAGrC,OAAA,KAAK,KAAK,IAAMA,CAAK,EAC1B,SAAS,EAAE,EACX,aACH,EAEaE,EAAmBC,GACxBA,EAAM,IAGDC,EAAuB,CAACC,EAAWC,EAAWC,EAAWC,IACpEH,GAAK,GAAOC,GAAK,GAAOC,GAAK,EAAKC,EAEvBC,EAA8BN,GAAwB,CAC5D,MAAAE,EAAKF,IAAQ,GAAM,IACnBG,EAAKH,IAAQ,GAAM,IACnBI,EAAKJ,IAAQ,EAAK,IAClBK,EAAIL,EAAM,IAEhB,MAAO,QAAQE,MAAMC,MAAMC,OAAOC,EAAI,KAAK,QAAQ,CAAC,IACrD,EAEaE,EAAmBC,GAA0C,CACzE,MAAMC,EAAI,SAASD,GAAK,MAAM,CAAC,GAAK,IAAK,EAAE,EACrCN,EAAKO,GAAK,GAAM,IAChBN,EAAKM,GAAK,EAAK,IACfL,EAAIK,EAAI,IACP,MAAA,CAACP,EAAGC,EAAGC,CAAC,CAChB,EACaM,EAAsB,CAACV,EAAaH,IAA4B,CACtE,MAAAK,EAAKF,IAAQ,GAAM,IACnBG,EAAKH,IAAQ,GAAM,IACnBI,EAAKJ,IAAQ,EAAK,IAClBK,EAAIL,EAAM,IAEhB,MAAO,KAAQ,UAAYE,GAAK,KAAOC,GAAK,GAAKC,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,GAAKP,EAAQC,EAAYO,EAAI,GAAG,EAAI,GAC7G"}