Skip to main content

Color

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.

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)

    • optionala: number

      The alpha component of color (0-1.0)

    Returns Color

Properties

publica

a: number

Alpha channel (between 0 and 1)

publicb

b: number

Blue channel

publicg

g: number

Green channel

publich

h: number

Hue

publicl

l: number

Lightness

publicr

r: number

Red channel

publics

s: number

Saturation

Accessors

publicstaticAzure

  • Azure (#007FFF)


    Returns Color

publicstaticBlack

  • Black (#000000)


    Returns Color

publicstaticBlue

  • Blue (#0000FF)


    Returns Color

publicstaticBrown

  • Brown (#964B00)


    Returns Color

publicstaticChartreuse

  • Chartreuse (#7FFF00)


    Returns Color

publicstaticCyan

  • Cyan (#00FFFF)


    Returns Color

publicstaticDarkGray

  • Dark gray (#A9A9A9)


    Returns Color

publicstaticExcaliburBlue

  • get ExcaliburBlue(): Color
  • ExcaliburBlue (#176BAA)


    Returns Color

publicstaticGray

  • Gray (#808080)


    Returns Color

publicstaticGreen

  • Green (#00FF00)


    Returns Color

publicstaticLightGray

  • Light gray (#D3D3D3)


    Returns Color

publicstaticMagenta

  • Magenta (#FF00FF)


    Returns Color

publicstaticOrange

  • Orange (#FFA500)


    Returns Color

publicstaticPink

  • Pink (#FFC0CB)


    Returns Color

publicstaticPurple

  • Purple (#800080)


    Returns Color

publicstaticRed

  • Red (#FF0000)


    Returns Color

publicstaticRose

  • Rose (#FF007F)


    Returns Color

publicstaticTeal

  • Teal (#008080)


    Returns Color

publicstaticTransparent

  • Transparent (#FFFFFF00)


    Returns Color

publicstaticVermilion

  • Vermilion (#FF5B31)


    Returns Color

publicstaticViolet

  • Violet (#7F00FF)


    Returns Color

publicstaticViridian

  • Viridian (#59978F)


    Returns Color

publicstaticWhite

  • White (#FFFFFF)


    Returns Color

publicstaticYellow

  • Yellow (#FFFF00)


    Returns Color

Methods

publicaverage

  • Averages the current color with another


    Parameters

    • color: Color

      The other color

    Returns Color

publicclone

  • Returns a clone of the current color.


    Returns Color

publicdarken

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


    Parameters

    • factor: number = 0.1

      The amount to darken by [0-1]

    Returns Color

publicdesaturate

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


    Parameters

    • factor: number = 0.1

      The amount to desaturate by [0-1]

    Returns Color

publicequal

  • equal(color: Color): boolean
  • Parameters

    Returns boolean

publicfillStyle

  • fillStyle(): string
  • Returns a CSS string representation of a color.


    Returns string

publicinvert

  • Inverts the current color


    Returns Color

publiclighten

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


    Parameters

    • factor: number = 0.1

      The amount to lighten by [0-1]

    Returns Color

publicmultiply

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


    Parameters

    • color: Color

      The other color

    Returns Color

publicsaturate

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


    Parameters

    • factor: number = 0.1

      The amount to saturate by [0-1]

    Returns Color

publicscreen

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


    Parameters

    • color: Color

      The other color

    Returns Color

publictoHSLA

  • toHSLA(): string
  • Return HSLA representation of a color.


    Returns string

publictoHex

  • toHex(): string
  • Return Hex representation of a color.


    Returns string

publictoRGBA

  • toRGBA(): string
  • Return RGBA representation of a color.


    Returns string

publictoString

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


    Parameters

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

      Color representation, accepts: rgb, hsl, or hex

    Returns string

publicstaticfromHSL

  • 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]

    • a: number = 1.0

      Alpha is represented [0-1]

    Returns Color

publicstaticfromHex

  • 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

publicstaticfromRGB

  • 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)

    • optionala: number

      The alpha component of color (0-1.0)

    Returns Color

publicstaticfromRGBString

  • 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