Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

constructor

  • new Color(r: number, g: number, b: number, a?: number): 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

Properties

a

a: number

Alpha channel (between 0 and 1)

b

b: number

Blue channel

g

g: number

Green channel

h

h: number

Hue

l

l: number

Lightness

r

r: number

Red channel

s

s: number

Saturation

Accessors

Static Azure

Static Black

Static Blue

Static Chartreuse

  • get Chartreuse(): Color

Static Cyan

Static DarkGray

Static Gray

Static Green

Static LightGray

Static Magenta

Static Orange

Static Red

Static Rose

Static Transparent

  • get Transparent(): Color

Static Vermilion

Static Vermillion

  • get Vermillion(): Color
  • Vermilion (#FF5B31)

    obsolete

    Alias for incorrect spelling used in older versions, use multiply instead, will be removed in v0.25.0

    Returns Color

Static Violet

Static Viridian

Static White

Static Yellow

Methods

average

clone

darken

  • darken(factor?: number): Color
  • Darkens the current color by a specified amount

    Parameters

    • Default value factor: number = 0.1

      The amount to darken by [0-1]

    Returns Color

desaturate

  • desaturate(factor?: number): Color
  • Desaturates the current color by a specified amount

    Parameters

    • Default value factor: number = 0.1

      The amount to desaturate by [0-1]

    Returns Color

fillStyle

  • fillStyle(): string

invert

lighten

  • lighten(factor?: number): Color
  • Lightens the current color by a specified amount

    Parameters

    • Default value factor: number = 0.1

      The amount to lighten by [0-1]

    Returns Color

Obsolete mulitiply

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

    obsolete

    Alias for incorrect spelling used in older versions, use multiply instead, will be removed in v0.25.0

    Parameters

    Returns Color

multiply

saturate

  • saturate(factor?: number): Color
  • Saturates the current color by a specified amount

    Parameters

    • Default value factor: number = 0.1

      The amount to saturate by [0-1]

    Returns Color

screen

toHSLA

  • toHSLA(): string

toHex

  • toHex(): string

toRGBA

  • toRGBA(): string

toString

  • toString(format?: "rgb" | "hsl" | "hex"): string
  • Returns a CSS string representation of a color.

    Parameters

    • Default value format: "rgb" | "hsl" | "hex" = "rgb"

      Color representation, accepts: rgb, hsl, or hex

    Returns string

Static fromHSL

  • fromHSL(h: number, s: number, l: number, a?: number): Color
  • 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]

    • Default value a: number = 1

      Alpha is represented [0-1]

    Returns Color

Static fromHex

  • fromHex(hex: string): 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

Static fromRGB

  • fromRGB(r: number, g: number, b: number, a?: number): 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

Static fromRGBString

  • fromRGBString(string: string): 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