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.

  • applyRGB(vec3: number[]): void
  • Set an rgb array with the rgb values contained in this Color class.

    Parameters

    • vec3: number[]

      Receive the result. Must be an array with at least a length of 3.

    Returns void

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

  • mix(color1: number, color2: number, weight: number): number
  • Apply a linear interpolation between two colors, according to the weight.

    Parameters

    • color1: number

      The first color to mix.

    • color2: number

      The second color to mix.

    • weight: number

      Weight of the linear interpolation.

    Returns number

    The resulting mixed color

  • multiply(color1: number, color2: number): number
  • Multiply two colors.

    Parameters

    • color1: number

      The first color to multiply.

    • color2: number

      The second color to multiply.

    Returns number

    The result.

  • multiplyScalar(color: number, scalar: number): number
  • Multiply a color by a scalar

    Parameters

    • color: number

      The color to multiply.

    • scalar: number

      A static scalar to multiply with.

    Returns number

    The resulting color as a number.

  • maximize(color1: number, color2: number): number
  • Maximize two colors.

    Parameters

    • color1: number

      The first color.

    • color2: number

      The second color.

    Returns number

    The result.

  • maximizeScalar(color: number, scalar: number): number
  • Maximize a color by a static scalar.

    Parameters

    • color: number

      The color to maximize.

    • scalar: number

      Scalar to maximize with (normalized).

    Returns number

    The resulting color as a number.

  • add(color1: number, color2: number): number
  • Add two colors.

    Parameters

    • color1: number

      The first color.

    • color2: number

      The second color.

    Returns number

    The resulting color as a number.

  • addScalar(color: number, scalar: number): number
  • Add a static scalar to a color.

    Parameters

    • color: number

      The color.

    • scalar: number

      Scalar to add with (normalized).

    Returns number

    The resulting color as a number.

  • subtract(color1: number, color2: number): number
  • Subtract two colors.

    Parameters

    • color1: number

      The first color.

    • color2: number

      The second color.

    Returns number

  • subtractScalar(color: number, scalar: number): number
  • Subtract a color by a static scalar.

    Parameters

    • color: number

      The color.

    • scalar: number

      Scalar to subtract with (normalized).

    Returns number

    The resulting color as a number.

  • minimize(color1: number, color2: number): number
  • Minimize two colors.

    Parameters

    • color1: number

      The first color.

    • color2: number

      The second color.

    Returns number

  • minimizeScalar(color: number, scalar: number): number
  • Minimize a color by a static scalar.

    Parameters

    • color: number

      The color.

    • scalar: number

      Scalar to minimize with (normalized).

    Returns number

  • applyRGB(color: number, vec3: number[]): void
  • Convert a color to RGB and assign values to a passed array.

    Parameters

    • color: number

      The color to convert to RGB values.

    • vec3: number[]

      Receive the result. Must be an array with at least a length of 3.

    Returns void

  • 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

  • fromRGBvalues(r: number, g: number, b: number): utils.Color
  • Create a Color instance from an RGB normalized values.

    Parameters

    • r: number

      The red value

    • g: number

      The green value

    • b: number

      The blue value

    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