PokéRogue
    Preparing search index...

    A mutable color representation that stores RGBA values (0-255 range) with automatic conversion to WebGL-compatible normalized floats (0-1), HSV color space, CSS rgba strings, and packed 24/32-bit integer formats. Provides methods for color manipulation including saturation, lightness, brightness adjustments, grayscale, and randomization. Supports construction from RGB integers, hex strings, HSV values, or color objects. Used throughout Phaser for tinting, effects, and rendering.

    Index
    • Parameters

      • Optionalred: number

        The red color value. A number between 0 and 255. Default 0.

      • Optionalgreen: number

        The green color value. A number between 0 and 255. Default 0.

      • Optionalblue: number

        The blue color value. A number between 0 and 255. Default 0.

      • Optionalalpha: number

        The alpha value. A number between 0 and 255. Default 255.

      Returns Color

    alpha: number

    The alpha color value, in the range 0 to 255.

    alphaGL: number

    The alpha color value, normalized to the range 0 to 1.

    blue: number

    The blue color value, in the range 0 to 255.

    blueGL: number

    The blue color value, normalized to the range 0 to 1.

    color: number

    The packed 24-bit RGB integer representation of this color, not including the alpha channel.

    color32: number

    The packed 32-bit RGBA integer representation of this color, including the alpha channel.

    gl: number[]

    An array containing the RGBA color components in WebGL-compatible normalized float format, stored as [red, green, blue, alpha] with each value in the range 0 to 1.

    green: number

    The green color value, in the range 0 to 255.

    greenGL: number

    The green color value, normalized to the range 0 to 1.

    h: number

    The hue color value. A number between 0 and 1. This is the base color.

    red: number

    The red color value, in the range 0 to 255.

    redGL: number

    The red color value, normalized to the range 0 to 1.

    rgba: string

    The color of this Color object as a CSS-compatible rgba() string, suitable for use with Canvas 2D or HTML elements.

    s: number

    The saturation color value. A number between 0 and 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white.

    v: number

    The value (brightness) component of this color in the HSV color space. A number between 0 and 1, where 1 is fully bright and 0 is black.

    • Brighten this Color by the percentage amount given.

      Parameters

      • amount: number

        The percentage amount to change this color by. A value between 0 and 100.

      Returns Color

      This Color object.

    • Returns a new Color component using the values from this one.undefined

      Returns Color

      A new Color object.

    • Decrease the lightness of this Color by the percentage amount given.

      Parameters

      • amount: number

        The percentage amount to change this color by. A value between 0 and 100.

      Returns Color

      This Color object.

    • Decrease the saturation of this Color by the percentage amount given. The saturation is the amount of the base color in the hue.

      Parameters

      • amount: number

        The percentage amount to change this color by. A value between 0 and 100.

      Returns Color

      This Color object.

    • Sets this Color object to be grayscaled based on the shade value given.

      Parameters

      • shade: number

        A value between 0 and 255.

      Returns Color

      This Color object.

    • Increase the lightness of this Color by the percentage amount given.

      Parameters

      • amount: number

        The percentage amount to change this color by. A value between 0 and 100.

      Returns Color

      This Color object.

    • Sets this Color object to be a random color between the min and max values given.

      Parameters

      • Optionalmin: number

        The minimum random color value. Between 0 and 255. Default 0.

      • Optionalmax: number

        The maximum random color value. Between 0 and 255. Default 255.

      Returns Color

      This Color object.

    • Sets this Color object to be a random grayscale color between the min and max values given.

      Parameters

      • Optionalmin: number

        The minimum random color value. Between 0 and 255. Default 0.

      • Optionalmax: number

        The maximum random color value. Between 0 and 255. Default 255.

      Returns Color

      This Color object.

    • Increase the saturation of this Color by the percentage amount given. The saturation is the amount of the base color in the hue.

      Parameters

      • amount: number

        The percentage amount to change this color by. A value between 0 and 100.

      Returns Color

      This Color object.

    • Sets the color based on the hue, saturation and value (HSV) components given.

      Parameters

      • h: number

        The hue, in the range 0 - 1. This is the base color.

      • s: number

        The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white.

      • v: number

        The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black.

      Returns Color

      This Color object.

    • Sets the color based on the color object given.

      Parameters

      • color: InputColorObject

        An object containing r, g, b and optionally a values in the range 0 to 255.

      Returns Color

      This Color object.

    • Sets the red, green, blue and alpha GL values of this Color component.

      Parameters

      • red: number

        The red color value. A number between 0 and 1.

      • green: number

        The green color value. A number between 0 and 1.

      • blue: number

        The blue color value. A number between 0 and 1.

      • Optionalalpha: number

        The alpha value. A number between 0 and 1. Default 1.

      Returns Color

      This Color object.

    • Sets the color of this Color component.

      Parameters

      • red: number

        The red color value. A number between 0 and 255.

      • green: number

        The green color value. A number between 0 and 255.

      • blue: number

        The blue color value. A number between 0 and 255.

      • Optionalalpha: number

        The alpha value. A number between 0 and 255. Default 255.

      • OptionalupdateHSV: boolean

        Update the HSV values after setting the RGB values? Default true.

      Returns Color

      This Color object.

    • Sets this color to be transparent. Sets all values to zero.undefined

      Returns Color

      This Color object.

    • Returns an array of Color Objects representing a full color spectrum.

      The spectrum colors cycle through the hue wheel in the order: red, yellow, green, cyan, blue, violet, and back to red.

      By default this function will return an array with 1024 elements.

      However, you can reduce this to a smaller quantity if needed, by specifying the limit parameter. When a limit smaller than 1024 is given, the colors are sampled evenly across the full spectrum so the hue distribution remains uniform regardless of the array size.

      Parameters

      • Optionallimit: number

        How many colors should be returned? The maximum is 1024 but you can set a smaller quantity if required. Default 1024.

      Returns ColorObject[]

      An array containing limit parameter number of elements, where each contains a Color Object.

    • Converts the given color value into an object containing r, g, b and a properties.

      The color value can be a 24-bit RGB integer (e.g. 0xRRGGBB) or a 32-bit ARGB integer (e.g. 0xAARRGGBB). If the value is 24-bit (i.e. does not exceed 0xFFFFFF), the alpha component of the returned object defaults to 255 (fully opaque). Otherwise, the alpha is extracted from the upper 8 bits of the value.

      Parameters

      • color: number

        A 24-bit RGB or 32-bit ARGB color integer, optionally including an alpha component in the most-significant byte.

      Returns ColorObject

      An object containing the parsed color values.

    • Returns a string containing a hex representation of the given color component.

      Parameters

      • color: number

        The color channel to get the hex value for, must be a value between 0 and 255.

      Returns string

      A string of length 2 characters, i.e. 255 = ff, 100 = 64.

    • Packs three separate red, green, and blue color component values into a single 24-bit integer in the format 0xRRGGBB.

      Parameters

      • red: number

        The red color value. A number between 0 and 255.

      • green: number

        The green color value. A number between 0 and 255.

      • blue: number

        The blue color value. A number between 0 and 255.

      Returns number

      The packed color value as a 24-bit integer in the format 0xRRGGBB.

    • Packs four ARGB component values (red, green, blue, and alpha) into a single 32-bit integer in ARGB format.

      Parameters

      • red: number

        The red color value. A number between 0 and 255.

      • green: number

        The green color value. A number between 0 and 255.

      • blue: number

        The blue color value. A number between 0 and 255.

      • alpha: number

        The alpha color value. A number between 0 and 255.

      Returns number

      The packed 32-bit ARGB color value.

    • Converts a hex string into a Phaser Color object.

      The hex string can be supplied as '#0033ff' or the short-hand format of '#03f'; it can begin with an optional "#" or "0x", or be unprefixed.

      An alpha channel is not supported.

      Parameters

      • hex: string

        The hex color value to convert, such as #0033ff or the short-hand format: #03f.

      • Optionalcolor: Color

        The color where the new color will be stored. If not defined, a new color object is returned.

      Returns Color

      A Color object populated by the values of the given string.

    • Converts HSL (hue, saturation and lightness) values to a Phaser Color object.

      All three input values should be in the range 0 to 1. If the saturation is 0 the color is treated as achromatic (greyscale). Otherwise the standard HSL-to-RGB algorithm is applied, using the lightness value to derive the intermediate q and p coefficients before delegating each channel to HueToComponent.

      Parameters

      • h: number

        The hue value in the range 0 to 1.

      • s: number

        The saturation value in the range 0 to 1.

      • l: number

        The lightness value in the range 0 to 1.

      • Optionalcolor: Color

        An optional Color object to populate with the converted values. If not provided, a new Color object is created and returned.

      Returns Color

      The Color object populated with the RGB values derived from the given h, s and l inputs. This is either the color argument (if provided) or a newly created Color object.

    • Generates an HSV color wheel as an array of 360 ColorObject entries, one for each degree of hue from 0 to 359.

      Parameters

      • Optionals: number

        The saturation, in the range 0 - 1. Default 1.

      • Optionalv: number

        The value, in the range 0 - 1. Default 1.

      Returns ColorObject[]

      An array of 360 ColorObject elements, each representing the RGB color at that hue step of the HSV color wheel.

    • Converts a HSV (hue, saturation and value) color set to RGB.

      Conversion formula from https://en.wikipedia.org/wiki/HSL_and_HSV

      Assumes HSV values are contained in the set [0, 1].

      Parameters

      • h: number

        The hue, in the range 0 - 1. This is the base color.

      • s: number

        The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you a greyscale color.

      • v: number

        The value, in the range 0 - 1. This controls how bright the color is, where 1 is as bright as possible and 0 is black.

      • Optionalout: Color | ColorObject

        A Color object to store the results in. If not given a new ColorObject will be created.

      Returns Color | ColorObject

      An object with the red, green and blue values set in the r, g and b properties.

    • Calculates a single RGB channel value from a hue offset and the two intermediate lightness values used during HSL to RGB conversion. Call this function once for each channel (red, green, and blue), passing the appropriate hue offset each time. Based on code by Michael Jackson (https://github.com/mjijackson)

      Parameters

      • p: number

        The first intermediate value derived from the lightness during HSL to RGB conversion.

      • q: number

        The second intermediate value derived from the lightness and saturation during HSL to RGB conversion.

      • t: number

        The hue offset for the color channel being calculated (red, green, or blue).

      Returns number

      The RGB channel value for the given hue offset, in the range 0 to 1.

    • Converts the given color value into an instance of a Color object.

      Parameters

      • input: number

        The 32-bit integer color value to convert, such as a hex value like 0xff0000 for red.

      • Optionalcolor: Color

        An optional Color object to store the result in. If not provided, a new Color object is created and returned.

      Returns Color

      A Color object containing the red, green, blue, and alpha components extracted from the given integer.

    • Return the component parts of a color as an Object with the properties alpha, red, green, blue.

      If the color value includes an alpha component (0xAARRGGBB), it is extracted and set in the a property. Otherwise, alpha defaults to 255 (fully opaque).

      Parameters

      • color: number

        The color value to convert into a Color object.

      Returns ColorObject

      An object with the alpha, red, green, and blue values set in the a, r, g, and b properties.

    • Converts an object containing r, g, b and a properties into a Color class instance.

      Parameters

      • input: InputColorObject

        An object containing r, g, b and a properties in the range 0 to 255.

      • Optionalcolor: Color

        The color where the new color will be stored. If not defined, a new color object is returned.

      Returns Color

      A Color object.

    • Creates a new Color object where the r, g, and b values have been set to random values based on the given min max values.

      Parameters

      • Optionalmin: number

        The minimum value to set the random range from (between 0 and 255) Default 0.

      • Optionalmax: number

        The maximum value to set the random range from (between 0 and 255) Default 255.

      Returns Color

      A Color object.

    • Converts a CSS 'web' string into a Phaser Color object.

      The web string can be in the format 'rgb(r,g,b)' or 'rgba(r,g,b,a)' where r/g/b are in the range [0..255] and a is in the range [0..1].

      Parameters

      • rgb: string

        The CSS format color string, using the rgb or rgba format.

      • Optionalcolor: Color

        An optional Color object to populate with the parsed values. If not provided, a new Color object is created and returned.

      Returns Color

      The Color object populated with the parsed RGB or RGBA values.

    • Converts an RGB color value to HSV (hue, saturation and value). Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. Based on code by Michael Jackson (https://github.com/mjijackson)

      Parameters

      • r: number

        The red color value. A number between 0 and 255.

      • g: number

        The green color value. A number between 0 and 255.

      • b: number

        The blue color value. A number between 0 and 255.

      • Optionalout: Color | HSVColorObject

        An object to store the color values in. If not given an HSV Color Object will be created.

      Returns Color | HSVColorObject

      An object with the properties h, s and v set.

    • Converts the given red, green, blue, and alpha color component values into a hex color string.

      When using the # prefix the result is a 6-character CSS-compatible hex string in #rrggbb format. The alpha value is not included in this format.

      When using the 0x prefix the result is an 8-character ARGB hex string in 0xaarrggbb format, which includes the alpha component as the most significant byte.

      Parameters

      • r: number

        The red color value. A number between 0 and 255.

      • g: number

        The green color value. A number between 0 and 255.

      • b: number

        The blue color value. A number between 0 and 255.

      • Optionala: number

        The alpha value. A number between 0 and 255. Default 255.

      • Optionalprefix: string

        The prefix of the string. Either # or 0x. Default #.

      Returns string

      A hex color string in either #rrggbb or 0xaarrggbb format, depending on the prefix.

    • Converts the given source color value into an instance of a Color class. The value can be a string (either prefixed with rgb for an RGB color string, or a hex color string), a number representing a packed RGB integer, or a plain object with r, g, and b properties.

      Parameters

      • input: string | number | InputColorObject

        The source color value to convert.

      • Optionalcolor: Color

        An existing Color object to store the result in. If not provided, a new Color object is created and returned.

      Returns Color

      A Color object containing the converted color value.