{"version":3,"file":"rockColor.js","sources":["../../../../Framework/Core/Utilities/rockColor.ts"],"sourcesContent":["// \r\n// Copyright by the Spark Development Network\r\n//\r\n// Licensed under the Rock Community License (the \"License\");\r\n// you may not use this file except in compliance with the License.\r\n// You may obtain a copy of the License at\r\n//\r\n// http://www.rockrms.com/license\r\n//\r\n// Unless required by applicable law or agreed to in writing, software\r\n// distributed under the License is distributed on an \"AS IS\" BASIS,\r\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n// See the License for the specific language governing permissions and\r\n// limitations under the License.\r\n// \r\n//\r\n\r\n// NOTICE!!!\r\n// This file has a C# version in the Rock.Common project. If changes are made\r\n// to one the same changes must be made to the other.\r\n// NOTICE!!!\r\n\r\nimport { ColorPair } from \"./colorPair\";\r\nimport { ColorScheme } from \"@Obsidian/Enums/Core/colorScheme\";\r\nimport { ColorRecipe } from \"@Obsidian/Enums/Core/colorRecipe\";\r\n\r\nconst html4Colors: Map = new Map([\r\n [\"aliceblue\", 0xf0f8ff],\r\n [\"antiquewhite\", 0xfaebd7],\r\n [\"aqua\", 0x00ffff],\r\n [\"aquamarine\", 0x7fffd4],\r\n [\"azure\", 0xf0ffff],\r\n [\"beige\", 0xf5f5dc],\r\n [\"bisque\", 0xffe4c4],\r\n [\"black\", 0x000000],\r\n [\"blanchedalmond\", 0xffebcd],\r\n [\"blue\", 0x0000ff],\r\n [\"blueviolet\", 0x8a2be2],\r\n [\"brown\", 0xa52a2a],\r\n [\"burlywood\", 0xdeb887],\r\n [\"cadetblue\", 0x5f9ea0],\r\n [\"chartreuse\", 0x7fff00],\r\n [\"chocolate\", 0xd2691e],\r\n [\"coral\", 0xff7f50],\r\n [\"cornflowerblue\", 0x6495ed],\r\n [\"cornsilk\", 0xfff8dc],\r\n [\"crimson\", 0xdc143c],\r\n [\"cyan\", 0x00ffff],\r\n [\"darkblue\", 0x00008b],\r\n [\"darkcyan\", 0x008b8b],\r\n [\"darkgoldenrod\", 0xb8860b],\r\n [\"darkgray\", 0xa9a9a9],\r\n [\"darkgrey\", 0xa9a9a9],\r\n [\"darkgreen\", 0x006400],\r\n [\"darkkhaki\", 0xbdb76b],\r\n [\"darkmagenta\", 0x8b008b],\r\n [\"darkolivegreen\", 0x556b2f],\r\n [\"darkorange\", 0xff8c00],\r\n [\"darkorchid\", 0x9932cc],\r\n [\"darkred\", 0x8b0000],\r\n [\"darksalmon\", 0xe9967a],\r\n [\"darkseagreen\", 0x8fbc8f],\r\n [\"darkslateblue\", 0x483d8b],\r\n [\"darkslategray\", 0x2f4f4f],\r\n [\"darkslategrey\", 0x2f4f4f],\r\n [\"darkturquoise\", 0x00ced1],\r\n [\"darkviolet\", 0x9400d3],\r\n [\"deeppink\", 0xff1493],\r\n [\"deepskyblue\", 0x00bfff],\r\n [\"dimgray\", 0x696969],\r\n [\"dimgrey\", 0x696969],\r\n [\"dodgerblue\", 0x1e90ff],\r\n [\"firebrick\", 0xb22222],\r\n [\"floralwhite\", 0xfffaf0],\r\n [\"forestgreen\", 0x228b22],\r\n [\"fuchsia\", 0xff00ff],\r\n [\"gainsboro\", 0xdcdcdc],\r\n [\"ghostwhite\", 0xf8f8ff],\r\n [\"gold\", 0xffd700],\r\n [\"goldenrod\", 0xdaa520],\r\n [\"gray\", 0x808080],\r\n [\"grey\", 0x808080],\r\n [\"green\", 0x008000],\r\n [\"greenyellow\", 0xadff2f],\r\n [\"honeydew\", 0xf0fff0],\r\n [\"hotpink\", 0xff69b4],\r\n [\"indianred\", 0xcd5c5c],\r\n [\"indigo\", 0x4b0082],\r\n [\"ivory\", 0xfffff0],\r\n [\"khaki\", 0xf0e68c],\r\n [\"lavender\", 0xe6e6fa],\r\n [\"lavenderblush\", 0xfff0f5],\r\n [\"lawngreen\", 0x7cfc00],\r\n [\"lemonchiffon\", 0xfffacd],\r\n [\"lightblue\", 0xadd8e6],\r\n [\"lightcoral\", 0xf08080],\r\n [\"lightcyan\", 0xe0ffff],\r\n [\"lightgoldenrodyellow\", 0xfafad2],\r\n [\"lightgray\", 0xd3d3d3],\r\n [\"lightgrey\", 0xd3d3d3],\r\n [\"lightgreen\", 0x90ee90],\r\n [\"lightpink\", 0xffb6c1],\r\n [\"lightsalmon\", 0xffa07a],\r\n [\"lightseagreen\", 0x20b2aa],\r\n [\"lightskyblue\", 0x87cefa],\r\n [\"lightslategray\", 0x778899],\r\n [\"lightslategrey\", 0x778899],\r\n [\"lightsteelblue\", 0xb0c4de],\r\n [\"lightyellow\", 0xffffe0],\r\n [\"lime\", 0x00ff00],\r\n [\"limegreen\", 0x32cd32],\r\n [\"linen\", 0xfaf0e6],\r\n [\"magenta\", 0xff00ff],\r\n [\"maroon\", 0x800000],\r\n [\"mediumaquamarine\", 0x66cdaa],\r\n [\"mediumblue\", 0x0000cd],\r\n [\"mediumorchid\", 0xba55d3],\r\n [\"mediumpurple\", 0x9370d8],\r\n [\"mediumseagreen\", 0x3cb371],\r\n [\"mediumslateblue\", 0x7b68ee],\r\n [\"mediumspringgreen\", 0x00fa9a],\r\n [\"mediumturquoise\", 0x48d1cc],\r\n [\"mediumvioletred\", 0xc71585],\r\n [\"midnightblue\", 0x191970],\r\n [\"mintcream\", 0xf5fffa],\r\n [\"mistyrose\", 0xffe4e1],\r\n [\"moccasin\", 0xffe4b5],\r\n [\"navajowhite\", 0xffdead],\r\n [\"navy\", 0x000080],\r\n [\"oldlace\", 0xfdf5e6],\r\n [\"olive\", 0x808000],\r\n [\"olivedrab\", 0x6b8e23],\r\n [\"orange\", 0xffa500],\r\n [\"orangered\", 0xff4500],\r\n [\"orchid\", 0xda70d6],\r\n [\"palegoldenrod\", 0xeee8aa],\r\n [\"palegreen\", 0x98fb98],\r\n [\"paleturquoise\", 0xafeeee],\r\n [\"palevioletred\", 0xd87093],\r\n [\"papayawhip\", 0xffefd5],\r\n [\"peachpuff\", 0xffdab9],\r\n [\"peru\", 0xcd853f],\r\n [\"pink\", 0xffc0cb],\r\n [\"plum\", 0xdda0dd],\r\n [\"powderblue\", 0xb0e0e6],\r\n [\"purple\", 0x800080],\r\n [\"red\", 0xff0000],\r\n [\"rosybrown\", 0xbc8f8f],\r\n [\"royalblue\", 0x4169e1],\r\n [\"saddlebrown\", 0x8b4513],\r\n [\"salmon\", 0xfa8072],\r\n [\"sandybrown\", 0xf4a460],\r\n [\"seagreen\", 0x2e8b57],\r\n [\"seashell\", 0xfff5ee],\r\n [\"sienna\", 0xa0522d],\r\n [\"silver\", 0xc0c0c0],\r\n [\"skyblue\", 0x87ceeb],\r\n [\"slateblue\", 0x6a5acd],\r\n [\"slategray\", 0x708090],\r\n [\"slategrey\", 0x708090],\r\n [\"snow\", 0xfffafa],\r\n [\"springgreen\", 0x00ff7f],\r\n [\"steelblue\", 0x4682b4],\r\n [\"tan\", 0xd2b48c],\r\n [\"teal\", 0x008080],\r\n [\"thistle\", 0xd8bfd8],\r\n [\"tomato\", 0xff6347],\r\n [\"turquoise\", 0x40e0d0],\r\n [\"violet\", 0xee82ee],\r\n [\"wheat\", 0xf5deb3],\r\n [\"white\", 0xffffff],\r\n [\"whitesmoke\", 0xf5f5f5],\r\n [\"yellow\", 0xffff00],\r\n [\"yellowgreen\", 0x9acd32]\r\n]);\r\n\r\nconst html4ColorsReverse: Map = new Map();\r\n\r\nhtml4Colors.forEach((value, key) => {\r\n // Reverse the order.\r\n if (!html4ColorsReverse.has(value)) {\r\n html4ColorsReverse.set(value, key);\r\n }\r\n});\r\n\r\n/**\r\n * Normalizes the value to ensure it falls between the minimum and maximum\r\n * values, inclusively.\r\n *\r\n * @param value The value to be normalized.\r\n * @param minimum The minimum value allowed.\r\n * @param maximum The maximum value allowed.\r\n *\r\n * @returns The number after it has been constrained to the allowed values.\r\n */\r\nfunction normalize(value: number, minimum: number, maximum: number): number {\r\n return value < minimum ? minimum : value > maximum ? maximum : value;\r\n}\r\n\r\n/**\r\n * Helper method to perform some conversion of HSL values to RGB values.\r\n *\r\n * @param q1 The first value.\r\n * @param q2 The second value.\r\n * @param hue The hue value.\r\n */\r\nfunction qqhToRgb(q1: number, q2: number, hue: number): number {\r\n if (hue > 360) {\r\n hue -= 360;\r\n }\r\n else if (hue < 0) {\r\n hue += 360;\r\n }\r\n\r\n if (hue < 60) {\r\n return q1 + (q2 - q1) * hue / 60;\r\n }\r\n else if (hue < 180) {\r\n return q2;\r\n }\r\n else if (hue < 240) {\r\n return q1 + (q2 - q1) * (240 - hue) / 60;\r\n }\r\n else {\r\n return q1;\r\n }\r\n}\r\n\r\n/**\r\n * Parses a hex string into a single numerical value.\r\n *\r\n * @param hex The string containing the hex characters.\r\n *\r\n * @returns The numerical value of the hex representation.\r\n */\r\nfunction parseHexValue(hex: string): number {\r\n const value = parseInt(hex, 16);\r\n\r\n return isNaN(value) ? 0 : value;\r\n}\r\n\r\n/**\r\n * Parses a hexadecimal representation of a color into the RGBA values.\r\n *\r\n * @param hex The hexadecimal representation of the color.\r\n *\r\n * @returns A 4 segment array of numbers that represent the RGBA values.\r\n */\r\nfunction parseHexString(hex: string): number[] {\r\n hex = hex.startsWith(\"#\") ? hex.substring(1) : hex;\r\n\r\n if (hex.length === 8) {\r\n return [\r\n parseHexValue(hex.substring(0, 2)),\r\n parseHexValue(hex.substring(2, 4)),\r\n parseHexValue(hex.substring(4, 6)),\r\n parseHexValue(hex.substring(6, 8)) / 255\r\n ];\r\n }\r\n else if (hex.length === 6) {\r\n return [\r\n parseHexValue(hex.substring(0, 2)),\r\n parseHexValue(hex.substring(2, 4)),\r\n parseHexValue(hex.substring(4, 6)),\r\n 1\r\n ];\r\n }\r\n else if (hex.length === 4) {\r\n return [\r\n parseHexValue(hex.substring(0, 1).repeat(2)),\r\n parseHexValue(hex.substring(1, 2).repeat(2)),\r\n parseHexValue(hex.substring(2, 3).repeat(2)),\r\n parseHexValue(hex.substring(3, 4).repeat(2)) / 255\r\n ];\r\n }\r\n else if (hex.length === 3) {\r\n return [\r\n parseHexValue(hex.substring(0, 1).repeat(2)),\r\n parseHexValue(hex.substring(1, 2).repeat(2)),\r\n parseHexValue(hex.substring(2, 3).repeat(2)),\r\n 1\r\n ];\r\n }\r\n else {\r\n return [0, 0, 0, 1];\r\n }\r\n}\r\n\r\n/**\r\n * Helper function to parse a floating point number from a string with error\r\n * handling for non-numbers.\r\n *\r\n * @param str The string to be parsed.\r\n *\r\n * @returns The numerical value or 0 if it could not be parsed.\r\n */\r\nfunction asFloat(str: string): number {\r\n const num = parseFloat(str);\r\n\r\n return isNaN(num) ? 0 : num;\r\n}\r\n\r\n/**\r\n * Utility class for color manipulation.\r\n */\r\nexport class RockColor {\r\n // #region Fields\r\n\r\n private readonly rgbInternal: number[] = [0, 0, 0];\r\n private alphaInternal: number = 1;\r\n private hueInternal!: number;\r\n private saturationInternal!: number;\r\n private luminosityInternal!: number;\r\n private textInternal?: string;\r\n\r\n // #endregion\r\n\r\n // #region Properties\r\n\r\n /**\r\n * Gets or sets the Alpha level. This will be between 0 and 1.\r\n */\r\n public get alpha(): number {\r\n return this.alphaInternal;\r\n }\r\n\r\n public set alpha(value: number) {\r\n this.alphaInternal = normalize(value, 0, 1);\r\n }\r\n\r\n /**\r\n * Gets or sets the Red value of the color. This will be between 0 and 255.\r\n */\r\n public get r(): number {\r\n return this.rgbInternal[0];\r\n }\r\n\r\n public set r(value: number) {\r\n this.rgbInternal[0] = normalize(value, 0, 255);\r\n this.updateHslFromRgb();\r\n }\r\n\r\n /**\r\n * Gets or sets the Green value of the color. This will be between 0 and 255.\r\n */\r\n public get g(): number {\r\n return this.rgbInternal[1];\r\n }\r\n\r\n public set g(value: number) {\r\n this.rgbInternal[1] = normalize(value, 0, 255);\r\n this.updateHslFromRgb();\r\n }\r\n\r\n /**\r\n * Gets or sets the Blue value of the color. This will be between 0 and 255.\r\n */\r\n public get b(): number {\r\n return this.rgbInternal[2];\r\n }\r\n\r\n public set b(value: number) {\r\n this.rgbInternal[2] = normalize(value, 0, 255);\r\n this.updateHslFromRgb();\r\n }\r\n\r\n /**\r\n * Calculates the luma value based on the W3 Standard.\r\n */\r\n public get luma(): number {\r\n const { red, green, blue } = this.toStandardRgb();\r\n\r\n return (0.2126 * red) + (0.7152 * green) + (0.0722 * blue);\r\n }\r\n\r\n /**\r\n * Gets or sets the hue of the color.\r\n */\r\n public get hue(): number {\r\n return this.hueInternal;\r\n }\r\n\r\n public set hue(value: number) {\r\n // Take care of translating things like 540 to 360.\r\n while (value > 360) {\r\n value -= 360;\r\n }\r\n\r\n while (value < 0) {\r\n value += 360;\r\n }\r\n\r\n this.hueInternal = value;\r\n this.updateRgbFromHsl();\r\n }\r\n\r\n /**\r\n * Gets or sets the saturation of the color.\r\n */\r\n public get saturation(): number {\r\n return this.saturationInternal;\r\n }\r\n\r\n public set saturation(value: number) {\r\n this.saturationInternal = normalize(value, 0, 1);\r\n this.updateRgbFromHsl();\r\n }\r\n\r\n /**\r\n * Gets or sets the luminosity of the color.\r\n */\r\n public get luminosity(): number {\r\n return this.luminosityInternal;\r\n }\r\n\r\n public set luminosity(value: number) {\r\n this.luminosityInternal = normalize(value, 0, 1);\r\n this.updateRgbFromHsl();\r\n }\r\n\r\n /**\r\n * Gets the color as a hexadecimal string, including the leading `#`.\r\n */\r\n public get hex(): string {\r\n return this.toHex();\r\n }\r\n\r\n /**\r\n * Determines if the color is a light color.\r\n */\r\n public get isLight(): boolean {\r\n return this.luminosityInternal > 0.5;\r\n }\r\n\r\n /**\r\n * Determines if the color is a dark color.\r\n */\r\n public get isDark(): boolean {\r\n return !this.isLight;\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Constructors\r\n\r\n constructor(color: string);\r\n constructor(rgb: number[]);\r\n constructor(rgb: number[], alpha: number);\r\n constructor(rgb: number[], alpha: number, text: string);\r\n constructor(color: number);\r\n constructor(red: number, green: number, blue: number);\r\n constructor(red: number, green: number, blue: number, alpha: number);\r\n constructor(red: number, green: number, blue: number, alpha?: number, text?: string);\r\n\r\n constructor(p1: number | string | number[], p2?: number, p3?: number | string, p4?: number, p5?: string) {\r\n if (typeof p1 === \"number\") {\r\n if (typeof p2 === \"undefined\") {\r\n this.constructFromSingleNumber(p1);\r\n }\r\n else if (typeof p3 === \"number\") {\r\n if (typeof p4 === \"number\") {\r\n this.constructFromRgb([p1, p2, p3], p4);\r\n }\r\n else {\r\n this.constructFromRgb([p1, p2, p3], 1);\r\n }\r\n\r\n if (typeof p5 === \"string\") {\r\n this.textInternal = p5;\r\n }\r\n }\r\n }\r\n else if (typeof p1 === \"string\") {\r\n this.constructFromString(p1);\r\n }\r\n else if (p1.length === 3) {\r\n if (typeof p2 === \"number\") {\r\n this.constructFromRgb([p1[0], p1[1], p1[2]], p2);\r\n }\r\n else {\r\n this.constructFromRgb([p1[0], p1[1], p1[2]], 1);\r\n }\r\n\r\n if (typeof p3 === \"string\") {\r\n this.textInternal = p3;\r\n }\r\n }\r\n\r\n this.updateHslFromRgb();\r\n }\r\n\r\n /**\r\n * Creates this instance from the specified number value. This is a numeric\r\n * representation such as 0x112233.\r\n *\r\n * @param color The color has a number value.\r\n */\r\n private constructFromSingleNumber(color: number): void {\r\n this.rgbInternal[0] = color & 0xff;\r\n color >>= 8;\r\n this.rgbInternal[1] = color & 0xff;\r\n color >>= 8;\r\n this.rgbInternal[2] = color & 0xff;\r\n\r\n this.alphaInternal = 1;\r\n }\r\n\r\n /**\r\n * Creates this instance from the specified text value. This can be either\r\n * a `#` hex value, an `rgba` value, an `rgb` value or a named HTML color.\r\n *\r\n * @param color The string that represents the color.\r\n */\r\n private constructFromString(color: string): void {\r\n // Check for colors in #ee7625 format.\r\n if (color.startsWith(\"#\")) {\r\n const rgba = parseHexString(color);\r\n this.rgbInternal[0] = normalize(rgba[0], 0, 255);\r\n this.rgbInternal[1] = normalize(rgba[1], 0, 255);\r\n this.rgbInternal[2] = normalize(rgba[2], 0, 255);\r\n this.alphaInternal = normalize(rgba[3], 0, 1);\r\n }\r\n\r\n // Check for colors in rgba(255, 99, 71, 0.5) format.\r\n else if (color.startsWith(\"rgba\")) {\r\n const parts = color.replace(/ /g, \"\")\r\n .replace(\"rgba(\", \"\")\r\n .replace(\")\", \"\")\r\n .split(\",\");\r\n\r\n if (parts.length === 4) {\r\n this.rgbInternal[0] = normalize(asFloat(parts[0].trim()), 0, 255);\r\n this.rgbInternal[1] = normalize(asFloat(parts[1].trim()), 0, 255);\r\n this.rgbInternal[2] = normalize(asFloat(parts[2].trim()), 0, 255);\r\n this.alphaInternal = normalize(asFloat(parts[3].trim()), 0, 1);\r\n }\r\n }\r\n\r\n // Check for colors in rgb(255, 99, 71) format.\r\n else if (color.startsWith(\"rgb\")) {\r\n const parts = color.replace(/ /g, \"\")\r\n .replace(\"rgb(\", \"\")\r\n .replace(\")\", \"\")\r\n .split(\",\");\r\n\r\n if (parts.length === 3) {\r\n this.rgbInternal[0] = normalize(asFloat(parts[0].trim()), 0, 255);\r\n this.rgbInternal[1] = normalize(asFloat(parts[1].trim()), 0, 255);\r\n this.rgbInternal[2] = normalize(asFloat(parts[2].trim()), 0, 255);\r\n this.alphaInternal = 1;\r\n }\r\n }\r\n\r\n // Check if it is a named color.\r\n else {\r\n const namedColor = RockColor.getColorFromKeyword(color);\r\n\r\n if (namedColor != null) {\r\n this.rgbInternal[0] = namedColor.r;\r\n this.rgbInternal[1] = namedColor.g;\r\n this.rgbInternal[2] = namedColor.b;\r\n this.alpha = namedColor.alpha;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates this instance from the specified RGB and alpha values.\r\n *\r\n * @param rgb The RGB components, this must always have 3 components.\r\n * @param alpha The alpha value to assign.\r\n */\r\n private constructFromRgb(rgb: number[], alpha: number): void {\r\n this.rgbInternal[0] = normalize(rgb[0], 0, 255);\r\n this.rgbInternal[1] = normalize(rgb[1], 0, 255);\r\n this.rgbInternal[2] = normalize(rgb[2], 0, 255);\r\n this.alphaInternal = normalize(alpha, 0, 1);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Private Functions\r\n\r\n /**\r\n * Updates the HSL values of the color from the RGB values.\r\n */\r\n private updateHslFromRgb(): void {\r\n // Convert the RGB values to representations of between 0.0 and 1.0.\r\n const red = this.rgbInternal[0] / 255;\r\n const green = this.rgbInternal[1] / 255;\r\n const blue = this.rgbInternal[2] / 255;\r\n\r\n // Get the maximum value between all three components.\r\n const max = Math.max(red, green, blue);\r\n\r\n // Get the minmimum value between all three components.\r\n const min = Math.min(red, green, blue);\r\n\r\n // Update the luminosity.\r\n this.luminosityInternal = (max + min) / 2;\r\n\r\n const diff = max - min;\r\n\r\n // Update the hue and saturation values.\r\n if (Math.abs(diff) < 0.00001) {\r\n this.saturationInternal = 0;\r\n this.hueInternal = 0;\r\n }\r\n else {\r\n if (this.luminosityInternal <= 0.5) {\r\n this.saturationInternal = diff / (max + min);\r\n }\r\n else {\r\n this.saturationInternal = diff / (2 - max - min);\r\n }\r\n\r\n const redDist = (max - red) / diff;\r\n const greenDist = (max - green) / diff;\r\n const blueDist = (max - blue) / diff;\r\n\r\n let hue: number;\r\n\r\n if (red == max) {\r\n hue = blueDist - greenDist;\r\n }\r\n else if (green == max) {\r\n hue = 2 + redDist - blueDist;\r\n }\r\n else {\r\n hue = 4 + greenDist - redDist;\r\n }\r\n\r\n hue = hue * 60;\r\n if (hue < 0) {\r\n hue += 360;\r\n }\r\n\r\n this.hueInternal = normalize(hue, 0, 360);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the RGB values of the color from the HSL values.\r\n */\r\n private updateRgbFromHsl(): void {\r\n const p2 = this.luminosityInternal <= 0.5\r\n ? this.luminosityInternal * (1 + this.saturationInternal)\r\n : this.luminosityInternal + this.saturationInternal - this.luminosityInternal * this.saturationInternal;\r\n const p1 = 2 * this.luminosityInternal - p2;\r\n\r\n let red: number;\r\n let green: number;\r\n let blue: number;\r\n\r\n if (this.saturationInternal === 0) {\r\n red = this.luminosityInternal;\r\n green = this.luminosityInternal;\r\n blue = this.luminosityInternal;\r\n }\r\n else {\r\n red = qqhToRgb(p1, p2, this.hueInternal + 120);\r\n green = qqhToRgb(p1, p2, this.hueInternal);\r\n blue = qqhToRgb(p1, p2, this.hueInternal - 120);\r\n }\r\n\r\n // Convert the decimal RGB values to 0 to 255 range.\r\n this.rgbInternal[0] = normalize(Math.round(red * 255), 0, 255);\r\n this.rgbInternal[1] = normalize(Math.round(green * 255), 0, 255);\r\n this.rgbInternal[2] = normalize(Math.round(blue * 255), 0, 255);\r\n }\r\n\r\n // #endregion\r\n\r\n // #region Public Functions\r\n\r\n /**\r\n * Gets the {@link RockColor} that corresponds to the HTML color keyword.\r\n *\r\n * @param keyword The HTML color keyword.\r\n *\r\n * @returns An instance of {@link RockColor} that represents the color or `null` if not found.\r\n */\r\n public static getColorFromKeyword(keyword: string): RockColor | null {\r\n if (keyword === \"transparent\") {\r\n return new RockColor(0, 0, 0, 0, keyword);\r\n }\r\n\r\n const rgb = html4Colors.get(keyword);\r\n if (rgb !== undefined) {\r\n const red = (rgb >> 16) & 0xff;\r\n const green = (rgb >> 8) & 0xff;\r\n const blue = rgb & 0xff;\r\n\r\n return new RockColor(red, green, blue, 1, keyword);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Calculates the contrast ratio between two colors.\r\n *\r\n * @param color1 The first color.\r\n * @param color2 The second color.\r\n *\r\n * @returns A number that represents the contrast ratio between the two colors.\r\n */\r\n public static calculateContrastRatio(color1: RockColor, color2: RockColor): number {\r\n // Formula: (L1 + 0.05) / (L2 + 0.05)\r\n // https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156\r\n // https://www.w3.org/TR/2012/NOTE-WCAG20-TECHS-20120103/G17.html\r\n // L1 = Lighter color\r\n // L2 = Darker color\r\n\r\n let l1: RockColor;\r\n let l2: RockColor;\r\n\r\n // Determine the lighter and darker color.\r\n if (color1.luminosity > color2.luminosity) {\r\n l1 = color1;\r\n l2 = color2;\r\n }\r\n else {\r\n l1 = color2;\r\n l2 = color1;\r\n }\r\n\r\n return (l1.luma + 0.05) / (l2.luma + 0.05);\r\n }\r\n\r\n /**\r\n * Creates a color pair from a single color with logic for light and\r\n * dark modes.\r\n *\r\n * @param color The base color to use when creating the color pair.\r\n * @param colorScheme The color scheme the color will be used in.\r\n *\r\n * @returns A new instance of {@link ColorPair}.\r\n */\r\n public static calculateColorPair(color: RockColor, colorScheme: ColorScheme = ColorScheme.Light): ColorPair {\r\n const foregroundColor = RockColor.calculateColorRecipe(color, ColorRecipe.Darkest);\r\n const backgroundColor = RockColor.calculateColorRecipe(color, ColorRecipe.Lightest);\r\n\r\n const colorPair = new ColorPair(foregroundColor, backgroundColor);\r\n\r\n if (colorScheme === ColorScheme.Dark) {\r\n colorPair.flip();\r\n }\r\n\r\n return colorPair;\r\n }\r\n\r\n /**\r\n * Creates a recipe color from the provided color.\r\n *\r\n * @param color The base color to calculate the new color from.\r\n * @param recipe The recipe to use when calculating the new color.\r\n *\r\n * @returns A new instance of {@link RockColor}.\r\n */\r\n public static calculateColorRecipe(color: RockColor, recipe: ColorRecipe): RockColor {\r\n const recipeColor = color.clone();\r\n let recipeSaturation = 0;\r\n let recipeLuminosity = 0;\r\n\r\n switch (recipe) {\r\n case ColorRecipe.Lightest:\r\n recipeSaturation = 0.88;\r\n recipeLuminosity = 0.87;\r\n break;\r\n\r\n case ColorRecipe.Light:\r\n recipeSaturation = 0.10;\r\n recipeLuminosity = 0.95;\r\n break;\r\n\r\n case ColorRecipe.Medium:\r\n recipeSaturation = 0.20;\r\n recipeLuminosity = 0.66;\r\n break;\r\n\r\n case ColorRecipe.Dark:\r\n recipeSaturation = 0.30;\r\n recipeLuminosity = 0.45;\r\n break;\r\n\r\n case ColorRecipe.Darkest:\r\n recipeSaturation = 0.60;\r\n recipeLuminosity = 0.20;\r\n break;\r\n\r\n case ColorRecipe.Primary:\r\n recipeSaturation = 0.70;\r\n recipeLuminosity = 0.80;\r\n break;\r\n }\r\n\r\n // If the saturation of the original color is very low then we'll use\r\n // a different recipe so the color looks more like the original (which\r\n // would be gray).\r\n if (color.saturation <= 0.15) {\r\n recipeSaturation = color.saturation;\r\n }\r\n\r\n recipeColor.saturation = recipeSaturation;\r\n recipeColor.luminosity = recipeLuminosity;\r\n\r\n return recipeColor;\r\n }\r\n\r\n /**\r\n * Lightens the color by the provided percentage.\r\n *\r\n * @param percentage The percentage amount to lighten the color as a number between 0 and 100.\r\n */\r\n public lighten(percentage: number): void {\r\n this.luminosity = this.luminosity + (percentage / 100);\r\n }\r\n\r\n /**\r\n * Darkens the color by the provided percentage.\r\n *\r\n * @param percentage The percentage amount to darken the color as a number between 0 and 100.\r\n */\r\n public darken(percentage: number): void {\r\n this.luminosity = this.luminosity - (percentage / 100);\r\n }\r\n\r\n /**\r\n * Saturates the color by the provided percentage.\r\n *\r\n * @param percentage The percentage amount to saturate the color as a number between 0 and 100.\r\n */\r\n public saturate(percentage: number): void {\r\n this.saturation = this.saturation + (percentage / 100);\r\n }\r\n\r\n /**\r\n * Desaturates the color by the provided percentage.\r\n *\r\n * @param percentage The percentage amount to desaturate the color as a number between 0 and 100.\r\n */\r\n public desaturate(percentage: number): void {\r\n this.saturation = this.saturation - (percentage / 100);\r\n }\r\n\r\n /**\r\n * Increases the opacity level by the given percentage. This makes the\r\n * color less transparent and more opaque.\r\n *\r\n * @param percentage The percentage amount to adjust the alpha as a number between 0 and 100.\r\n */\r\n public fadeIn(percentage: number): void {\r\n this.alpha = this.alpha + (percentage / 100);\r\n }\r\n\r\n /**\r\n * Decreases the opacity level by the given percentage. This makes the\r\n * color more transparent and less opaque.\r\n *\r\n * @param percentage The percentage amount to adjust the alpha as a number between 0 and 100.\r\n */\r\n public fadeOut(percentage: number): void {\r\n this.alpha = this.alpha - (percentage / 100);\r\n }\r\n\r\n /**\r\n * Adjusts the hue by the specified percentage.\r\n *\r\n * @param percentage The percentage to adjust the hue by as a value between -100 and 100.\r\n */\r\n public adjustHueByPercent(percentage: number): void {\r\n this.hue = this.hue + (360 * (percentage / 100));\r\n }\r\n\r\n /**\r\n * Adjusts the hue by the specified number of degrees.\r\n *\r\n * @param degrees The number of degrees to adjust the hue by as a value between -360 and 360.\r\n */\r\n public adjustHueByDegrees(degrees: number): void {\r\n this.hue = this.hue + degrees;\r\n }\r\n\r\n /**\r\n * Tints the specified percentage amount. This mixes this color with white\r\n * by the percentage.\r\n *\r\n * @param percentage The percentage amount as a value between 0 and 100.\r\n */\r\n public tint(percentage: number): void {\r\n this.mix(new RockColor(\"#ffffff\"), percentage);\r\n }\r\n\r\n /**\r\n * Shades the specified percentage amount. This mixes this color with black\r\n * by the percentage.\r\n *\r\n * @param percentage The percentage amount as a value between 0 and 100.\r\n */\r\n public shade(percentage: number): void {\r\n this.mix(new RockColor(\"#000000\"), percentage);\r\n }\r\n\r\n /**\r\n * Mixes the specified color into the current color with an optional\r\n * percentage amount.\r\n *\r\n * @param mixColor The color to be mixed into this color.\r\n * @param percentage The percentage amount to be mixed as a value between 0 and 100. Defaults to 50.\r\n */\r\n public mix(mixColor: RockColor, percentage?: number): void {\r\n const amount = (percentage ?? 50) / 100;\r\n\r\n this.r = (mixColor.r * amount) + this.r * (1 - amount);\r\n this.g = (mixColor.g * amount) + this.g * (1 - amount);\r\n this.b = (mixColor.b * amount) + this.b * (1 - amount);\r\n }\r\n\r\n /**\r\n * Turns the color to it's grayscale value.\r\n */\r\n public grayscale(): void {\r\n this.saturate(-100);\r\n }\r\n\r\n /**\r\n * Creates a clone of this color.\r\n *\r\n * @returns A new instance that has the same color values as this instance.\r\n */\r\n public clone(): RockColor {\r\n return new RockColor(this.rgbInternal, this.alpha);\r\n }\r\n\r\n /**\r\n * Converts the current color to a CSS `rgba` string format.\r\n *\r\n * @returns A string representation of the color.\r\n */\r\n public toRgba(): string {\r\n return `rgba(${Math.floor(this.r)}, ${Math.floor(this.g)}, ${Math.floor(this.b)}, ${this.alpha})`;\r\n }\r\n\r\n /**\r\n * Converts the current color to an HTML hexadecimal `#rrggbbaa` string\r\n * format. If the alpha value is 1 then the \"aa\" component will not be\r\n * included.\r\n *\r\n * @returns Hexadecimal version of the color.\r\n */\r\n public toHex(): string {\r\n const r = Math.round(this.r).toString(16).padStart(2, \"0\");\r\n const g = Math.round(this.g).toString(16).padStart(2, \"0\");\r\n const b = Math.round(this.b).toString(16).padStart(2, \"0\");\r\n const a = Math.round(this.alpha * 255).toString(16).padStart(2, \"0\");\r\n\r\n if (a === \"ff\") {\r\n return `#${r}${g}${b}`;\r\n }\r\n else {\r\n return `#${r}${g}${b}${a}`;\r\n }\r\n }\r\n\r\n /**\r\n * Gets a numeric value representing this color. If two colors have the\r\n * same RGB and Alpha values then they will return the same value here.\r\n *\r\n * @returns A numeric value that represents this unique color.\r\n */\r\n public valueOf(): number {\r\n return (this.r + this.g + this.b) * this.alpha;\r\n }\r\n\r\n /**\r\n * Compares this color against another color to see which one has a higher\r\n * value.\r\n *\r\n * @param otherColor The other color to compare this color to.\r\n *\r\n * @returns `0` if both colors are the same, `-1` if this color is less than the other color and `1` if this color is greater than the other color.\r\n */\r\n public compareTo(otherColor: RockColor | undefined | null): number {\r\n if (otherColor === undefined || otherColor === null) {\r\n return -1;\r\n }\r\n\r\n // Check if they are identical.\r\n if (this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.alpha === otherColor.alpha) {\r\n return 0;\r\n }\r\n\r\n return this.valueOf() > otherColor.valueOf() ? 1 : -1;\r\n }\r\n\r\n /**\r\n * Determines if two colors are similar.\r\n *\r\n * @param otherColor The other color to compare this color to.\r\n * @param similarityPercent The minimum percentage to consider the colors similar. This will be between 0 and 1 (defaults to 0.95).\r\n * @returns `true` if the colors are N percent similar, where N is the `similarityPercentage`; otherwise, returns `false`.\r\n * @example\r\n * // this = new RockColor(\"#FFF\")\r\n * this.isSimilarTo(new RockColor(\"#FFE\"), 0.95) // `true`, color similarity >= 95%\r\n * this.isSimilarTo(new RockColor(\"#FFE\"), 0.99) // `false`, color similarity < 99%\r\n * this.isSimilarTo(new RockColor(\"#FFE\"), 1) // `false`, color similarity != 100%\r\n * this.isSimilarTo(new RockColor(\"#FFF\"), 1) // `true`, color similarity = 100%\r\n */\r\n public isSimilarTo(otherColor: RockColor, similarityPercent: number = 0.95): boolean {\r\n similarityPercent = normalize(similarityPercent, 0, 1);\r\n\r\n if (similarityPercent === 0) {\r\n // A color similarity of 0% will always return `true`\r\n // as the colors do not have to be similar at all.\r\n return true;\r\n }\r\n\r\n if (this.compareTo(otherColor) === 0) {\r\n // The same colors will always return `true`\r\n // regardless of the percent similar passed in.\r\n return true;\r\n }\r\n\r\n if (similarityPercent === 1) {\r\n // The colors are not the same at this point\r\n // but the similarity percentage was set to 100%,\r\n // so return `false`.\r\n return false;\r\n }\r\n\r\n // Calculate the actual similarity percent and compare the actual and expected values.\r\n\r\n function calculateWeightedColorDistance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, maxColorValue: number): number {\r\n const redDiffSquared = Math.pow(r2 - r1, 2);\r\n const greenDiffSquared = Math.pow(g2 - g1, 2);\r\n const blueDiffSquared = Math.pow(b2 - b1, 2);\r\n const redAverage = (r2 + r1) / 2;\r\n const redAveragePercentage = redAverage / maxColorValue;\r\n\r\n return Math.sqrt(\r\n ((2 + redAveragePercentage) * redDiffSquared) +\r\n (4 * greenDiffSquared) +\r\n ((3 - redAveragePercentage) * blueDiffSquared)\r\n );\r\n }\r\n\r\n function calculateSimilarityPercent(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, maxColorValue: number): number {\r\n const maxDistance = calculateWeightedColorDistance(\r\n maxColorValue, maxColorValue, maxColorValue,\r\n 0, 0, 0,\r\n maxColorValue);\r\n\r\n const colorDistance = calculateWeightedColorDistance(\r\n r1, g1, b1,\r\n r2, g2, b2,\r\n maxColorValue);\r\n\r\n return 1 - (colorDistance / maxDistance);\r\n }\r\n\r\n // Compare the sRGB values first.\r\n const sRgb = this.toStandardRgb();\r\n const otherSRgb = otherColor.toStandardRgb();\r\n\r\n let actualSimilarityPercent = calculateSimilarityPercent(\r\n sRgb.red, sRgb.green, sRgb.blue,\r\n otherSRgb.red, otherSRgb.green, otherSRgb.blue,\r\n 1);\r\n\r\n if (actualSimilarityPercent >= similarityPercent) {\r\n return true;\r\n }\r\n // Only fallback to comparing RGB values if the previous result was close (within 5%).\r\n else if (similarityPercent - actualSimilarityPercent <= 0.05) {\r\n actualSimilarityPercent = calculateSimilarityPercent(\r\n this.r, this.g, this.b,\r\n otherColor.r, otherColor.g, otherColor.b,\r\n 255);\r\n\r\n return actualSimilarityPercent >= similarityPercent;\r\n }\r\n else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sRGB value of this color.\r\n *\r\n * @returns This color in the standard RGB color space.\r\n */\r\n private toStandardRgb(): { red: number, green: number, blue: number } {\r\n const linearR = this.r / 255;\r\n const linearG = this.g / 255;\r\n const linearB = this.b / 255;\r\n\r\n const red = (linearR <= 0.03928) ? linearR / 12.92 : Math.pow((linearR + 0.055) / 1.055, 2.4);\r\n const green = (linearG <= 0.03928) ? linearG / 12.92 : Math.pow((linearG + 0.055) / 1.055, 2.4);\r\n const blue = (linearB <= 0.03928) ? linearB / 12.92 : Math.pow((linearB + 0.055) / 1.055, 2.4);\r\n\r\n return { red, green, blue };\r\n }\r\n\r\n // #endregion\r\n}\r\n"],"names":["html4Colors","Map","html4ColorsReverse","forEach","value","key","has","set","normalize","minimum","maximum","qqhToRgb","q1","q2","hue","parseHexValue","hex","parseInt","isNaN","parseHexString","startsWith","substring","length","repeat","asFloat","str","num","parseFloat","RockColor","alpha","alphaInternal","r","rgbInternal","updateHslFromRgb","g","b","luma","_this$toStandardRgb","toStandardRgb","red","green","blue","hueInternal","updateRgbFromHsl","saturation","saturationInternal","luminosity","luminosityInternal","toHex","isLight","isDark","constructor","p1","p2","p3","p4","p5","_defineProperty","constructFromSingleNumber","constructFromRgb","textInternal","constructFromString","color","rgba","parts","replace","split","trim","namedColor","getColorFromKeyword","rgb","max","Math","min","diff","abs","redDist","greenDist","blueDist","round","keyword","get","undefined","calculateContrastRatio","color1","color2","l1","l2","calculateColorPair","colorScheme","arguments","ColorScheme","Light","foregroundColor","calculateColorRecipe","ColorRecipe","Darkest","backgroundColor","Lightest","colorPair","ColorPair","Dark","flip","recipe","recipeColor","clone","recipeSaturation","recipeLuminosity","Medium","Primary","lighten","percentage","darken","saturate","desaturate","fadeIn","fadeOut","adjustHueByPercent","adjustHueByDegrees","degrees","tint","mix","shade","mixColor","amount","grayscale","toRgba","concat","floor","toString","padStart","a","valueOf","compareTo","otherColor","isSimilarTo","similarityPercent","calculateWeightedColorDistance","r1","g1","b1","r2","g2","b2","maxColorValue","redDiffSquared","pow","greenDiffSquared","blueDiffSquared","redAverage","redAveragePercentage","sqrt","calculateSimilarityPercent","maxDistance","colorDistance","sRgb","otherSRgb","actualSimilarityPercent","linearR","linearG","linearB"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BA,IAAMA,WAAgC,GAAG,IAAIC,GAAG,CAAC,CAC7C,CAAC,WAAW,EAAE,QAAQ,CAAC,EACvB,CAAC,cAAc,EAAE,QAAQ,CAAC,EAC1B,CAAC,MAAM,EAAE,QAAQ,CAAC,EAClB,CAAC,YAAY,EAAE,QAAQ,CAAC,EACxB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EACpB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAC5B,CAAC,MAAM,EAAE,QAAQ,CAAC,EAClB,CAAC,YAAY,EAAE,QAAQ,CAAC,EACxB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnB,CAAC,WAAW,EAAE,QAAQ,CAAC,EACvB,CAAC,WAAW,EAAE,QAAQ,CAAC,EACvB,CAAC,YAAY,EAAE,QAAQ,CAAC,EACxB,CAAC,WAAW,EAAE,QAAQ,CAAC,EACvB,CAAC,OAAO,EAAE,QAAQ,CAAC,EACnB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAC5B,CAAC,UAAU,EAAE,QAAQ,CAAC,EACtB,CA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