Represents a color with red, green, blue, and alpha (transparency) components.

Constructors

Properties

Accessors

a b g r

Methods

Constructors

  • Creates an instance of Color.

    Parameters

    • r: number

      The red component (0-255).

    • g: number

      The green component (0-255).

    • b: number

      The blue component (0-255).

    • a: number

      The alpha component (0-255).

    Returns Color

Properties

uint32: number

Accessors

  • get a(): number
  • Gets the alpha component.

    Returns number

  • set a(value): void
  • Sets the alpha component and updates the uint32 representation.

    Parameters

    • value: number

      The new alpha component (0-255).

    Returns void

  • get b(): number
  • Gets the blue component.

    Returns number

  • set b(value): void
  • Sets the blue component and updates the uint32 representation.

    Parameters

    • value: number

      The new blue component (0-255).

    Returns void

  • get g(): number
  • Gets the green component.

    Returns number

  • set g(value): void
  • Sets the green component and updates the uint32 representation.

    Parameters

    • value: number

      The new green component (0-255).

    Returns void

  • get r(): number
  • Gets the red component.

    Returns number

  • set r(value): void
  • Sets the red component and updates the uint32 representation.

    Parameters

    • value: number

      The new red component (0-255).

    Returns void

Methods

  • Adds the components of another color to this color, clamping the result to 255.

    Parameters

    • color: Color

      The color to add.

    Returns Color

    A new Color instance with the result of the addition.

  • Copies the RGBA values from another color.

    Parameters

    • color: Color

      The color to copy from.

    Returns void

  • Checks if the current color is equal to another color.

    Parameters

    • color: Color

      The color to compare with.

    Returns boolean

    True if the colors are equal, otherwise false.

  • Sets the RGBA values of the color and updates the uint32 representation.

    Parameters

    • r: number

      The red component (0-255).

    • g: number

      The green component (0-255).

    • b: number

      The blue component (0-255).

    • a: number

      The alpha component (0-255).

    Returns void

  • Subtracts the components of another color from this color, clamping the result to 0.

    Parameters

    • color: Color

      The color to subtract.

    Returns Color

    A new Color instance with the result of the subtraction.

  • Creates a Color instance from a hexadecimal color string.

    Parameters

    • hexString: string

      The hexadecimal color string, e.g., '#RRGGBB' or '#RRGGBBAA'.

    Returns Color

    A new Color instance.