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

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

  • get ExcaliburBlue(): Color

Methods

  • Averages the current color with another

    Parameters

    • color: Color

      The other color

    Returns Color

  • 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

  • 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

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

    Returns string

  • 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

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

    Parameters

    • color: Color

      The other color

    Returns Color

  • 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

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

    Parameters

    • color: Color

      The other color

    Returns Color

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

    Returns string

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

    Returns string

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

    Returns string

  • 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

  • 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

  • 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

  • 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

  • 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