Hide menu
Loading...
Searching...
No Matches
Color

Defines an RGB color.

Implements

Constructors

new Color()

new Color(r?, g?, b?): Color

Parameters

r?

number

Red component.

g?

number

Green component.

b?

number

Blue component.

Returns

Color

Accessors

b

Get Signature

get b(): number

Returns blue component of color.

Returns

number

Set Signature

set b(b): void

Sets blue component of color. Value should be in [0, 1] range.

Parameters

b

number

Blue component.

Returns

void

Blue component.

Implementation of

BaseRGB.b


g

Get Signature

get g(): number

Returns green component of color.

Returns

number

Set Signature

set g(g): void

Sets green component of color. Value should be in [0, 1] range.

Parameters

g

number

Green component.

Returns

void

Green component.

Implementation of

BaseRGB.g


r

Get Signature

get r(): number

Returns red component of color.

Returns

number

Set Signature

set r(r): void

Sets red component of color. Value should be in [0, 1] range.

Parameters

r

number

Red component.

Returns

void

Red component.

Implementation of

BaseRGB.r

Methods

clone()

clone(): Color

Creates new Color with components same as this.

Returns

Color


copy()

copy(other): this

Copies components from another color.

Parameters

other

Color

Other color.

Returns

this


hex()

hex(): number

Returns the hexadecimal value of this color which represents RGB.

Returns

number


isEqual()

isEqual(other, tolerance?): boolean

Returns true if other color components are equal to this point components within provided tolerance (1e-5 by default). Returns false otherwise.

Parameters

other

Color

Other color.

tolerance?

number

Components comparison tolerance;

Returns

boolean


setComponents()

setComponents(r?, g?, b?): this

Sets r, g and b components of this object. Values should be in [0, 1] range.

Parameters

r?

number

Red component.

g?

number

Green component.

b?

number

Blue component.

Returns

this


setHex()

setHex(hex): this

Sets color from hex value which represents RGB.

Parameters

hex

number

Hex value.

Returns

this


toJSON()

toJSON(): BaseRGB

Returns JSON representation of the color.

Returns

BaseRGB


toString()

toString(): string

Returns string representation of the color.

Returns

string


fromRGB()

static fromRGB(rgb): Color

Creates new Color object from object implementing BaseRGB interface.

Parameters

rgb

BaseRGB

Object implementing BaseRGB interface.

Returns

Color