Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

  • create(r: number, g: number, b: number, a?: number): Color
  • Constructs a new color with the given red, green, blue and alpha values. If alpha is undefined, defaults to 1.

    Parameters

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

    Returns Color

  • fromArray(rgba: number[] | Uint8ClampedArray): Color
  • Converts an array of four values to a Color. The sequence of the array is expected to be [r, g, b] or [r, g, b, a].

    Parameters

    • rgba: number[] | Uint8ClampedArray

    Returns Color

  • fromCss(css: string): undefined | Color
  • Creates a Color from a CSS color value. This function currently only supports rgb(255, 255, 255), rgba(255, 255, 255, 0.5) or "#FFFFFF". Returns undefined if the color cannot be parsed.

    Parameters

    • css: string

    Returns undefined | Color

  • fromHexString(str: string): undefined | Color
  • Returns a Color from a hex string, or undefined if the color string cannot be parsed. Supports hex strings in the format of "#00FF00", "0x00FF00" or "00FF00".

    Parameters

    • str: string

    Returns undefined | Color

  • fromNumber(num: number): Color
  • Converts a numeric color value containing red, green and blue values to a Color. The alpha channel will default to fully opaque.

    Parameters

    • num: number

    Returns Color

  • isInvisible(color: Color): boolean
  • isOpaque(color: Color): boolean
  • toHexString(color: Omit<Color, "a">): string