Class ColorRGBA

Represents a color with red, green, blue, and alpha values. Extends the ColorRGB class.

Hierarchy (View Summary)

Constructors

  • Creates a new instance of the Color class.

    Parameters

    • Optionalr: number = 255

      The red component of the color. Must be a number between 0 and 255.

    • Optionalg: number = 255

      The green component of the color. Must be a number between 0 and 255.

    • Optionalb: number = 255

      The blue component of the color. Must be a number between 0 and 255.

    • Optionala: number = 1

      The alpha component of the color. Must be a number between 0 and 1.

    • OptionalonChange: Function = undefined

      The callback function to be called when the color changes.

    Returns ColorRGBA

Accessors

  • get hex(): string

    Returns the hexadecimal representation of the RGB color.

    Returns string

    The hexadecimal color value.

  • get rgb(): number[]

    Returns an array containing the RGB values of the color.

    Returns number[]

    An array of numbers representing the RGB values in the format [r, g, b].

  • get rgba(): number[]

    Get the RGBA values of the color.

    Returns number[]

    An array containing the red, green, blue, and alpha values.

  • get rgbaNormal(): number[]

    Returns the normalized RGBA values as an array.

    Returns number[]

    The normalized rgba values.

  • get rgbNormal(): number[]

    Returns the normalized RGB values as an array.

    Returns number[]

    An array containing the normalized RGB values.

Methods

  • Sets the color of the object using a hexadecimal color code.

    Parameters

    • hexColor: string | number

      The hexadecimal color code to set the color with.

    Returns void

  • Sets the color of the object based on the provided RGB values.

    Parameters

    • r: number

      The red value in the range of 0-255.

    • g: number

      The green value in the range of 0-255.

    • b: number

      The blue value in the range of 0-255.

    Returns void

  • Sets the color of the object using RGBA values.

    Parameters

    • r: number

      The red component of the color. Value should be between 0 and 255.

    • g: number

      The green component of the color. Value should be between 0 and 255.

    • b: number

      The blue component of the color. Value should be between 0 and 255.

    • a: number

      The alpha component of the color. Value should be between 0 and 1.

    Returns void

    If the RGBA color value is invalid.

  • Sets the color of an object using an RGBA string.

    Parameters

    • rgbaString: string

      The RGBA color value as a string.

    Returns void

    If the RGBA color value is invalid.

  • Sets the color of an object by parsing a string representing an RGB color value.

    Parameters

    • rgbString: string

      The string representing the RGB color value in the format "rgb(r, g, b)".

    Returns void

    Throws an error if the given rgbString is not a valid RGB color value.