@ujjwalvivek/tinyts
    Preparing search index...

    Class Color

    RGBA color with components in 0-1 range.

    Index

    Constructors

    • Parameters

      • r: number = 1

        Red channel (0-1)

      • g: number = 1

        Green channel (0-1)

      • b: number = 1

        Blue channel (0-1)

      • a: number = 1

        Alpha channel (0-1)

      Returns Color

    Properties

    a: number = 1

    Alpha channel (0-1)

    b: number = 1

    Blue channel (0-1)

    g: number = 1

    Green channel (0-1)

    r: number = 1

    Red channel (0-1)

    Methods

    • Copy channels from another Color. Returns this for chaining.

      Parameters

      Returns this

    • Darken by a factor (0-1). Does not affect alpha.

      Parameters

      • amount: number

      Returns this

    • Linearly interpolate toward another Color by factor t (0-1).

      Parameters

      Returns this

    • Lighten by a factor (0-1). Does not affect alpha.

      Parameters

      • amount: number

      Returns this

    • Set all channels. Returns this for chaining.

      Parameters

      • r: number
      • g: number
      • b: number
      • a: number = ...

      Returns this

    • Convert to a "#rrggbb" hex string.

      Returns string

    • Convert to an "rgba(r,g,b,a)" CSS string.

      Returns string

    • Convert to a CSS color string (hex if opaque, rgba otherwise).

      Returns string

    • Parse a hex string ("#rgb", "#rrggbb", "#rrggbbaa") or "rgba(...)" into a Color.

      Parameters

      • hex: string

      Returns Color

    • Create a Color from HSL values.

      Parameters

      • h: number

        Hue in degrees (0-360)

      • s: number

        Saturation (0-1)

      • l: number

        Lightness (0-1)

      • a: number = 1

      Returns Color

    • Create a Color from HSL with percentage saturation/lightness.

      Parameters

      • h: number

        Hue in degrees (0-360)

      • s: number

        Saturation (0-100)

      • l: number

        Lightness (0-100)

      • Optionala: number

      Returns Color

    • Create a Color from 0-255 RGB values.

      Parameters

      • r: number
      • g: number
      • b: number
      • Optionala: number

      Returns Color