UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

1 lines 54.2 kB
{"version":3,"file":"Color.mjs","sources":["../../src/color/Color.ts"],"sourcesContent":["import { colord, extend } from '@pixi/colord';\nimport namesPlugin from '@pixi/colord/plugins/names';\n\nimport type { AnyColor, HslaColor, HslColor, HsvaColor, HsvColor, RgbaColor, RgbColor } from '@pixi/colord';\n\nextend([namesPlugin]);\n\n/**\n * Array of RGBA color components, where each component is a number between 0 and 1.\n * The array must contain exactly 4 numbers in the order: red, green, blue, alpha.\n * @example\n * ```ts\n * // Full white (opaque)\n * const white: RgbaArray = [1, 1, 1, 1];\n *\n * // Semi-transparent red\n * const transparentRed: RgbaArray = [1, 0, 0, 0.5];\n * ```\n * @remarks\n * - All components must be between 0 and 1\n * - Array must contain exactly 4 values\n * - Order is [red, green, blue, alpha]\n * @see {@link Color} For the main color utility class\n * @category color\n * @standard\n */\nexport type RgbaArray = [number, number, number, number];\n\n/**\n * Valid color formats supported by PixiJS. These types extend from [colord](https://www.npmjs.com/package/colord)\n * with additional PixiJS-specific formats.\n *\n * Common Formats:\n * ```ts\n * // CSS Color Names\n * new Color('red');\n * new Color('blue');\n * new Color('green');\n *\n * // Hex Values\n * new Color(0xff0000); // RGB integer\n * new Color('#ff0000'); // 6-digit hex\n * new Color('#f00'); // 3-digit hex\n * new Color('#ff0000ff'); // 8-digit hex (with alpha)\n * new Color('#f00f'); // 4-digit hex (with alpha)\n *\n * // RGB/RGBA Objects\n * new Color({ r: 255, g: 0, b: 0 });\n * new Color({ r: 255, g: 0, b: 0, a: 0.5 });\n *\n * // RGB/RGBA Strings\n * new Color('rgb(255, 0, 0)');\n * new Color('rgba(255, 0, 0, 0.5)');\n * new Color('rgb(100% 0% 0%)');\n * new Color('rgba(100% 0% 0% / 50%)');\n *\n * // Arrays (normalized 0-1)\n * new Color([1, 0, 0]); // RGB\n * new Color([1, 0, 0, 0.5]); // RGBA\n * new Color(new Float32Array([1, 0, 0, 0.5]));\n *\n * // Arrays (0-255)\n * new Color(new Uint8Array([255, 0, 0]));\n * new Color(new Uint8ClampedArray([255, 0, 0, 128]));\n *\n * // HSL/HSLA\n * new Color({ h: 0, s: 100, l: 50 });\n * new Color({ h: 0, s: 100, l: 50, a: 0.5 });\n * new Color('hsl(0, 100%, 50%)');\n * new Color('hsla(0deg 100% 50% / 50%)');\n *\n * // HSV/HSVA\n * new Color({ h: 0, s: 100, v: 100 });\n * new Color({ h: 0, s: 100, v: 100, a: 0.5 });\n * ```\n * @remarks\n * - All color values are normalized internally to 0-1 range\n * - Alpha is always between 0-1\n * - Invalid colors will throw an error\n * - Original format is preserved when possible\n * @see {@link Color} For the main color utility class\n * @see {@link https://www.w3.org/TR/css-color-4} CSS Color Level 4 Specification\n * @since 7.2.0\n * @category color\n * @standard\n */\nexport type ColorSource =\n | string\n | number\n | number[]\n | Float32Array\n | Uint8Array\n | Uint8ClampedArray\n | HslColor\n | HslaColor\n | HsvColor\n | HsvaColor\n | RgbColor\n | RgbaColor\n | Color\n | number;\n\ntype ColorSourceTypedArray = Float32Array | Uint8Array | Uint8ClampedArray;\n\n/**\n * Color utility class for managing colors in various formats. Provides a unified way to work\n * with colors across your PixiJS application.\n *\n * Features:\n * - Accepts multiple color formats (hex, RGB, HSL, etc.)\n * - Automatic format conversion\n * - Color manipulation methods\n * - Component access (r,g,b,a)\n * - Chainable operations\n * @example\n * ```js\n * import { Color } from 'pixi.js';\n *\n * new Color('red').toArray(); // [1, 0, 0, 1]\n * new Color(0xff0000).toArray(); // [1, 0, 0, 1]\n * new Color('ff0000').toArray(); // [1, 0, 0, 1]\n * new Color('#f00').toArray(); // [1, 0, 0, 1]\n * new Color('0xff0000ff').toArray(); // [1, 0, 0, 1]\n * new Color('#f00f').toArray(); // [1, 0, 0, 1]\n * new Color({ r: 255, g: 0, b: 0, a: 0.5 }).toArray(); // [1, 0, 0, 0.5]\n * new Color('rgb(255, 0, 0, 0.5)').toArray(); // [1, 0, 0, 0.5]\n * new Color([1, 1, 1]).toArray(); // [1, 1, 1, 1]\n * new Color([1, 0, 0, 0.5]).toArray(); // [1, 0, 0, 0.5]\n * new Color(new Float32Array([1, 0, 0, 0.5])).toArray(); // [1, 0, 0, 0.5]\n * new Color(new Uint8Array([255, 0, 0, 255])).toArray(); // [1, 0, 0, 1]\n * new Color(new Uint8ClampedArray([255, 0, 0, 255])).toArray(); // [1, 0, 0, 1]\n * new Color({ h: 0, s: 100, l: 50, a: 0.5 }).toArray(); // [1, 0, 0, 0.5]\n * new Color('hsl(0, 100%, 50%, 50%)').toArray(); // [1, 0, 0, 0.5]\n * new Color({ h: 0, s: 100, v: 100, a: 0.5 }).toArray(); // [1, 0, 0, 0.5]\n *\n * // Convert between formats\n * const color = new Color('red');\n * color.toHex(); // \"#ff0000\"\n * color.toRgbString(); // \"rgb(255,0,0,1)\"\n * color.toNumber(); // 0xff0000\n *\n * // Access components\n * color.red; // 1\n * color.green; // 0\n * color.blue; // 0\n * color.alpha; // 1\n *\n * // Chain operations\n * color\n * .setAlpha(0.5)\n * .multiply([0.5, 0.5, 0.5])\n * .premultiply(0.8);\n * ```\n * @remarks\n * The Color class automatically normalizes all color values internally:\n * - RGB components are stored as floats between 0-1\n * - Alpha is always between 0-1\n * - Color operations clamp values to valid ranges\n * - Original input format is preserved when possible\n * @since 7.2.0\n * @category color\n * @standard\n */\nexport class Color\n{\n /**\n * Static shared Color instance used for utility operations. This is a singleton color object\n * that can be reused to avoid creating unnecessary Color instances.\n * > [!IMPORTANT] You should be careful when using this shared instance, as it is mutable and can be\n * > changed by any code that uses it.\n * >\n * > It is best used for one-off color operations or temporary transformations.\n * > For persistent colors, create your own Color instance instead.\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Use shared instance for one-off color operations\n * Color.shared.setValue(0xff0000);\n * const redHex = Color.shared.toHex(); // \"#ff0000\"\n * const redRgb = Color.shared.toRgbArray(); // [1, 0, 0]\n *\n * // Temporary color transformations\n * const colorNumber = Color.shared\n * .setValue('#ff0000') // Set to red\n * .setAlpha(0.5) // Make semi-transparent\n * .premultiply(0.8) // Apply premultiplication\n * .toNumber(); // Convert to number\n *\n * // Chain multiple operations\n * const result = Color.shared\n * .setValue(someColor)\n * .multiply(tintColor)\n * .toPremultiplied(alpha);\n * ```\n * @remarks\n * - This is a shared instance - be careful about multiple code paths using it simultaneously\n * - Use for temporary color operations to avoid allocating new Color instances\n * - The value is preserved between operations, so reset if needed\n * - For persistent colors, create your own Color instance instead\n */\n public static readonly shared = new Color();\n\n /**\n * Temporary Color object for static uses internally.\n * As to not conflict with Color.shared.\n * @ignore\n */\n private static readonly _temp = new Color();\n\n /** Pattern for hex strings */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private static readonly HEX_PATTERN = /^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;\n\n /** Internal color source, from constructor or set value */\n private _value: Exclude<ColorSource, Color> | null;\n\n /** Normalized rgba component, floats from 0-1 */\n private _components: Float32Array;\n\n /** Cache color as number */\n private _int: number;\n\n /** An array of the current Color. Only populated when `toArray` functions are called */\n private _arrayRgba: number[] | null;\n private _arrayRgb: number[] | null;\n\n /**\n * @param {ColorSource} value - Optional value to use, if not provided, white is used.\n */\n constructor(value: ColorSource = 0xffffff)\n {\n this._value = null;\n this._components = new Float32Array(4);\n this._components.fill(1);\n this._int = 0xffffff;\n this.value = value;\n }\n\n /**\n * Get the red component of the color, normalized between 0 and 1.\n * @example\n * ```ts\n * const color = new Color('red');\n * console.log(color.red); // 1\n *\n * const green = new Color('#00ff00');\n * console.log(green.red); // 0\n * ```\n */\n get red(): number\n {\n return this._components[0];\n }\n\n /**\n * Get the green component of the color, normalized between 0 and 1.\n * @example\n * ```ts\n * const color = new Color('lime');\n * console.log(color.green); // 1\n *\n * const red = new Color('#ff0000');\n * console.log(red.green); // 0\n * ```\n */\n get green(): number\n {\n return this._components[1];\n }\n\n /**\n * Get the blue component of the color, normalized between 0 and 1.\n * @example\n * ```ts\n * const color = new Color('blue');\n * console.log(color.blue); // 1\n *\n * const yellow = new Color('#ffff00');\n * console.log(yellow.blue); // 0\n * ```\n */\n get blue(): number\n {\n return this._components[2];\n }\n\n /**\n * Get the alpha component of the color, normalized between 0 and 1.\n * @example\n * ```ts\n * const color = new Color('red');\n * console.log(color.alpha); // 1 (fully opaque)\n *\n * const transparent = new Color('rgba(255, 0, 0, 0.5)');\n * console.log(transparent.alpha); // 0.5 (semi-transparent)\n * ```\n */\n get alpha(): number\n {\n return this._components[3];\n }\n\n /**\n * Sets the color value and returns the instance for chaining.\n *\n * This is a chainable version of setting the `value` property.\n * @param value - The color to set. Accepts various formats:\n * - Hex strings/numbers (e.g., '#ff0000', 0xff0000)\n * - RGB/RGBA values (arrays, objects)\n * - CSS color names\n * - HSL/HSLA values\n * - HSV/HSVA values\n * @returns The Color instance for chaining\n * @example\n * ```ts\n * // Basic usage\n * const color = new Color();\n * color.setValue('#ff0000')\n * .setAlpha(0.5)\n * .premultiply(0.8);\n *\n * // Different formats\n * color.setValue(0xff0000); // Hex number\n * color.setValue('#ff0000'); // Hex string\n * color.setValue([1, 0, 0]); // RGB array\n * color.setValue([1, 0, 0, 0.5]); // RGBA array\n * color.setValue({ r: 1, g: 0, b: 0 }); // RGB object\n *\n * // Copy from another color\n * const red = new Color('red');\n * color.setValue(red);\n * ```\n * @throws {Error} If the color value is invalid or null\n * @see {@link Color.value} For the underlying value property\n */\n public setValue(value: ColorSource): this\n {\n this.value = value;\n\n return this;\n }\n\n /**\n * The current color source. This property allows getting and setting the color value\n * while preserving the original format where possible.\n * @remarks\n * When setting:\n * - Setting to a `Color` instance copies its source and components\n * - Setting to other valid sources normalizes and stores the value\n * - Setting to `null` throws an Error\n * - The color remains unchanged if normalization fails\n *\n * When getting:\n * - Returns `null` if color was modified by {@link Color.multiply} or {@link Color.premultiply}\n * - Otherwise returns the original color source\n * @example\n * ```ts\n * // Setting different color formats\n * const color = new Color();\n *\n * color.value = 0xff0000; // Hex number\n * color.value = '#ff0000'; // Hex string\n * color.value = [1, 0, 0]; // RGB array\n * color.value = [1, 0, 0, 0.5]; // RGBA array\n * color.value = { r: 1, g: 0, b: 0 }; // RGB object\n *\n * // Copying from another color\n * const red = new Color('red');\n * color.value = red; // Copies red's components\n *\n * // Getting the value\n * console.log(color.value); // Returns original format\n *\n * // After modifications\n * color.multiply([0.5, 0.5, 0.5]);\n * console.log(color.value); // Returns null\n * ```\n * @throws {Error} When attempting to set `null`\n */\n set value(value: ColorSource | null)\n {\n // Support copying from other Color objects\n if (value instanceof Color)\n {\n this._value = this._cloneSource(value._value);\n this._int = value._int;\n this._components.set(value._components);\n }\n else if (value === null)\n {\n throw new Error('Cannot set Color#value to null');\n }\n else if (this._value === null || !this._isSourceEqual(this._value, value))\n {\n this._value = this._cloneSource(value);\n this._normalize(this._value);\n }\n }\n get value(): Exclude<ColorSource, Color> | null\n {\n return this._value;\n }\n\n /**\n * Copy a color source internally.\n * @param value - Color source\n */\n private _cloneSource(value: Exclude<ColorSource, Color> | null): Exclude<ColorSource, Color> | null\n {\n if (typeof value === 'string' || typeof value === 'number' || value instanceof Number || value === null)\n {\n return value;\n }\n else if (Array.isArray(value) || ArrayBuffer.isView(value))\n {\n return value.slice(0);\n }\n else if (typeof value === 'object' && value !== null)\n {\n return { ...value };\n }\n\n return value;\n }\n\n /**\n * Equality check for color sources.\n * @param value1 - First color source\n * @param value2 - Second color source\n * @returns `true` if the color sources are equal, `false` otherwise.\n */\n private _isSourceEqual(value1: Exclude<ColorSource, Color>, value2: Exclude<ColorSource, Color>): boolean\n {\n const type1 = typeof value1;\n const type2 = typeof value2;\n\n // Mismatched types\n if (type1 !== type2)\n {\n return false;\n }\n // Handle numbers/strings and things that extend Number\n // important to do the instanceof Number first, as this is \"object\" type\n else if (type1 === 'number' || type1 === 'string' || value1 instanceof Number)\n {\n return value1 === value2;\n }\n // Handle Arrays and TypedArrays\n else if (\n (Array.isArray(value1) && Array.isArray(value2))\n || (ArrayBuffer.isView(value1) && ArrayBuffer.isView(value2))\n )\n {\n if (value1.length !== value2.length)\n {\n return false;\n }\n\n return value1.every((v, i) => v === value2[i]);\n }\n // Handle Objects\n else if (value1 !== null && value2 !== null)\n {\n const keys1 = Object.keys(value1) as (keyof typeof value1)[];\n const keys2 = Object.keys(value2) as (keyof typeof value2)[];\n\n if (keys1.length !== keys2.length)\n {\n return false;\n }\n\n return keys1.every((key) => value1[key] === value2[key]);\n }\n\n return value1 === value2;\n }\n\n /**\n * Convert to a RGBA color object with normalized components (0-1).\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Convert colors to RGBA objects\n * new Color('white').toRgba(); // returns { r: 1, g: 1, b: 1, a: 1 }\n * new Color('#ff0000').toRgba(); // returns { r: 1, g: 0, b: 0, a: 1 }\n *\n * // With transparency\n * new Color('rgba(255,0,0,0.5)').toRgba(); // returns { r: 1, g: 0, b: 0, a: 0.5 }\n * ```\n * @returns An RGBA object with normalized components\n */\n public toRgba(): RgbaColor\n {\n const [r, g, b, a] = this._components;\n\n return { r, g, b, a };\n }\n\n /**\n * Convert to a RGB color object with normalized components (0-1).\n *\n * Alpha component is omitted in the output.\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Convert colors to RGB objects\n * new Color('white').toRgb(); // returns { r: 1, g: 1, b: 1 }\n * new Color('#ff0000').toRgb(); // returns { r: 1, g: 0, b: 0 }\n *\n * // Alpha is ignored\n * new Color('rgba(255,0,0,0.5)').toRgb(); // returns { r: 1, g: 0, b: 0 }\n * ```\n * @returns An RGB object with normalized components\n */\n public toRgb(): RgbColor\n {\n const [r, g, b] = this._components;\n\n return { r, g, b };\n }\n\n /**\n * Convert to a CSS-style rgba string representation.\n *\n * RGB components are scaled to 0-255 range, alpha remains 0-1.\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Convert colors to RGBA strings\n * new Color('white').toRgbaString(); // returns \"rgba(255,255,255,1)\"\n * new Color('#ff0000').toRgbaString(); // returns \"rgba(255,0,0,1)\"\n *\n * // With transparency\n * new Color([1, 0, 0, 0.5]).toRgbaString(); // returns \"rgba(255,0,0,0.5)\"\n * ```\n * @returns A CSS-compatible rgba string\n */\n public toRgbaString(): string\n {\n const [r, g, b] = this.toUint8RgbArray();\n\n return `rgba(${r},${g},${b},${this.alpha})`;\n }\n\n /**\n * Convert to an [R, G, B] array of clamped uint8 values (0 to 255).\n * @param {number[]|Uint8Array|Uint8ClampedArray} [out] - Optional output array. If not provided,\n * a cached array will be used and returned.\n * @returns Array containing RGB components as integers between 0-255\n * @example\n * ```ts\n * // Basic usage\n * new Color('white').toUint8RgbArray(); // returns [255, 255, 255]\n * new Color('#ff0000').toUint8RgbArray(); // returns [255, 0, 0]\n *\n * // Using custom output array\n * const rgb = new Uint8Array(3);\n * new Color('blue').toUint8RgbArray(rgb); // rgb is now [0, 0, 255]\n *\n * // Using different array types\n * new Color('red').toUint8RgbArray(new Uint8ClampedArray(3)); // [255, 0, 0]\n * new Color('red').toUint8RgbArray([]); // [255, 0, 0]\n * ```\n * @remarks\n * - Output values are always clamped between 0-255\n * - Alpha component is not included in output\n * - Reuses internal cache array if no output array provided\n */\n public toUint8RgbArray<T extends number[] | Uint8Array | Uint8ClampedArray = number[]>(out?: T): T\n {\n const [r, g, b] = this._components;\n\n if (!this._arrayRgb)\n {\n this._arrayRgb = [];\n }\n\n out ||= this._arrayRgb as T;\n\n out[0] = Math.round(r * 255);\n out[1] = Math.round(g * 255);\n out[2] = Math.round(b * 255);\n\n return out;\n }\n\n /**\n * Convert to an [R, G, B, A] array of normalized floats (numbers from 0.0 to 1.0).\n * @param {number[]|Float32Array} [out] - Optional output array. If not provided,\n * a cached array will be used and returned.\n * @returns Array containing RGBA components as floats between 0-1\n * @example\n * ```ts\n * // Basic usage\n * new Color('white').toArray(); // returns [1, 1, 1, 1]\n * new Color('red').toArray(); // returns [1, 0, 0, 1]\n *\n * // With alpha\n * new Color('rgba(255,0,0,0.5)').toArray(); // returns [1, 0, 0, 0.5]\n *\n * // Using custom output array\n * const rgba = new Float32Array(4);\n * new Color('blue').toArray(rgba); // rgba is now [0, 0, 1, 1]\n * ```\n * @remarks\n * - Output values are normalized between 0-1\n * - Includes alpha component as the fourth value\n * - Reuses internal cache array if no output array provided\n */\n public toArray<T extends number[] | Float32Array = number[]>(out?: T): T\n {\n if (!this._arrayRgba)\n {\n this._arrayRgba = [];\n }\n\n out ||= this._arrayRgba as T;\n const [r, g, b, a] = this._components;\n\n out[0] = r;\n out[1] = g;\n out[2] = b;\n out[3] = a;\n\n return out;\n }\n\n /**\n * Convert to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0).\n * @param {number[]|Float32Array} [out] - Optional output array. If not provided,\n * a cached array will be used and returned.\n * @returns Array containing RGB components as floats between 0-1\n * @example\n * ```ts\n * // Basic usage\n * new Color('white').toRgbArray(); // returns [1, 1, 1]\n * new Color('red').toRgbArray(); // returns [1, 0, 0]\n *\n * // Using custom output array\n * const rgb = new Float32Array(3);\n * new Color('blue').toRgbArray(rgb); // rgb is now [0, 0, 1]\n * ```\n * @remarks\n * - Output values are normalized between 0-1\n * - Alpha component is omitted from output\n * - Reuses internal cache array if no output array provided\n */\n public toRgbArray<T extends number[] | Float32Array = number[]>(out?: T): T\n {\n if (!this._arrayRgb)\n {\n this._arrayRgb = [];\n }\n\n out ||= this._arrayRgb as T;\n const [r, g, b] = this._components;\n\n out[0] = r;\n out[1] = g;\n out[2] = b;\n\n return out;\n }\n\n /**\n * Convert to a hexadecimal number.\n * @returns The color as a 24-bit RGB integer\n * @example\n * ```ts\n * // Basic usage\n * new Color('white').toNumber(); // returns 0xffffff\n * new Color('red').toNumber(); // returns 0xff0000\n *\n * // Store as hex\n * const color = new Color('blue');\n * const hex = color.toNumber(); // 0x0000ff\n * ```\n */\n public toNumber(): number\n {\n return this._int;\n }\n\n /**\n * Convert to a BGR number.\n *\n * Useful for platforms that expect colors in BGR format.\n * @returns The color as a 24-bit BGR integer\n * @example\n * ```ts\n * // Convert RGB to BGR\n * new Color(0xffcc99).toBgrNumber(); // returns 0x99ccff\n *\n * // Common use case: platform-specific color format\n * const color = new Color('orange');\n * const bgrColor = color.toBgrNumber(); // Color with swapped R/B channels\n * ```\n * @remarks\n * This swaps the red and blue channels compared to the normal RGB format:\n * - RGB 0xRRGGBB becomes BGR 0xBBGGRR\n */\n public toBgrNumber(): number\n {\n const [r, g, b] = this.toUint8RgbArray();\n\n return (b << 16) + (g << 8) + r;\n }\n\n /**\n * Convert to a hexadecimal number in little endian format (e.g., BBGGRR).\n *\n * Useful for platforms that expect colors in little endian byte order.\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Convert RGB color to little endian format\n * new Color(0xffcc99).toLittleEndianNumber(); // returns 0x99ccff\n *\n * // Common use cases:\n * const color = new Color('orange');\n * const leColor = color.toLittleEndianNumber(); // Swaps byte order for LE systems\n *\n * // Multiple conversions\n * const colors = {\n * normal: 0xffcc99,\n * littleEndian: new Color(0xffcc99).toLittleEndianNumber(), // 0x99ccff\n * backToNormal: new Color(0x99ccff).toLittleEndianNumber() // 0xffcc99\n * };\n * ```\n * @remarks\n * - Swaps R and B channels in the color value\n * - RGB 0xRRGGBB becomes 0xBBGGRR\n * - Useful for systems that use little endian byte order\n * - Can be used to convert back and forth between formats\n * @returns The color as a number in little endian format (BBGGRR)\n * @see {@link Color.toBgrNumber} For BGR format without byte swapping\n */\n public toLittleEndianNumber(): number\n {\n const value = this._int;\n\n return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);\n }\n\n /**\n * Multiply with another color.\n *\n * This action is destructive and modifies the original color.\n * @param {ColorSource} value - The color to multiply by. Accepts any valid color format:\n * - Hex strings/numbers (e.g., '#ff0000', 0xff0000)\n * - RGB/RGBA arrays ([1, 0, 0], [1, 0, 0, 1])\n * - Color objects ({ r: 1, g: 0, b: 0 })\n * - CSS color names ('red', 'blue')\n * @returns this - The Color instance for chaining\n * @example\n * ```ts\n * // Basic multiplication\n * const color = new Color('#ff0000');\n * color.multiply(0x808080); // 50% darker red\n *\n * // With transparency\n * color.multiply([1, 1, 1, 0.5]); // 50% transparent\n *\n * // Chain operations\n * color\n * .multiply('#808080')\n * .multiply({ r: 1, g: 1, b: 1, a: 0.5 });\n * ```\n * @remarks\n * - Multiplies each RGB component and alpha separately\n * - Values are clamped between 0-1\n * - Original color format is lost (value becomes null)\n * - Operation cannot be undone\n */\n public multiply(value: ColorSource): this\n {\n const [r, g, b, a] = Color._temp.setValue(value)._components;\n\n this._components[0] *= r;\n this._components[1] *= g;\n this._components[2] *= b;\n this._components[3] *= a;\n\n this._refreshInt();\n this._value = null;\n\n return this;\n }\n\n /**\n * Converts color to a premultiplied alpha format.\n *\n * This action is destructive and modifies the original color.\n * @param alpha - The alpha value to multiply by (0-1)\n * @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels\n * @returns {Color} The Color instance for chaining\n * @example\n * ```ts\n * // Basic premultiplication\n * const color = new Color('red');\n * color.premultiply(0.5); // 50% transparent red with premultiplied RGB\n *\n * // Alpha only (RGB unchanged)\n * color.premultiply(0.5, false); // 50% transparent, original RGB\n *\n * // Chain with other operations\n * color\n * .multiply(0x808080)\n * .premultiply(0.5)\n * .toNumber();\n * ```\n * @remarks\n * - RGB channels are multiplied by alpha when applyToRGB is true\n * - Alpha is always set to the provided value\n * - Values are clamped between 0-1\n * - Original color format is lost (value becomes null)\n * - Operation cannot be undone\n */\n public premultiply(alpha: number, applyToRGB = true): this\n {\n if (applyToRGB)\n {\n this._components[0] *= alpha;\n this._components[1] *= alpha;\n this._components[2] *= alpha;\n }\n this._components[3] = alpha;\n\n this._refreshInt();\n this._value = null;\n\n return this;\n }\n\n /**\n * Returns the color as a 32-bit premultiplied alpha integer.\n *\n * Format: 0xAARRGGBB\n * @param {number} alpha - The alpha value to multiply by (0-1)\n * @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels\n * @returns {number} The premultiplied color as a 32-bit integer\n * @example\n * ```ts\n * // Convert to premultiplied format\n * const color = new Color('red');\n *\n * // Full opacity (0xFFRRGGBB)\n * color.toPremultiplied(1.0); // 0xFFFF0000\n *\n * // 50% transparency with premultiplied RGB\n * color.toPremultiplied(0.5); // 0x7F7F0000\n *\n * // 50% transparency without RGB premultiplication\n * color.toPremultiplied(0.5, false); // 0x7FFF0000\n * ```\n * @remarks\n * - Returns full opacity (0xFF000000) when alpha is 1.0\n * - Returns 0 when alpha is 0.0 and applyToRGB is true\n * - RGB values are rounded during premultiplication\n */\n public toPremultiplied(alpha: number, applyToRGB = true): number\n {\n if (alpha === 1.0)\n {\n return (0xff << 24) + this._int;\n }\n if (alpha === 0.0)\n {\n return applyToRGB ? 0 : this._int;\n }\n let r = (this._int >> 16) & 0xff;\n let g = (this._int >> 8) & 0xff;\n let b = this._int & 0xff;\n\n if (applyToRGB)\n {\n r = ((r * alpha) + 0.5) | 0;\n g = ((g * alpha) + 0.5) | 0;\n b = ((b * alpha) + 0.5) | 0;\n }\n\n return ((alpha * 255) << 24) + (r << 16) + (g << 8) + b;\n }\n\n /**\n * Convert to a hexadecimal string (6 characters).\n * @returns A CSS-compatible hex color string (e.g., \"#ff0000\")\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Basic colors\n * new Color('red').toHex(); // returns \"#ff0000\"\n * new Color('white').toHex(); // returns \"#ffffff\"\n * new Color('black').toHex(); // returns \"#000000\"\n *\n * // From different formats\n * new Color(0xff0000).toHex(); // returns \"#ff0000\"\n * new Color([1, 0, 0]).toHex(); // returns \"#ff0000\"\n * new Color({ r: 1, g: 0, b: 0 }).toHex(); // returns \"#ff0000\"\n * ```\n * @remarks\n * - Always returns a 6-character hex string\n * - Includes leading \"#\" character\n * - Alpha channel is ignored\n * - Values are rounded to nearest hex value\n */\n public toHex(): string\n {\n const hexString = this._int.toString(16);\n\n return `#${'000000'.substring(0, 6 - hexString.length) + hexString}`;\n }\n\n /**\n * Convert to a hexadecimal string with alpha (8 characters).\n * @returns A CSS-compatible hex color string with alpha (e.g., \"#ff0000ff\")\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // Fully opaque colors\n * new Color('red').toHexa(); // returns \"#ff0000ff\"\n * new Color('white').toHexa(); // returns \"#ffffffff\"\n *\n * // With transparency\n * new Color('rgba(255, 0, 0, 0.5)').toHexa(); // returns \"#ff00007f\"\n * new Color([1, 0, 0, 0]).toHexa(); // returns \"#ff000000\"\n * ```\n * @remarks\n * - Returns an 8-character hex string\n * - Includes leading \"#\" character\n * - Alpha is encoded in last two characters\n * - Values are rounded to nearest hex value\n */\n public toHexa(): string\n {\n const alphaValue = Math.round(this._components[3] * 255);\n const alphaString = alphaValue.toString(16);\n\n return this.toHex() + '00'.substring(0, 2 - alphaString.length) + alphaString;\n }\n\n /**\n * Set alpha (transparency) value while preserving color components.\n *\n * Provides a chainable interface for setting alpha.\n * @param alpha - Alpha value between 0 (fully transparent) and 1 (fully opaque)\n * @returns The Color instance for chaining\n * @example\n * ```ts\n * // Basic alpha setting\n * const color = new Color('red');\n * color.setAlpha(0.5); // 50% transparent red\n *\n * // Chain with other operations\n * color\n * .setValue('#ff0000')\n * .setAlpha(0.8) // 80% opaque\n * .premultiply(0.5); // Further modify alpha\n *\n * // Reset to fully opaque\n * color.setAlpha(1);\n * ```\n * @remarks\n * - Alpha value is clamped between 0-1\n * - Can be chained with other color operations\n */\n public setAlpha(alpha: number): this\n {\n this._components[3] = this._clamp(alpha);\n\n return this;\n }\n\n /**\n * Normalize the input value into rgba\n * @param value - Input value\n */\n private _normalize(value: Exclude<ColorSource, Color>): void\n {\n let r: number | undefined;\n let g: number | undefined;\n let b: number | undefined;\n let a: number | undefined;\n\n // Number is a primitive so typeof works fine, but in the case\n // that someone creates a class that extends Number, we also\n // need to check for instanceof Number\n if (\n (typeof value === 'number' || value instanceof Number)\n && (value as number) >= 0\n && (value as number) <= 0xffffff\n )\n {\n const int = value as number; // cast required because instanceof Number is ambiguous for TS\n\n r = ((int >> 16) & 0xff) / 255;\n g = ((int >> 8) & 0xff) / 255;\n b = (int & 0xff) / 255;\n a = 1.0;\n }\n else if (\n (Array.isArray(value) || value instanceof Float32Array)\n // Can be rgb or rgba\n && value.length >= 3\n && value.length <= 4\n )\n {\n // make sure all values are 0 - 1\n value = this._clamp(value);\n [r, g, b, a = 1.0] = value;\n }\n else if (\n (value instanceof Uint8Array || value instanceof Uint8ClampedArray)\n // Can be rgb or rgba\n && value.length >= 3\n && value.length <= 4\n )\n {\n // make sure all values are 0 - 255\n value = this._clamp(value, 0, 255);\n [r, g, b, a = 255] = value;\n r /= 255;\n g /= 255;\n b /= 255;\n a /= 255;\n }\n else if (typeof value === 'string' || typeof value === 'object')\n {\n if (typeof value === 'string')\n {\n const match = Color.HEX_PATTERN.exec(value);\n\n if (match)\n {\n // Normalize hex string, remove 0x or # prefix\n value = `#${match[2]}`;\n }\n }\n\n const color = colord(value as AnyColor);\n\n if (color.isValid())\n {\n ({ r, g, b, a } = color.rgba);\n r /= 255;\n g /= 255;\n b /= 255;\n }\n }\n\n // Cache normalized values for rgba and hex integer\n if (r !== undefined)\n {\n this._components[0] = r as number;\n this._components[1] = g as number;\n this._components[2] = b as number;\n this._components[3] = a as number;\n this._refreshInt();\n }\n else\n {\n throw new Error(`Unable to convert color ${value}`);\n }\n }\n\n /** Refresh the internal color rgb number */\n private _refreshInt(): void\n {\n // Clamp values to 0 - 1\n this._clamp(this._components);\n\n const [r, g, b] = this._components;\n\n this._int = ((r * 255) << 16) + ((g * 255) << 8) + ((b * 255) | 0);\n }\n\n /**\n * Clamps values to a range. Will override original values\n * @param value - Value(s) to clamp\n * @param min - Minimum value\n * @param max - Maximum value\n */\n private _clamp<T extends number | number[] | ColorSourceTypedArray>(value: T, min = 0, max = 1): T\n {\n if (typeof value === 'number')\n {\n return Math.min(Math.max(value, min), max) as T;\n }\n\n value.forEach((v, i) =>\n {\n value[i] = Math.min(Math.max(v, min), max);\n });\n\n return value;\n }\n\n /**\n * Check if a value can be interpreted as a valid color format.\n * Supports all color formats that can be used with the Color class.\n * @param value - Value to check\n * @returns True if the value can be used as a color\n * @example\n * ```ts\n * import { Color } from 'pixi.js';\n *\n * // CSS colors and hex values\n * Color.isColorLike('red'); // true\n * Color.isColorLike('#ff0000'); // true\n * Color.isColorLike(0xff0000); // true\n *\n * // Arrays (RGB/RGBA)\n * Color.isColorLike([1, 0, 0]); // true\n * Color.isColorLike([1, 0, 0, 0.5]); // true\n *\n * // TypedArrays\n * Color.isColorLike(new Float32Array([1, 0, 0])); // true\n * Color.isColorLike(new Uint8Array([255, 0, 0])); // true\n * Color.isColorLike(new Uint8ClampedArray([255, 0, 0])); // true\n *\n * // Object formats\n * Color.isColorLike({ r: 1, g: 0, b: 0 }); // true (RGB)\n * Color.isColorLike({ r: 1, g: 0, b: 0, a: 0.5 }); // true (RGBA)\n * Color.isColorLike({ h: 0, s: 100, l: 50 }); // true (HSL)\n * Color.isColorLike({ h: 0, s: 100, l: 50, a: 0.5 }); // true (HSLA)\n * Color.isColorLike({ h: 0, s: 100, v: 100 }); // true (HSV)\n * Color.isColorLike({ h: 0, s: 100, v: 100, a: 0.5 });// true (HSVA)\n *\n * // Color instances\n * Color.isColorLike(new Color('red')); // true\n *\n * // Invalid values\n * Color.isColorLike(null); // false\n * Color.isColorLike(undefined); // false\n * Color.isColorLike({}); // false\n * Color.isColorLike([]); // false\n * Color.isColorLike('not-a-color'); // false\n * ```\n * @remarks\n * Checks for the following formats:\n * - Numbers (0x000000 to 0xffffff)\n * - CSS color strings\n * - RGB/RGBA arrays and objects\n * - HSL/HSLA objects\n * - HSV/HSVA objects\n * - TypedArrays (Float32Array, Uint8Array, Uint8ClampedArray)\n * - Color instances\n * @see {@link ColorSource} For supported color format types\n * @see {@link Color.setValue} For setting color values\n * @category utility\n */\n public static isColorLike(value: unknown): value is ColorSource\n {\n return (\n typeof value === 'number'\n || typeof value === 'string'\n || value instanceof Number\n || value instanceof Color\n || Array.isArray(value)\n || value instanceof Uint8Array\n || value instanceof Uint8ClampedArray\n || value instanceof Float32Array\n || ((value as RgbColor).r !== undefined\n && (value as RgbColor).g !== undefined\n && (value as RgbColor).b !== undefined)\n || ((value as RgbaColor).r !== undefined\n && (value as RgbaColor).g !== undefined\n && (value as RgbaColor).b !== undefined\n && (value as RgbaColor).a !== undefined)\n || ((value as HslColor).h !== undefined\n && (value as HslColor).s !== undefined\n && (value as HslColor).l !== undefined)\n || ((value as HslaColor).h !== undefined\n && (value as HslaColor).s !== undefined\n && (value as HslaColor).l !== undefined\n && (value as HslaColor).a !== undefined)\n || ((value as HsvColor).h !== undefined\n && (value as HsvColor).s !== undefined\n && (value as HsvColor).v !== undefined)\n || ((value as HsvaColor).h !== undefined\n && (value as HsvaColor).s !== undefined\n && (value as HsvaColor).v !== undefined\n && (value as HsvaColor).a !== undefined)\n );\n }\n}\n"],"names":[],"mappings":";;;;AAKA,MAAO,CAAA,CAAC,WAAW,CAAC,CAAA,CAAA;AA8Jb,MAAM,MAAA,GAAN,MAAM,MACb,CAAA;AAAA;AAAA;AAAA;AAAA,EAkEI,WAAA,CAAY,QAAqB,QACjC,EAAA;AACI,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AACd,IAAK,IAAA,CAAA,WAAA,GAAc,IAAI,YAAA,CAAa,CAAC,CAAA,CAAA;AACrC,IAAK,IAAA,CAAA,WAAA,CAAY,KAAK,CAAC,CAAA,CAAA;AACvB,IAAA,IAAA,CAAK,IAAO,GAAA,QAAA,CAAA;AACZ,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AAAA,GACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,IAAI,GACJ,GAAA;AACI,IAAO,OAAA,IAAA,CAAK,YAAY,CAAC,CAAA,CAAA;AAAA,GAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AA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