DDNet - v0.9.0
    Preparing search index...

    Class Color<T>

    Helper class to convert or pass around colors.

    Type Parameters

    • T extends string

      used internally.

    Index

    Constructors

    Methods

    Constructors

    • Construct a new Color instance from a teeworlds color code.

      Type Parameters

      • T extends string

      Parameters

      • tw: number

        A TeeWorlds color code.

      Returns Color<T>

    • Construct a new Color instance from an rgba color.

      Type Parameters

      • T extends string

      Parameters

      • rgba: RGBA_Color

        An RGBA color object with keys for Red (0-255), Green (0-255), Blue (0-255) and optionally Alpha (0-1)

        const col: RGBA_Color = { r: 169, g: 69, b: 42 }; // optionally add `a` for alpha
        

      Returns Color<T>

    • Construct a new Color instance from an hsla color.

      Type Parameters

      • T extends string

      Parameters

      • hsla: HSLA_Color

        An HSLA color object with keys for Hue (0-360), Saturation (0-100), Lightness (0-100) and optionally Alpha (0-1)

        const col: HSLA_Color = { h: 169, s: 69, l: 42 }; // optionally add `a` for alpha
        

      Returns Color<T>

    • Construct a new Color instance from a hex color.

      Type Parameters

      • T extends string

      Parameters

      • hex: `#${ValidateHexStr<T>}`

        A hex color in short or long form, a string starting with # followed by either 3, 4, 6 or 8 hex chars.

        const col1 = '#123';      // short form, no alpha
        const col2 = '#1234'; // short form, with alpha
        const col3 = '#123abc'; // long form, no alpha
        const col4 = '#123abc99'; // long form, with alpha

      Returns Color<T>

    Methods

    • Construct a new Color instance from a teeworlds color code.

      Parameters

      • tw: number

        A TeeWorlds color code.

      Returns Color<string>

    • Construct a new Color instance from an rgba color.

      Parameters

      • rgba: RGBA_Color

        An RGBA color object with keys for Red (0-255), Green (0-255), Blue (0-255) and optionally Alpha (0-1)

        const col: RGBA_Color = { r: 169, g: 69, b: 42 }; // optionally add `a` for alpha
        

      Returns Color<string>

    • Construct a new Color instance from an hsla color.

      Parameters

      • hsla: HSLA_Color

        An HSLA color object with keys for Hue (0-360), Saturation (0-100), Lightness (0-100) and optionally Alpha (0-1)

        const col: HSLA_Color = { h: 169, s: 69, l: 42 }; // optionally add `a` for alpha
        

      Returns Color<string>

    • Construct a new Color instance from a hex color.

      Type Parameters

      • T extends string

      Parameters

      • hex: `#${ValidateHexStr<T>}`

        A hex color in short or long form, a string starting with # followed by either 3, 4, 6 or 8 hex chars.

        const col1 = '#123';      // short form, no alpha
        const col2 = '#1234'; // short form, with alpha
        const col3 = '#123abc'; // long form, no alpha
        const col4 = '#123abc99'; // long form, with alpha

      Returns Color<string>