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

Defines an RGBA color (with alpha chanel).

Implements

Constructors

new Color()

new Color(hexCode): Color

Parameters

hexCode

string

Hex code in the RGB ("#FF0000") or RGBA ("#FF0000FF") formats.

Returns

Color

new Color()

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

Parameters

r?

number

Red component.

g?

number

Green component.

b?

number

Blue component.

a?

number

Alpha component.

Returns

Color

Accessors

a

Get Signature

get a(): number

Returns alpha component of color.

Returns

number

Set Signature

set a(a): void

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

Parameters

a

number

Alpha component.

Returns

void

Alpha component.

Implementation of

BaseRGBA.a


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

BaseRGBA.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

BaseRGBA.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

BaseRGBA.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


getValue()

getValue(index): number

Gets individual components of this object.

Parameters

index

number

Component index. Should be in [0, 3] range.

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


isNull()

isNull(): boolean

Returns true if color components of this object is not initialized (i.e. was created using empty constructor). Otherwise returns false.

Returns

boolean


setA()

setA(a): this

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

Parameters

a

number

Alpha component.

Returns

this


setB()

setB(b): this

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

Parameters

b

number

Blue component.

Returns

this


setG()

setG(g): this

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

Parameters

g

number

Green component.

Returns

this


setR()

setR(r): this

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

Parameters

r

number

Red component.

Returns

this


setValue()

setValue(index, value): this

Sets individual components of this object.

Parameters

index

number

Component index. Should be in [0, 3] range.

value

number

Component value. Should be in [0, 1] range.

Returns

this


setValues()

setValues(r?, g?, b?, a?): this

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

Parameters

r?

number

Red component.

g?

number

Green component.

b?

number

Blue component.

a?

number

Alpha component.

Returns

this


toJSON()

toJSON(): BaseRGBA

Returns JSON representation of the color.

Returns

BaseRGBA


toRGB()

toRGB(): number

Returns hex code of this color in RGB format.

Returns

number


toRGBA()

toRGBA(): number

Returns hex code of this color in RGBA format.

Returns

number


toString()

toString(): string

Returns string representation of the color.

Returns

string


fromRGB()

Call Signature

static fromRGB(rgb): Color

Creates new Color object from object implementing BaseRGB interface.

Parameters

rgb

BaseRGB

Object implementing BaseRGB interface.

Returns

Color

Call Signature

static fromRGB(rgb): Color

Creates new Color object from hex code.

Parameters

rgb

number

Hex code in the RGB format.

Returns

Color


fromRGBA()

Call Signature

static fromRGBA(rgba): Color

Creates new Color object from object implementing BaseRGBA interface.

Parameters

rgba

BaseRGBA

Object implementing BaseRGBA interface.

Returns

Color

Call Signature

static fromRGBA(rgba): Color

Creates new Color object from hex code.

Parameters

rgba

number

Hex code in the RGBA format.

Returns

Color