Class Color

Represents a color. See also {@link ColorUtils}.

example

var color = new THREE.Color( 0xff0000 );

see

src/math/Color.js

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(color?: Color): Color

Parameters

Returns

Color

constructor(color?: string): Color

Parameters

  • color?: string optional

Returns

Color

constructor(color?: number): Color

Parameters

  • color?: number optional

Returns

Color

constructor(r: number, g: number, b: number): Color

Parameters

  • r: number
  • g: number
  • b: number

Returns

Color

Properties

public b: number

Blue channel value between 0 and 1. Default is 1.

public g: number

Green channel value between 0 and 1. Default is 1.

public r: number

Red channel value between 0 and 1. Default is 1.

Methods

public add(color: Color): Color

Parameters

Returns

Color

public addColors(color1: Color, color2: Color): Color

Parameters

Returns

Color

public addScalar(s: number): Color

Parameters

  • s: number

Returns

Color

public clone(): Color

Clones this color.

Returns

Color

public convertGammaToLinear(): Color

Converts this color from gamma to linear space.

Returns

Color

public convertLinearToGamma(): Color

Converts this color from linear to gamma space.

Returns

Color

public copy(color: Color): Color

Copies given color.

Parameters

  • color: Color

    Color to copy.

Returns

Color

public copyGammaToLinear(color: Color): Color

Copies given color making conversion from gamma to linear space.

Parameters

  • color: Color

    Color to copy.

Returns

Color

public copyLinearToGamma(color: Color): Color

Copies given color making conversion from linear to gamma space.

Parameters

  • color: Color

    Color to copy.

Returns

Color

public equals(color: Color): boolean

Parameters

Returns

boolean

public getHSL(): HSL

Returns

HSL

public getHex(): number

Returns the hexadecimal value of this color.

Returns

number

public getHexString(): string

Returns the string formated hexadecimal value of this color.

Returns

string

public getStyle(): string

Returns the value of this color in CSS context style. Example: rgb(r, g, b)

Returns

string

public lerp(color: Color, alpha: number): Color

Parameters

  • color: Color
  • alpha: number

Returns

Color

public multiply(color: Color): Color

Parameters

Returns

Color

public multiplyScalar(s: number): Color

Parameters

  • s: number

Returns

Color

public offsetHSL(h: number, s: number, l: number): Color

Parameters

  • h: number
  • s: number
  • l: number

Returns

Color

public set(color: Color): Color

Parameters

Returns

Color

public set(color: number): Color

Parameters

  • color: number

Returns

Color

public set(color: string): Color

Parameters

  • color: string

Returns

Color

public setHSL(h: number, s: number, l: number): Color

Sets this color from HSL values. Based on MochiKit implementation by Bob Ippolito.

Parameters

  • h: number

    Hue channel value between 0 and 1.

  • s: number

    Saturation value channel between 0 and 1.

  • l: number

    Value channel value between 0 and 1.

Returns

Color

public setHex(hex: number): Color

Parameters

  • hex: number

Returns

Color

public setRGB(r: number, g: number, b: number): Color

Sets this color from RGB values.

Parameters

  • r: number

    Red channel value between 0 and 1.

  • g: number

    Green channel value between 0 and 1.

  • b: number

    Blue channel value between 0 and 1.

Returns

Color

public setStyle(style: string): Color

Sets this color from a CSS context style string.

Parameters

  • style: string

Returns

Color