Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class Color

    Index
    • Creates a new Color.

      Parameters

      • r: number = 0

        Red component (0-1).

      • g: number = 0

        Green component (0-1).

      • b: number = 0

        Blue component (0-1).

      • a: number = 1.0

        Alpha component (0-1).

      Returns Color

    a: number = 1.0

    Alpha component (0-1).

    b: number = 0

    Blue component (0-1).

    g: number = 0

    Green component (0-1).

    r: number = 0

    Red component (0-1).

    AQUA: Color = ...
    BLACK: Color = ...
    BLUE: Color = ...
    CYAN: Color = ...
    FUCHSIA: Color = ...
    GRAY: Color = ...
    GREEN: Color = ...
    LIME: Color = ...
    MAGENTA: Color = ...
    MAROON: Color = ...
    NAVY: Color = ...
    OLIVE: Color = ...
    PURPLE: Color = ...
    RED: Color = ...
    SILVER: Color = ...
    TEAL: Color = ...
    TRANSPARENT: Color = ...
    WHITE: Color = ...
    YELLOW: Color = ...
    • Parameters

      • r: number = 0
      • g: number = 0
      • b: number = 0
      • a: number = 1.0

      Returns this

    • Returns the color components as an array.

      Returns number[]

      [r, g, b, a]

    • Returns the color components as a Float32Array.

      Returns Float32Array

      Float32Array(4)

    • Returns the color components as a hex string (e.g. "#FF0000").

      Parameters

      • includeAlpha: boolean = false

        Whether to include the alpha channel (e.g. "#FF0000FF").

      Returns string

    • Returns the color components as HSL.

      Returns { h: number; l: number; s: number }

      An object with { h: (0-360), s: (0-1), l: (0-1) }

    • Returns the color components as HSV/HSB.

      Returns { h: number; s: number; v: number }

      An object with { h: (0-360), s: (0-1), v: (0-1) }

    • Evaluates a thermal blackbody radiation color ramp from normalized temperature t in [0, 1].

      • 0.0: Deep dark red (0.6, 0.0, 0.0)
      • 0.5: Hot fiery orange (1.0, 0.38, 0.0)
      • 0.8: Golden yellow (1.0, 0.75, 0.33)
      • 1.0: Blinding thermal white (1.0, 1.0, 1.0)

      Parameters

      • t: number

        Normalized temperature in [0, 1] (clamped automatically).

      • Optionaltarget: Color

        Optional existing Color instance to mutate (avoids GC allocations).

      Returns Color

    • Creates a Color from HSL (Hue, Saturation, Lightness).

      Parameters

      • h: number

        Hue (0 - 360).

      • s: number

        Saturation (0.0 - 1.0).

      • l: number

        Lightness (0.0 - 1.0).

      • a: number = 1.0

        Alpha (0.0 - 1.0). Default is 1.0.

      Returns Color

    • Creates a Color from HSV/HSB (Hue, Saturation, Value/Brightness).

      Parameters

      • h: number

        Hue (0 - 360).

      • s: number

        Saturation (0.0 - 1.0).

      • v: number

        Value/Brightness (0.0 - 1.0).

      • a: number = 1.0

        Alpha (0.0 - 1.0). Default is 1.0.

      Returns Color

    • Creates a Color from a CSS/X11 named color (e.g. "papayawhip", "royalblue", "coral").

      Parameters

      • name: string

      Returns Color | undefined

    • Converts a color temperature in Kelvin (1000K to 40000K) to standard RGB color. Based on Tanner Helland's analytic Planckian locus fit.

      Parameters

      • kelvin: number

        Temperature in Kelvin (e.g. 1900 for candlelight, 5500 for midday sun, 10000 for blue sky).

      • Optionaltarget: Color

        Optional existing Color instance to mutate (avoids GC allocations).

      Returns Color