Interface IColorRgb

Immutable RGB color interface with alpha channel support. Represents a color with red, green, blue components and optional alpha. All components are readonly and cannot be modified after creation.

interface IColorRgb {
    a: number;
    b: number;
    g: number;
    r: number;
    at(i: number): number;
    clone(): IColorRgb;
    dot(vec: IVector3): number;
    flattenAsArray(): number[];
    isDummy(): boolean;
    isEqual(vec: IVector3, delta: number): boolean;
    isStrictEqual(vec: IVector3): boolean;
    length(): number;
    lengthSquared(): number;
    lengthTo(vec: IVector3): number;
    toString(): string;
    toStringApproximately(): string;
}

Implemented by

Properties

a: number

Alpha (transparency) component of the color (0.0 to 1.0)

b: number

Blue component of the color (0.0 to 1.0)

g: number

Green component of the color (0.0 to 1.0)

r: number

Red component of the color (0.0 to 1.0)

Methods

  • Gets the component value at the specified index.

    Parameters

    • i: number

      The index (0=r, 1=g, 2=b, 3=a)

    Returns number

    The component value at the specified index

  • Calculates the dot product with another vector.

    Parameters

    • vec: IVector3

      The vector to calculate dot product with

    Returns number

    The dot product result

  • Converts the color to a flat array of numbers.

    Returns number[]

    Array containing the color components

  • Checks if this is a dummy/placeholder color instance.

    Returns boolean

    True if this is a dummy color, false otherwise

  • Checks if this color is equal to another vector within a given tolerance.

    Parameters

    • vec: IVector3

      The vector to compare with

    • delta: number

      The tolerance for comparison

    Returns boolean

    True if the colors are equal within the tolerance

  • Checks if this color is strictly equal to another vector.

    Parameters

    • vec: IVector3

      The vector to compare with

    Returns boolean

    True if the colors are exactly equal

  • Calculates the length (magnitude) of the color vector.

    Returns number

    The length of the color vector

  • Calculates the squared length of the color vector.

    Returns number

    The squared length of the color vector

  • Calculates the distance to another vector.

    Parameters

    Returns number

    The distance to the target vector

  • Returns a string representation of the color.

    Returns string

    String representation of the color

  • Returns an approximate string representation of the color with limited precision.

    Returns string

    Approximate string representation of the color