Provides standard colors (e.g. Color.Black) but you can also create custom colors using RGB, HSL, or Hex. Also provides useful color operations like Color.lighten, Color.darken, and more.

Hierarchy

  • Color

Constructors

  • Creates a new instance of Color from an r, g, b, a

    Parameters

    • r: number

      The red component of color (0-255)

    • g: number

      The green component of color (0-255)

    • b: number

      The blue component of color (0-255)

    • Optional a: number

      The alpha component of color (0-1.0)

    Returns Color

Properties

a: number

Alpha channel (between 0 and 1)

b: number

Blue channel

g: number

Green channel

h: number

Hue

l: number

Lightness

r: number

Red channel

s: number

Saturation

Accessors

Methods

  • Darkens the current color by a specified amount

    Parameters

    • factor: number = 0.1

      The amount to darken by [0-1]

    Returns Color

  • Desaturates the current color by a specified amount

    Parameters

    • factor: number = 0.1

      The amount to desaturate by [0-1]

    Returns Color

  • Returns a CSS string representation of a color.

    Returns string

  • Lightens the current color by a specified amount

    Parameters

    • factor: number = 0.1

      The amount to lighten by [0-1]

    Returns Color

  • Multiplies a color by another, results in a darker color

    Parameters

    • color: Color

      The other color

    Returns Color

  • Saturates the current color by a specified amount

    Parameters

    • factor: number = 0.1

      The amount to saturate by [0-1]

    Returns Color

  • Screens a color by another, results in a lighter color

    Parameters

    • color: Color

      The other color

    Returns Color

  • Return HSLA representation of a color.

    Returns string

  • Return Hex representation of a color.

    Returns string

  • Return RGBA representation of a color.

    Returns string

  • Returns a CSS string representation of a color.

    Parameters

    • format: "rgb" | "hsl" | "hex" = 'rgb'

      Color representation, accepts: rgb, hsl, or hex

    Returns string

  • Creates a new instance of Color from hsla values

    Parameters

    • h: number

      Hue is represented [0-1]

    • s: number

      Saturation is represented [0-1]

    • l: number

      Luminance is represented [0-1]

    • a: number = 1.0

      Alpha is represented [0-1]

    Returns Color

  • Creates a new instance of Color from a hex string

    Parameters

    • hex: string

      CSS color string of the form #ffffff, the alpha component is optional

    Returns Color

  • Creates a new instance of Color from an r, g, b, a

    Parameters

    • r: number

      The red component of color (0-255)

    • g: number

      The green component of color (0-255)

    • b: number

      The blue component of color (0-255)

    • Optional a: number

      The alpha component of color (0-1.0)

    Returns Color

  • Creates a new instance of Color from a rgb string

    Parameters

    • string: string

      CSS color string of the form rgba(255, 255, 255, 1) or rgb(255, 255, 255)

    Returns Color