Options
All
  • Public
  • Public/Protected
  • All
Menu

A representation of a color in hexadecimal format. This class provides methods for transformations and manipulations of colors.

Hierarchy

  • Number
    • Color

Index

Constructors

  • Parameters

    • Optional value: any

    Returns utils.Color

Accessors

  • get css(): string
  • A CSS-compatible color string. An alias for Color#toString.

    Returns string

  • get rgb(): [number, number, number]
  • The color represented as an RGB array.

    Returns [number, number, number]

  • get r(): number
  • The numeric value of the red channel between [0, 1].

    Returns number

  • get g(): number
  • The numeric value of the green channel between [0, 1].

    Returns number

  • get b(): number
  • The numeric value of the blue channel between [0, 1].

    Returns number

  • get maximum(): number
  • The maximum value of all channels.

    Returns number

  • get minimum(): number
  • The minimum value of all channels.

    Returns number

  • get littleEndian(): number
  • Get the value of this color in little endian format.

    Returns number

  • get hsv(): [number, number, number]
  • The color represented as an HSV array. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 1] and returns h, s, and v in the set [0, 1].

    Returns [number, number, number]

Methods

  • toString(radix: any): string
  • override

    Parameters

    • radix: any

    Returns string

  • Test whether this color equals some other color

    Parameters

    • other: number | utils.Color

      Some other color or hex number

    Returns boolean

    Are the colors equal?

  • toRGBA(alpha: number): string
  • Get a CSS-compatible RGBA color string.

    Parameters

    • alpha: number

      The desired alpha in the range [0, 1]

    Returns string

    A CSS-compatible RGBA string

  • Mix this Color with some other Color using a provided interpolation weight.

    Parameters

    • other: utils.Color

      Some other Color to mix with

    • weight: number

      The mixing weight placed on this color where weight is placed on the other color

    Returns utils.Color

    The resulting mixed Color

  • Multiply this Color by another Color or a static scalar.

    Parameters

    • other: number | utils.Color

      Some other Color or a static scalar.

    Returns utils.Color

    The resulting Color.

  • Add this Color by another Color or a static scalar.

    Parameters

    • other: number | utils.Color

      Some other Color or a static scalar.

    Returns utils.Color

    The resulting Color.

  • Subtract this Color by another Color or a static scalar.

    Parameters

    • other: number | utils.Color

      Some other Color or a static scalar.

    Returns utils.Color

    The resulting Color.

  • Max this color by another Color or a static scalar.

    Parameters

    • other: number | utils.Color

      Some other Color or a static scalar.

    Returns utils.Color

    The resulting Color.

  • Min this color by another Color or a static scalar.

    Parameters

    • other: number | utils.Color

      Some other Color or a static scalar.

    Returns utils.Color

    The resulting Color.

  • [iterator](): Generator<number, any, any>
  • Iterating over a Color is equivalent to iterating over its [r,g,b] color channels.

    Returns Generator<number, any, any>

  • from(color: string | number | number[]): number | utils.Color
  • Create a Color instance from an RGB array.

    Parameters

    • color: string | number | number[]

      A color input

    Returns number | utils.Color

    The hex color instance or NaN

  • Create a Color instance from a color string which either includes or does not include a leading #.

    Parameters

    • color: string

      A color string

    Returns utils.Color

    The hex color instance

  • fromRGB(rgb: [number, number, number]): utils.Color
  • Create a Color instance from an RGB array.

    Parameters

    • rgb: [number, number, number]

      An RGB tuple

    Returns utils.Color

    The hex color instance

  • fromHSV(hsv: [number, number, number]): utils.Color
  • Create a Color instance from an HSV array. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are contained in the set [0, 1].

    Parameters

    • hsv: [number, number, number]

      An HSV tuple

    Returns utils.Color

    The hex color instance