rhodonite
    Preparing search index...

    Class MutableColorRgba

    A mutable RGBA color class that extends MutableVector4. Represents a color with red, green, blue, and alpha components. This class provides both vector-like (x, y, z, w) and color-specific (r, g, b, a) accessors.

    Hierarchy (View Summary)

    Implements

    Index
    • Creates a new MutableVector4 instance.

      Parameters

      • x: Float32Array

        Float32Array containing the vector components [x, y, z, w]

      Returns MutableColorRgba

    _v: TypedArray = ...

    Internal typed array storage for vector components

    • get _updateCount(): number

      Gets the update counter value. This counter is incremented whenever the vector is modified.

      Returns number

      The current update count

    • get a(): number

      Gets the alpha component.

      Returns number

      The alpha value

    • set a(val: number): void

      Sets the alpha component.

      Parameters

      • val: number

        The alpha value to set

      Returns void

    • get b(): number

      Gets the blue component.

      Returns number

      The blue value

    • set b(val: number): void

      Sets the blue component.

      Parameters

      • val: number

        The blue value to set

      Returns void

    • get bytesPerComponent(): number

      Gets the number of bytes per component in the underlying typed array.

      Returns number

      The byte size per component (4 for Float32Array, 8 for Float64Array)

    • get className(): string

      Gets the class name for debugging and identification purposes.

      Returns string

      The string 'MutableVector4'

    • get g(): number

      Gets the green component.

      Returns number

      The green value

    • set g(val: number): void

      Sets the green component.

      Parameters

      • val: number

        The green value to set

      Returns void

    • get glslStrAsFloat(): string

      Converts the vector to a GLSL vec4 string representation with float precision.

      Returns string

      A GLSL-compatible vec4 string (e.g., "vec4(1.0, 2.0, 3.0, 4.0)")

    • get glslStrAsInt(): string

      Converts the vector to a GLSL ivec4 string representation with integer values.

      Returns string

      A GLSL-compatible ivec4 string (e.g., "ivec4(1, 2, 3, 4)")

    • get glslStrAsUint(): string

      Converts the vector to a GLSL uvec4 string representation with unsigned integer values.

      Returns string

      A GLSL-compatible uvec4 string (e.g., "uvec4(1u, 2u, 3u, 4u)")

    • get r(): number

      Gets the red component.

      Returns number

      The red value

    • set r(val: number): void

      Sets the red component.

      Parameters

      • val: number

        The red value to set

      Returns void

    • get w(): number

      Gets the w component (equivalent to alpha component).

      Returns number

      The w/alpha value

    • set w(val: number): void

      Sets the w component (equivalent to alpha component).

      Parameters

      • val: number

        The value to set

      Returns void

    • get wgslStrAsFloat(): string

      Converts the vector to a WGSL vec4f string representation with float precision.

      Returns string

      A WGSL-compatible vec4f string (e.g., "vec4f(1.0, 2.0, 3.0, 4.0)")

    • get wgslStrAsInt(): string

      Converts the vector to a WGSL vec4i string representation with integer values.

      Returns string

      A WGSL-compatible vec4i string (e.g., "vec4i(1, 2, 3, 4)")

    • get wgslStrAsUint(): string

      Converts the vector to a WGSL vec4u string representation with unsigned integer values.

      Returns string

      A WGSL-compatible vec4u string (e.g., "vec4u(1u, 2u, 3u, 4u)")

    • get x(): number

      Gets the x component (equivalent to red component).

      Returns number

      The x/red value

    • set x(val: number): void

      Sets the x component (equivalent to red component).

      Parameters

      • val: number

        The value to set

      Returns void

    • get y(): number

      Gets the y component (equivalent to green component).

      Returns number

      The y/green value

    • set y(val: number): void

      Sets the y component (equivalent to green component).

      Parameters

      • val: number

        The value to set

      Returns void

    • get z(): number

      Gets the z component (equivalent to blue component).

      Returns number

      The z/blue value

    • set z(val: number): void

      Sets the z component (equivalent to blue component).

      Parameters

      • val: number

        The value to set

      Returns void

    • get compositionType(): CompositionTypeClass<"VEC4">

      Gets the composition type identifier for this vector type.

      Returns CompositionTypeClass<"VEC4">

      The CompositionType.Vec4 identifier

    • Gets the component value at the specified index.

      Parameters

      • i: number

        The index (0=x, 1=y, 2=z, 3=w)

      Returns number

      The component value at the specified index

    • Divides this vector by a scalar value. If the value is zero, sets components to 0 and logs an error.

      Parameters

      • value: number

        The scalar value to divide by

      Returns MutableColorRgba

      This vector instance for method chaining

    • Calculates the dot product between this vector and another vector. The dot product is the sum of the products of corresponding components.

      Parameters

      • vec: IVector4

        The vector to calculate dot product with

      Returns number

      The dot product of the two vectors

    • Converts the vector to a flat array representation.

      Returns number[]

      An array containing the vector components [x, y, z, w]

    • Checks if this vector is a dummy vector (has no components).

      Returns boolean

      True if the vector has no components, false otherwise

    • Checks if this vector is approximately equal to another vector within a specified tolerance.

      Parameters

      • vec: IVector4

        The vector to compare with

      • delta: number = Number.EPSILON

        The tolerance value for comparison (default: Number.EPSILON)

      Returns boolean

      True if the vectors are approximately equal, false otherwise

    • Checks if this vector is strictly equal to another vector (exact component equality).

      Parameters

      • vec: IVector4

        The vector to compare with

      Returns boolean

      True if all components are exactly equal, false otherwise

    • Checks if the internal storage shares the same ArrayBuffer as the provided one. Useful for determining if vectors share underlying memory.

      Parameters

      • arrayBuffer: ArrayBuffer

        The ArrayBuffer to compare against

      Returns boolean

      True if the same ArrayBuffer is used, false otherwise

    • Calculates the length (magnitude) of the vector using the Euclidean norm.

      Returns number

      The length of the vector

    • Calculates the squared length (magnitude) of the vector. This is more efficient than length() when only comparing magnitudes.

      Returns number

      The squared length of the vector

    • Calculates the distance from this vector to another vector.

      Parameters

      • vec: IVector4

        The target vector to calculate distance to

      Returns number

      The distance between the two vectors

    • Sets the value at the specified index.

      Parameters

      • i: number

        The index (0-3) to set

      • value: number

        The value to set at the index

      Returns MutableColorRgba

      This vector instance for method chaining

    • Sets all four components of the vector.

      Parameters

      • x: number

        The x component value

      • y: number

        The y component value

      • z: number

        The z component value

      • w: number

        The w component value

      Returns MutableColorRgba

      This vector instance for method chaining

    • Converts the vector to a string representation in the format "(x, y, z, w)".

      Returns string

      A string representation of the vector

    • Converts the vector to an approximately formatted string representation with financial precision. Each component is formatted to a fixed number of decimal places.

      Returns string

      A string with space-separated components followed by a newline

    • Gets the component value at the specified index. Alias for the at() method for convenience.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • Divides a vector by a scalar value.

      Parameters

      • vec: IVector4

        The vector to divide

      • value: number

        The scalar value to divide by

      Returns MutableColorRgba

      A new MutableColorRgba containing the divided result

    • Divides a vector by a scalar value and stores the result in the output vector. If the divisor is zero, the result components will be set to 0 and an error will be logged. This method modifies the output vector in-place for better performance.

      Parameters

      • vec: IVector4

        The vector to divide

      • value: number

        The scalar value to divide by

      • out: IMutableVector4

        The output vector to store the result (will be modified)

      Returns IMutableVector4

      The modified output vector with each component divided by the scalar

    • Divides the left vector by the right vector component-wise and stores the result in the output vector. If any component of the right vector is zero, the corresponding result component will be set to 0. This method modifies the output vector in-place for better performance.

      Parameters

      • l_vec: IVector4

        The left operand vector (dividend)

      • r_vec: IVector4

        The right operand vector (divisor)

      • out: IMutableVector4

        The output vector to store the result (will be modified)

      Returns IMutableVector4

      The modified output vector with component-wise division result

    • Calculates the dot product of two vectors. The dot product is the sum of the products of corresponding components.

      Parameters

      • l_vec: IVector4

        The left operand vector

      • r_vec: IVector4

        The right operand vector

      Returns number

      The dot product of the two vectors

    • Creates a new MutableVector4 from individual component values.

      Parameters

      • x: number

        The x component

      • y: number

        The y component

      • z: number

        The z component

      • w: number

        The w component

      Returns MutableVector4

      A new MutableVector4 instance

    • Creates a new MutableVector4 from an array of numbers. Takes up to 4 elements from the array.

      Parameters

      • array: number[]

        Array of numbers to copy from

      Returns MutableVector4

      A new MutableVector4 instance

    • Calculates the distance between two vectors.

      Parameters

      Returns number

      The distance between the two vectors

    • Calculates the squared length (magnitude) of a vector. This is more efficient than length() when only comparing magnitudes.

      Parameters

      • vec: IVector4

        The vector to calculate squared length for

      Returns number

      The squared length of the vector

    • Multiplies a vector by a scalar value.

      Parameters

      • vec: IVector4

        The vector to multiply

      • value: number

        The scalar value to multiply by

      Returns MutableColorRgba

      A new MutableColorRgba containing the scaled result

    • Multiplies a vector by a scalar value and stores the result in the output vector. This method modifies the output vector in-place for better performance.

      Parameters

      • vec: IVector4

        The vector to multiply

      • value: number

        The scalar value to multiply by

      • out: IMutableVector4

        The output vector to store the result (will be modified)

      Returns IMutableVector4

      The modified output vector with each component multiplied by the scalar

    • Multiplies two vectors component-wise and stores the result in the output vector. This method modifies the output vector in-place for better performance.

      Parameters

      • l_vec: IVector4

        The left operand vector

      • r_vec: IVector4

        The right operand vector

      • out: IMutableVector4

        The output vector to store the result (will be modified)

      Returns IMutableVector4

      The modified output vector with component-wise multiplication result

    • Creates a new MutableColorRgba with all components set to one.

      Returns MutableColorRgba

      A new MutableColorRgba instance with values [1, 1, 1, 1]

    • Subtracts the right vector from the left vector component-wise and stores the result in the output vector. This method modifies the output vector in-place for better performance.

      Parameters

      • l_vec: IVector4

        The left operand vector (minuend)

      • r_vec: IVector4

        The right operand vector (subtrahend)

      • out: IMutableVector4

        The output vector to store the result (will be modified)

      Returns IMutableVector4

      The modified output vector containing the difference

    • Creates a new MutableColorRgba with all components set to zero.

      Returns MutableColorRgba

      A new MutableColorRgba instance with values [0, 0, 0, 0]