Skip to content

Class: Color

RGBA Color Object

Constructors

Properties

Accessors

Methods

Constructors

constructor

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

create new color instance

Parameters

NameTypeDefault valueDescription
rnumber1.0red channel
gnumber1.0green channel
bnumber1.0blue channel
anumber1.0alpha channel

Returns

Color

Defined in

src/math/Color.ts:92

Properties

COLOR_RED

Static COLOR_RED: Color

red color

Defined in

src/math/Color.ts:10


COLOR_GREEN

Static COLOR_GREEN: Color

green color

Defined in

src/math/Color.ts:15


COLOR_BLUE

Static COLOR_BLUE: Color

blue color

Defined in

src/math/Color.ts:20


COLOR_WHITE

Static COLOR_WHITE: Color

white color

Defined in

src/math/Color.ts:25


r

r: number = 0

red channel

Defined in

src/math/Color.ts:68


g

g: number = 0

green channel

Defined in

src/math/Color.ts:73


b

b: number = 0

blue channel

Defined in

src/math/Color.ts:78


a

a: number = 0

alpha channel

Defined in

src/math/Color.ts:83


PRIMARY

Static PRIMARY: number = 0x3f51b5

Defined in

src/math/Color.ts:352


PRIMARYDARK

Static PRIMARYDARK: number = 0x303f9f

Defined in

src/math/Color.ts:353


ACCENT

Static ACCENT: number = 0xff4081

Defined in

src/math/Color.ts:354


WHITE

Static WHITE: number = 0xffffff

Defined in

src/math/Color.ts:356


IVORY

Static IVORY: number = 0xfffff0

Defined in

src/math/Color.ts:357


LIGHTYELLOW

Static LIGHTYELLOW: number = 0xffffe0

Defined in

src/math/Color.ts:358


YELLOW

Static YELLOW: number = 0xffff00

Defined in

src/math/Color.ts:359


SNOW

Static SNOW: number = 0xfffafa

Defined in

src/math/Color.ts:360


FLORALWHITE

Static FLORALWHITE: number = 0xfffaf0

Defined in

src/math/Color.ts:361


LEMONCHIFFON

Static LEMONCHIFFON: number = 0xfffacd

Defined in

src/math/Color.ts:362


CORNSILK

Static CORNSILK: number = 0xfff8dc

Defined in

src/math/Color.ts:363


SEASHELL

Static SEASHELL: number = 0xfff5ee

Defined in

src/math/Color.ts:364


LAVENDERBLUSH

Static LAVENDERBLUSH: number = 0xfff0f5

Defined in

src/math/Color.ts:365


PAPAYAWHIP

Static PAPAYAWHIP: number = 0xffefd5

Defined in

src/math/Color.ts:366


BLANCHEDALMOND

Static BLANCHEDALMOND: number = 0xffebcd

Defined in

src/math/Color.ts:367


MISTYROSE

Static MISTYROSE: number = 0xffe4e1

Defined in

src/math/Color.ts:368


BISQUE

Static BISQUE: number = 0xffe4c4

Defined in

src/math/Color.ts:369


MOCCASIN

Static MOCCASIN: number = 0xffe4b5

Defined in

src/math/Color.ts:370


Static NAVAJOWHITE: number = 0xffdead

Defined in

src/math/Color.ts:371


PEACHPUFF

Static PEACHPUFF: number = 0xffdab9

Defined in

src/math/Color.ts:372


GOLD

Static GOLD: number = 0xffd700

Defined in

src/math/Color.ts:373


PINK

Static PINK: number = 0xffc0cb

Defined in

src/math/Color.ts:374


LIGHTPINK

Static LIGHTPINK: number = 0xffb6c1

Defined in

src/math/Color.ts:375


ORANGE

Static ORANGE: number = 0xffa500

Defined in

src/math/Color.ts:376


LIGHTSALMON

Static LIGHTSALMON: number = 0xffa07a

Defined in

src/math/Color.ts:377


DARKORANGE

Static DARKORANGE: number = 0xff8c00

Defined in

src/math/Color.ts:378


CORAL

Static CORAL: number = 0xff7f50

Defined in

src/math/Color.ts:379


HOTPINK

Static HOTPINK: number = 0xff69b4

Defined in

src/math/Color.ts:380


TOMATO

Static TOMATO: number = 0xff6347

Defined in

src/math/Color.ts:381


ORANGERED

Static ORANGERED: number = 0xff4500

Defined in

src/math/Color.ts:382


DEEPPINK

Static DEEPPINK: number = 0xff1493

Defined in

src/math/Color.ts:383


FUCHSIA

Static FUCHSIA: number = 0xff00ff

Defined in

src/math/Color.ts:384


MAGENTA

Static MAGENTA: number = 0xff00ff

Defined in

src/math/Color.ts:385


RED

Static RED: number = 0xff0000

Defined in

src/math/Color.ts:386


OLDLACE

Static OLDLACE: number = 0xfdf5e6

Defined in

src/math/Color.ts:387


LIGHTGOLDENRODYELLOW

Static LIGHTGOLDENRODYELLOW: number = 0xfafad2

Defined in

src/math/Color.ts:388


LINEN

Static LINEN: number = 0xfaf0e6

Defined in

src/math/Color.ts:389


ANTIQUEWHITE

Static ANTIQUEWHITE: number = 0xfaebd7

Defined in

src/math/Color.ts:390


SALMON

Static SALMON: number = 0xfa8072

Defined in

src/math/Color.ts:391


GHOSTWHITE

Static GHOSTWHITE: number = 0xf8f8ff

Defined in

src/math/Color.ts:392


MINTCREAM

Static MINTCREAM: number = 0xf5fffa

Defined in

src/math/Color.ts:393


WHITESMOKE

Static WHITESMOKE: number = 0xf5f5f5

Defined in

src/math/Color.ts:394


BEIGE

Static BEIGE: number = 0xf5f5dc

Defined in

src/math/Color.ts:395


WHEAT

Static WHEAT: number = 0xf5deb3

Defined in

src/math/Color.ts:396


SANDYBROWN

Static SANDYBROWN: number = 0xf4a460

Defined in

src/math/Color.ts:397


AZURE

Static AZURE: number = 0xf0ffff

Defined in

src/math/Color.ts:398


HONEYDEW

Static HONEYDEW: number = 0xf0fff0

Defined in

src/math/Color.ts:399


ALICEBLUE

Static ALICEBLUE: number = 0xf0f8ff

Defined in

src/math/Color.ts:400


KHAKI

Static KHAKI: number = 0xf0e68c

Defined in

src/math/Color.ts:401


LIGHTCORAL

Static LIGHTCORAL: number = 0xf08080

Defined in

src/math/Color.ts:402


PALEGOLDENROD

Static PALEGOLDENROD: number = 0xeee8aa

Defined in

src/math/Color.ts:403


VIOLET

Static VIOLET: number = 0xee82ee

Defined in

src/math/Color.ts:404


DARKSALMON

Static DARKSALMON: number = 0xe9967a

Defined in

src/math/Color.ts:405


LAVENDER

Static LAVENDER: number = 0xe6e6fa

Defined in

src/math/Color.ts:406


LIGHTCYAN

Static LIGHTCYAN: number = 0xe0ffff

Defined in

src/math/Color.ts:407


BURLYWOOD

Static BURLYWOOD: number = 0xdeb887

Defined in

src/math/Color.ts:408


PLUM

Static PLUM: number = 0xdda0dd

Defined in

src/math/Color.ts:409


GAINSBORO

Static GAINSBORO: number = 0xdcdcdc

Defined in

src/math/Color.ts:410


CRIMSON

Static CRIMSON: number = 0xdc143c

Defined in

src/math/Color.ts:411


PALEVIOLETRED

Static PALEVIOLETRED: number = 0xdb7093

Defined in

src/math/Color.ts:412


GOLDENROD

Static GOLDENROD: number = 0xdaa520

Defined in

src/math/Color.ts:414


ORCHID

Static ORCHID: number = 0xda70d6

Defined in

src/math/Color.ts:415


THISTLE

Static THISTLE: number = 0xd8bfd8

Defined in

src/math/Color.ts:416


LIGHTGREY

Static LIGHTGREY: number = 0xd3d3d3

Defined in

src/math/Color.ts:417


TAN

Static TAN: number = 0xd2b48c

Defined in

src/math/Color.ts:418


CHOCOLATE

Static CHOCOLATE: number = 0xd2691e

Defined in

src/math/Color.ts:419


PERU

Static PERU: number = 0xcd853f

Defined in

src/math/Color.ts:420


INDIANRED

Static INDIANRED: number = 0xcd5c5c

Defined in

src/math/Color.ts:421


MEDIUMVIOLETRED

Static MEDIUMVIOLETRED: number = 0xc71585

Defined in

src/math/Color.ts:422


SILVER

Static SILVER: number = 0xc0c0c0

Defined in

src/math/Color.ts:423


DARKKHAKI

Static DARKKHAKI: number = 0xbdb76b

Defined in

src/math/Color.ts:424


ROSYBROWN

Static ROSYBROWN: number = 0xbc8f8f

Defined in

src/math/Color.ts:425


MEDIUMORCHID

Static MEDIUMORCHID: number = 0xba55d3

Defined in

src/math/Color.ts:426


DARKGOLDENROD

Static DARKGOLDENROD: number = 0xb8860b

Defined in

src/math/Color.ts:427


FIREBRICK

Static FIREBRICK: number = 0xb22222

Defined in

src/math/Color.ts:428


POWDERBLUE

Static POWDERBLUE: number = 0xb0e0e6

Defined in

src/math/Color.ts:429


LIGHTSTEELBLUE

Static LIGHTSTEELBLUE: number = 0xb0c4de

Defined in

src/math/Color.ts:430


PALETURQUOISE

Static PALETURQUOISE: number = 0xafeeee

Defined in

src/math/Color.ts:431


GREENYELLOW

Static GREENYELLOW: number = 0xadff2f

Defined in

src/math/Color.ts:432


LIGHTBLUE

Static LIGHTBLUE: number = 0xadd8e6

Defined in

src/math/Color.ts:433


DARKGRAY

Static DARKGRAY: number = 0xa9a9a9

Defined in

src/math/Color.ts:434


BROWN

Static BROWN: number = 0xa52a2a

Defined in

src/math/Color.ts:435


SIENNA

Static SIENNA: number = 0xa0522d

Defined in

src/math/Color.ts:436


DARKORCHID

Static DARKORCHID: number = 0x9932cc

Defined in

src/math/Color.ts:437


PALEGREEN

Static PALEGREEN: number = 0x98fb98

Defined in

src/math/Color.ts:438


DARKVIOLET

Static DARKVIOLET: number = 0x9400d3

Defined in

src/math/Color.ts:439


MEDIUMPURPLE

Static MEDIUMPURPLE: number = 0x9370db

Defined in

src/math/Color.ts:440


LIGHTGREEN

Static LIGHTGREEN: number = 0x90ee90

Defined in

src/math/Color.ts:441


DARKSEAGREEN

Static DARKSEAGREEN: number = 0x8fbc8f

Defined in

src/math/Color.ts:442


SADDLEBROWN

Static SADDLEBROWN: number = 0x8b4513

Defined in

src/math/Color.ts:443


DARKMAGENTA

Static DARKMAGENTA: number = 0x8b008b

Defined in

src/math/Color.ts:444


DARKRED

Static DARKRED: number = 0x8b0000

Defined in

src/math/Color.ts:445


BLUEVIOLET

Static BLUEVIOLET: number = 0x8a2be2

Defined in

src/math/Color.ts:446


LIGHTSKYBLUE

Static LIGHTSKYBLUE: number = 0x87cefa

Defined in

src/math/Color.ts:447


SKYBLUE

Static SKYBLUE: number = 0x87ceeb

Defined in

src/math/Color.ts:448


GRAY

Static GRAY: number = 0x808080

Defined in

src/math/Color.ts:449


OLIVE

Static OLIVE: number = 0x808000

Defined in

src/math/Color.ts:450


PURPLE

Static PURPLE: number = 0x800080

Defined in

src/math/Color.ts:451


MAROON

Static MAROON: number = 0x800000

Defined in

src/math/Color.ts:452


AQUAMARINE

Static AQUAMARINE: number = 0x7fffd4

Defined in

src/math/Color.ts:453


CHARTREUSE

Static CHARTREUSE: number = 0x7fff00

Defined in

src/math/Color.ts:454


LAWNGREEN

Static LAWNGREEN: number = 0x7cfc00

Defined in

src/math/Color.ts:455


MEDIUMSLATEBLUE

Static MEDIUMSLATEBLUE: number = 0x7b68ee

Defined in

src/math/Color.ts:456


LIGHTSLATEGRAY

Static LIGHTSLATEGRAY: number = 0x778899

Defined in

src/math/Color.ts:457


SLATEGRAY

Static SLATEGRAY: number = 0x708090

Defined in

src/math/Color.ts:458


OLIVEDRAB

Static OLIVEDRAB: number = 0x6b8e23

Defined in

src/math/Color.ts:459


SLATEBLUE

Static SLATEBLUE: number = 0x6a5acd

Defined in

src/math/Color.ts:460


DIMGRAY

Static DIMGRAY: number = 0x696969

Defined in

src/math/Color.ts:461


MEDIUMAQUAMARINE

Static MEDIUMAQUAMARINE: number = 0x66cdaa

Defined in

src/math/Color.ts:462


CORNFLOWERBLUE

Static CORNFLOWERBLUE: number = 0x6495ed

Defined in

src/math/Color.ts:463


CADETBLUE

Static CADETBLUE: number = 0x5f9ea0

Defined in

src/math/Color.ts:464


DARKOLIVEGREEN

Static DARKOLIVEGREEN: number = 0x556b2f

Defined in

src/math/Color.ts:465


INDIGO

Static INDIGO: number = 0x4b0082

Defined in

src/math/Color.ts:466


MEDIUMTURQUOISE

Static MEDIUMTURQUOISE: number = 0x48d1cc

Defined in

src/math/Color.ts:467


DARKSLATEBLUE

Static DARKSLATEBLUE: number = 0x483d8b

Defined in

src/math/Color.ts:468


STEELBLUE

Static STEELBLUE: number = 0x4682b4

Defined in

src/math/Color.ts:469


ROYALBLUE

Static ROYALBLUE: number = 0x4169e1

Defined in

src/math/Color.ts:470


TURQUOISE

Static TURQUOISE: number = 0x40e0d0

Defined in

src/math/Color.ts:471


MEDIUMSEAGREEN

Static MEDIUMSEAGREEN: number = 0x3cb371

Defined in

src/math/Color.ts:472


LIMEGREEN

Static LIMEGREEN: number = 0x32cd32

Defined in

src/math/Color.ts:473


DARKSLATEGRAY

Static DARKSLATEGRAY: number = 0x2f4f4f

Defined in

src/math/Color.ts:474


SEAGREEN

Static SEAGREEN: number = 0x2e8b57

Defined in

src/math/Color.ts:475


FORESTGREEN

Static FORESTGREEN: number = 0x228b22

Defined in

src/math/Color.ts:476


LIGHTSEAGREEN

Static LIGHTSEAGREEN: number = 0x20b2aa

Defined in

src/math/Color.ts:477


DODGERBLUE

Static DODGERBLUE: number = 0x1e90ff

Defined in

src/math/Color.ts:478


MIDNIGHTBLUE

Static MIDNIGHTBLUE: number = 0x191970

Defined in

src/math/Color.ts:479


AQUA

Static AQUA: number = 0x00ffff

Defined in

src/math/Color.ts:480


CYAN

Static CYAN: number = 0x00ffff

Defined in

src/math/Color.ts:481


SPRINGGREEN

Static SPRINGGREEN: number = 0x00ff7f

Defined in

src/math/Color.ts:482


LIME

Static LIME: number = 0x00ff00

Defined in

src/math/Color.ts:483


MEDIUMSPRINGGREEN

Static MEDIUMSPRINGGREEN: number = 0x00fa9a

Defined in

src/math/Color.ts:484


DARKTURQUOISE

Static DARKTURQUOISE: number = 0x00ced1

Defined in

src/math/Color.ts:485


DEEPSKYBLUE

Static DEEPSKYBLUE: number = 0x00bfff

Defined in

src/math/Color.ts:486


DARKCYAN

Static DARKCYAN: number = 0x008b8b

Defined in

src/math/Color.ts:487


TEAL

Static TEAL: number = 0x008080

Defined in

src/math/Color.ts:488


GREEN

Static GREEN: number = 0x008000

Defined in

src/math/Color.ts:489


DARKGREEN

Static DARKGREEN: number = 0x006400

Defined in

src/math/Color.ts:490


BLUE

Static BLUE: number = 0x0000ff

Defined in

src/math/Color.ts:491


MEDIUMBLUE

Static MEDIUMBLUE: number = 0x0000cd

Defined in

src/math/Color.ts:492


DARKBLUE

Static DARKBLUE: number = 0x00008b

Defined in

src/math/Color.ts:493


Static NAVY: number = 0x000080

Defined in

src/math/Color.ts:494


BLACK

Static BLACK: number = 0x000000

Defined in

src/math/Color.ts:495

Accessors

rgb

get rgb(): number[]

get rgb to array

Returns

number[]

Defined in

src/math/Color.ts:250

set rgb(c): void

set rgb by array

Parameters

NameType
cnumber[]

Returns

void

Defined in

src/math/Color.ts:257


rgba

get rgba(): number[]

get rgba to array

Returns

number[]

Defined in

src/math/Color.ts:264

set rgba(c): void

set rgb by array

Parameters

NameType
cnumber[]

Returns

void

Defined in

src/math/Color.ts:271

Methods

convertToHDRRGB

convertToHDRRGB(): Color

convert to hdr color , channel a is intensity

Returns

Color

Defined in

src/math/Color.ts:99


unSerialized

unSerialized(data): this

unSerialized color by data

Parameters

NameType
dataany

Returns

this

Defined in

src/math/Color.ts:111


hexToRGB

hexToRGB(value): Color

update this color rgb from hexadecimal no alpha

Parameters

NameType
valuenumber

Returns

Color

Defined in

src/math/Color.ts:123


hexToRGBA

hexToRGBA(value): Color

update this color rgb from hexadecimal has alpha

Parameters

NameType
valuenumber

Returns

Color

Defined in

src/math/Color.ts:135


random

random(base?): Color

random on color

Parameters

NameTypeDefault value
basenumber1.0

Returns

Color

Defined in

src/math/Color.ts:147


randomRGB

randomRGB(seedR?, seedG?, seedB?, baseR?, baseG?, baseB?): Color

Parameters

NameTypeDefault value
seedRnumber0.5
seedGnumber0.5
seedBnumber0.5
baseRnumber0.5
baseGnumber0.5
baseBnumber0.5

Returns

Color

Defined in

src/math/Color.ts:156


randomGray

randomGray(base?, random?): Color

random on color

Parameters

NameTypeDefault value
basenumber0.5
randomnumber0.5

Returns

Color

Defined in

src/math/Color.ts:170


setTo

setTo(r, g, b, a): void

set rgba to this color

Parameters

NameTypeDescription
rnumberred channel
gnumbergreen channel
bnumberblue channel
anumberalpha channel

Returns

void

Defined in

src/math/Color.ts:187


setHex

setHex(hex): void

update this color rgba from hexadecimal

Parameters

NameTypeDescription
hexstringhex string.

Returns

void

Defined in

src/math/Color.ts:198


getHex

getHex(): string

convert this color to hex string code

Returns

string

Defined in

src/math/Color.ts:234


clone

clone(): Color

clone this color

Returns

Color

Defined in

src/math/Color.ts:279


copyFrom

copyFrom(src): this

copy color from source color

Parameters

NameType
srcColor

Returns

this

Defined in

src/math/Color.ts:287


copyFromArray

copyFromArray(arr, scalar?): Color

copy color from array

Parameters

NameTypeDefault valueDescription
arrnumber[]undefined[ 255 , 255 , 255 , 255 ]
scalarnumber255

Returns

Color

Defined in

src/math/Color.ts:301


copyFromVector

copyFromVector(value): this

copy color from vector3 or vector4

Parameters

NameTypeDescription
valueObject{ x: number, y: number, z: number, w?: number }
value.xnumber-
value.ynumber-
value.znumber-
value.w?number-

Returns

this

Defined in

src/math/Color.ts:315


hexRGBColor

hexRGBColor(hexColor, dst?): Color

update this color rgb from hexadecimal no alpha

Parameters

NameTypeDefault valueDescription
hexColornumberundefinedrgb color
dstColornullref out color

Returns

Color

Defined in

src/math/Color.ts:328


lerp

lerp(v, c1, c2, target?): Color

lerp two color

Parameters

NameType
vnumber
c1Color
c2Color
target?Color

Returns

Color

Defined in

src/math/Color.ts:342