rapid-render
    Preparing search index...

    Class Color

    Index

    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 = 255

        The alpha component (0-255).

      Returns Color

    Properties

    uint32: number

    Accessors

    • get a(): number

      Gets the alpha component.

      Returns number

    • set a(value: number): 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: number): 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: number): 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: number): 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.

    • Clone the current color

      Returns Color

      A new Color instance with the same RGBA values.

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

    • Converts the color to a hexadecimal string representation (e.g., '#RRGGBBAA').

      Parameters

      • includeAlpha: boolean = true

        Whether to include the alpha channel in the hex string.

      Returns string

      The hexadecimal string representation of the color.

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

    • Creates a Color instance from normalized float components (0–1 range). Use this instead of new Color() when working with shader-style 0.0–1.0 values.

      Parameters

      • r: number

        Red channel (0.0–1.0)

      • g: number

        Green channel (0.0–1.0)

      • b: number

        Blue channel (0.0–1.0)

      • a: number = 1.0

        Alpha channel (0.0–1.0), defaults to 1.0

      Returns Color

      A new Color instance with components scaled to 0–255.

      Color.fromNorm(0.9, 0.87, 0.55, 0.1) // moon glow