Class ColorRGB

Represents an RGB color.

Hierarchy (View Summary)

Constructors

  • Creates a new instance of the Color class.

    Parameters

    • r: number = 255

      The red component of the RGB color. Defaults to 255.

    • g: number = 255

      The green component of the RGB color. Defaults to 255.

    • b: number = 255

      The blue component of the RGB color. Defaults to 255.

    • onChange: Function = undefined

      Optional callback function to be called when the color changes. Defaults to undefined.

    Returns ColorRGB

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 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 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.