Nano WebGPU API - v0.11.0
    Preparing search index...

    Class Color

    Color representation utilizing RGBA float values ranging from 0.0 to 1.0. Includes helpers to parse hex strings, CSS color names, interpolate colors, and convert to Linear space.

    Index

    Accessors

    Constructors

    • Create a new Color

      Parameters

      • r: number = 0.0

        Red channel (0.0 - 1.0)

      • g: number = 0.0

        Green channel (0.0 - 1.0)

      • b: number = 0.0

        Blue channel (0.0 - 1.0)

      • a: number = 1.0

        Alpha channel (0.0 - 1.0)

      Returns Color

    Methods

    • Get the color as a Float32Array

      Returns Float32Array

      The color as an array of floats

    • Returns a new Color converted from sRGB to Linear space. Often used when passing uniform colors to PBR shaders.

      Returns Color

    • Applies Narkowicz ACES filmic tone mapping approximation to this color and returns a new LDR Color instance. This curves the highlights and shadows to mimic physical film stock.

      Returns Color

      A new tone-mapped Color

    • Applies Reinhard tone mapping to this color and returns a new LDR Color instance. Formulated as: C_out = (C_in * exposure) / (1 + C_in * exposure)

      Parameters

      • Optionalexposure: number = 1.0

        The exposure value

      Returns Color

      A new tone-mapped Color

    • Creates a Color from varying inputs.

      Parameters

      • val: string | number[] | Color | [number, number, number, number?]

        The input value.

      Returns Color

      A new Color instance.

    • Create a Color from byte values (0 - 255)

      Parameters

      • r: number = 0

        Red channel (0 - 255)

      • g: number = 0

        Green channel (0 - 255)

      • b: number = 0

        Blue channel (0 - 255)

      • a: number = 255

        Alpha channel (0 - 255)

      Returns Color

      A new Color instance

    • Create a Color from a hex string (e.g. "#FF0000" or "FF0000") or a CSS color name

      Parameters

      • hex: string

        Hex color string or CSS color name

      Returns Color

      A new Color instance

    • Linearly interpolate between two colors

      Parameters

      • color1: Color

        Start color

      • color2: Color

        End color

      • t: number

        Interpolation factor (0.0 - 1.0)

      Returns Color

      A new interpolated Color

    Properties

    onChange?: () => void

    Callback triggered when any component changes

    CSS_NAMES: Record<string, string> = ...

    Standard CSS/HTML W3C color name mapping.