Skip to content

@orillusion/core


Class: Color

Defined in: src/math/Color.ts:5

RGBA Color Object

Constructors

Constructor

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

Defined in: src/math/Color.ts:92

create new color instance

Parameters

r?

number = 1.0

red channel

g?

number = 1.0

green channel

b?

number = 1.0

blue channel

a?

number = 1.0

alpha channel

Returns

Color

Properties

COLOR_RED

static COLOR_RED: Color

Defined in: src/math/Color.ts:10

red color


COLOR_GREEN

static COLOR_GREEN: Color

Defined in: src/math/Color.ts:15

green color


COLOR_BLUE

static COLOR_BLUE: Color

Defined in: src/math/Color.ts:20

blue color


COLOR_WHITE

static COLOR_WHITE: Color

Defined in: src/math/Color.ts:25

white color


r

r: number = 0

Defined in: src/math/Color.ts:68

red channel


g

g: number = 0

Defined in: src/math/Color.ts:73

green channel


b

b: number = 0

Defined in: src/math/Color.ts:78

blue channel


a

a: number = 0

Defined in: src/math/Color.ts:83

alpha channel


PRIMARY

static PRIMARY: number = 0x3f51b5

Defined in: src/math/Color.ts:359

Preset color: primary.


PRIMARYDARK

static PRIMARYDARK: number = 0x303f9f

Defined in: src/math/Color.ts:361

Preset color: primary dark.


ACCENT

static ACCENT: number = 0xff4081

Defined in: src/math/Color.ts:363

Preset color: accent.


WHITE

static WHITE: number = 0xffffff

Defined in: src/math/Color.ts:366

Preset color: white.


IVORY

static IVORY: number = 0xfffff0

Defined in: src/math/Color.ts:368

Preset color: ivory.


LIGHTYELLOW

static LIGHTYELLOW: number = 0xffffe0

Defined in: src/math/Color.ts:370

Preset color: light yellow.


YELLOW

static YELLOW: number = 0xffff00

Defined in: src/math/Color.ts:372

Preset color: yellow.


SNOW

static SNOW: number = 0xfffafa

Defined in: src/math/Color.ts:374

Preset color: snow.


FLORALWHITE

static FLORALWHITE: number = 0xfffaf0

Defined in: src/math/Color.ts:376

Preset color: floral white.


LEMONCHIFFON

static LEMONCHIFFON: number = 0xfffacd

Defined in: src/math/Color.ts:378

Preset color: lemon chiffon.


CORNSILK

static CORNSILK: number = 0xfff8dc

Defined in: src/math/Color.ts:380

Preset color: cornsilk.


SEASHELL

static SEASHELL: number = 0xfff5ee

Defined in: src/math/Color.ts:382

Preset color: seashell.


LAVENDERBLUSH

static LAVENDERBLUSH: number = 0xfff0f5

Defined in: src/math/Color.ts:384

Preset color: lavender blush.


PAPAYAWHIP

static PAPAYAWHIP: number = 0xffefd5

Defined in: src/math/Color.ts:386

Preset color: papaya whip.


BLANCHEDALMOND

static BLANCHEDALMOND: number = 0xffebcd

Defined in: src/math/Color.ts:388

Preset color: blanched almond.


MISTYROSE

static MISTYROSE: number = 0xffe4e1

Defined in: src/math/Color.ts:390

Preset color: misty rose.


BISQUE

static BISQUE: number = 0xffe4c4

Defined in: src/math/Color.ts:392

Preset color: bisque.


MOCCASIN

static MOCCASIN: number = 0xffe4b5

Defined in: src/math/Color.ts:394

Preset color: moccasin.


static NAVAJOWHITE: number = 0xffdead

Defined in: src/math/Color.ts:396

Preset color: navajo white.


PEACHPUFF

static PEACHPUFF: number = 0xffdab9

Defined in: src/math/Color.ts:398

Preset color: peach puff.


GOLD

static GOLD: number = 0xffd700

Defined in: src/math/Color.ts:400

Preset color: gold.


PINK

static PINK: number = 0xffc0cb

Defined in: src/math/Color.ts:402

Preset color: pink.


LIGHTPINK

static LIGHTPINK: number = 0xffb6c1

Defined in: src/math/Color.ts:404

Preset color: light pink.


ORANGE

static ORANGE: number = 0xffa500

Defined in: src/math/Color.ts:406

Preset color: orange.


LIGHTSALMON

static LIGHTSALMON: number = 0xffa07a

Defined in: src/math/Color.ts:408

Preset color: light salmon.


DARKORANGE

static DARKORANGE: number = 0xff8c00

Defined in: src/math/Color.ts:410

Preset color: dark orange.


CORAL

static CORAL: number = 0xff7f50

Defined in: src/math/Color.ts:412

Preset color: coral.


HOTPINK

static HOTPINK: number = 0xff69b4

Defined in: src/math/Color.ts:414

Preset color: hot pink.


TOMATO

static TOMATO: number = 0xff6347

Defined in: src/math/Color.ts:416

Preset color: tomato.


ORANGERED

static ORANGERED: number = 0xff4500

Defined in: src/math/Color.ts:418

Preset color: orange red.


DEEPPINK

static DEEPPINK: number = 0xff1493

Defined in: src/math/Color.ts:420

Preset color: deep pink.


FUCHSIA

static FUCHSIA: number = 0xff00ff

Defined in: src/math/Color.ts:422

Preset color: fuchsia.


MAGENTA

static MAGENTA: number = 0xff00ff

Defined in: src/math/Color.ts:424

Preset color: magenta.


RED

static RED: number = 0xff0000

Defined in: src/math/Color.ts:426

Preset color: red.


OLDLACE

static OLDLACE: number = 0xfdf5e6

Defined in: src/math/Color.ts:428

Preset color: old lace.


LIGHTGOLDENRODYELLOW

static LIGHTGOLDENRODYELLOW: number = 0xfafad2

Defined in: src/math/Color.ts:430

Preset color: light goldenrod yellow.


LINEN

static LINEN: number = 0xfaf0e6

Defined in: src/math/Color.ts:432

Preset color: linen.


ANTIQUEWHITE

static ANTIQUEWHITE: number = 0xfaebd7

Defined in: src/math/Color.ts:434

Preset color: antique white.


SALMON

static SALMON: number = 0xfa8072

Defined in: src/math/Color.ts:436

Preset color: salmon.


GHOSTWHITE

static GHOSTWHITE: number = 0xf8f8ff

Defined in: src/math/Color.ts:438

Preset color: ghost white.


MINTCREAM

static MINTCREAM: number = 0xf5fffa

Defined in: src/math/Color.ts:440

Preset color: mint cream.


WHITESMOKE

static WHITESMOKE: number = 0xf5f5f5

Defined in: src/math/Color.ts:442

Preset color: white smoke.


BEIGE

static BEIGE: number = 0xf5f5dc

Defined in: src/math/Color.ts:444

Preset color: beige.


WHEAT

static WHEAT: number = 0xf5deb3

Defined in: src/math/Color.ts:446

Preset color: wheat.


SANDYBROWN

static SANDYBROWN: number = 0xf4a460

Defined in: src/math/Color.ts:448

Preset color: sandy brown.


AZURE

static AZURE: number = 0xf0ffff

Defined in: src/math/Color.ts:450

Preset color: azure.


HONEYDEW

static HONEYDEW: number = 0xf0fff0

Defined in: src/math/Color.ts:452

Preset color: honeydew.


ALICEBLUE

static ALICEBLUE: number = 0xf0f8ff

Defined in: src/math/Color.ts:454

Preset color: alice blue.


KHAKI

static KHAKI: number = 0xf0e68c

Defined in: src/math/Color.ts:456

Preset color: khaki.


LIGHTCORAL

static LIGHTCORAL: number = 0xf08080

Defined in: src/math/Color.ts:458

Preset color: light coral.


PALEGOLDENROD

static PALEGOLDENROD: number = 0xeee8aa

Defined in: src/math/Color.ts:460

Preset color: pale goldenrod.


VIOLET

static VIOLET: number = 0xee82ee

Defined in: src/math/Color.ts:462

Preset color: violet.


DARKSALMON

static DARKSALMON: number = 0xe9967a

Defined in: src/math/Color.ts:464

Preset color: dark salmon.


LAVENDER

static LAVENDER: number = 0xe6e6fa

Defined in: src/math/Color.ts:466

Preset color: lavender.


LIGHTCYAN

static LIGHTCYAN: number = 0xe0ffff

Defined in: src/math/Color.ts:468

Preset color: light cyan.


BURLYWOOD

static BURLYWOOD: number = 0xdeb887

Defined in: src/math/Color.ts:470

Preset color: burlywood.


PLUM

static PLUM: number = 0xdda0dd

Defined in: src/math/Color.ts:472

Preset color: plum.


GAINSBORO

static GAINSBORO: number = 0xdcdcdc

Defined in: src/math/Color.ts:474

Preset color: gainsboro.


CRIMSON

static CRIMSON: number = 0xdc143c

Defined in: src/math/Color.ts:476

Preset color: crimson.


PALEVIOLETRED

static PALEVIOLETRED: number = 0xdb7093

Defined in: src/math/Color.ts:478

Preset color: pale violet red.


GOLDENROD

static GOLDENROD: number = 0xdaa520

Defined in: src/math/Color.ts:481

Preset color: goldenrod.


ORCHID

static ORCHID: number = 0xda70d6

Defined in: src/math/Color.ts:483

Preset color: orchid.


THISTLE

static THISTLE: number = 0xd8bfd8

Defined in: src/math/Color.ts:485

Preset color: thistle.


LIGHTGREY

static LIGHTGREY: number = 0xd3d3d3

Defined in: src/math/Color.ts:487

Preset color: light grey.


TAN

static TAN: number = 0xd2b48c

Defined in: src/math/Color.ts:489

Preset color: tan.


CHOCOLATE

static CHOCOLATE: number = 0xd2691e

Defined in: src/math/Color.ts:491

Preset color: chocolate.


PERU

static PERU: number = 0xcd853f

Defined in: src/math/Color.ts:493

Preset color: peru.


INDIANRED

static INDIANRED: number = 0xcd5c5c

Defined in: src/math/Color.ts:495

Preset color: indian red.


MEDIUMVIOLETRED

static MEDIUMVIOLETRED: number = 0xc71585

Defined in: src/math/Color.ts:497

Preset color: medium violet red.


SILVER

static SILVER: number = 0xc0c0c0

Defined in: src/math/Color.ts:499

Preset color: silver.


DARKKHAKI

static DARKKHAKI: number = 0xbdb76b

Defined in: src/math/Color.ts:501

Preset color: dark khaki.


ROSYBROWN

static ROSYBROWN: number = 0xbc8f8f

Defined in: src/math/Color.ts:503

Preset color: rosy brown.


MEDIUMORCHID

static MEDIUMORCHID: number = 0xba55d3

Defined in: src/math/Color.ts:505

Preset color: medium orchid.


DARKGOLDENROD

static DARKGOLDENROD: number = 0xb8860b

Defined in: src/math/Color.ts:507

Preset color: dark goldenrod.


FIREBRICK

static FIREBRICK: number = 0xb22222

Defined in: src/math/Color.ts:509

Preset color: firebrick.


POWDERBLUE

static POWDERBLUE: number = 0xb0e0e6

Defined in: src/math/Color.ts:511

Preset color: powder blue.


LIGHTSTEELBLUE

static LIGHTSTEELBLUE: number = 0xb0c4de

Defined in: src/math/Color.ts:513

Preset color: light steel blue.


PALETURQUOISE

static PALETURQUOISE: number = 0xafeeee

Defined in: src/math/Color.ts:515

Preset color: pale turquoise.


GREENYELLOW

static GREENYELLOW: number = 0xadff2f

Defined in: src/math/Color.ts:517

Preset color: green yellow.


LIGHTBLUE

static LIGHTBLUE: number = 0xadd8e6

Defined in: src/math/Color.ts:519

Preset color: light blue.


DARKGRAY

static DARKGRAY: number = 0xa9a9a9

Defined in: src/math/Color.ts:521

Preset color: dark gray.


BROWN

static BROWN: number = 0xa52a2a

Defined in: src/math/Color.ts:523

Preset color: brown.


SIENNA

static SIENNA: number = 0xa0522d

Defined in: src/math/Color.ts:525

Preset color: sienna.


DARKORCHID

static DARKORCHID: number = 0x9932cc

Defined in: src/math/Color.ts:527

Preset color: dark orchid.


PALEGREEN

static PALEGREEN: number = 0x98fb98

Defined in: src/math/Color.ts:529

Preset color: pale green.


DARKVIOLET

static DARKVIOLET: number = 0x9400d3

Defined in: src/math/Color.ts:531

Preset color: dark violet.


MEDIUMPURPLE

static MEDIUMPURPLE: number = 0x9370db

Defined in: src/math/Color.ts:533

Preset color: medium purple.


LIGHTGREEN

static LIGHTGREEN: number = 0x90ee90

Defined in: src/math/Color.ts:535

Preset color: light green.


DARKSEAGREEN

static DARKSEAGREEN: number = 0x8fbc8f

Defined in: src/math/Color.ts:537

Preset color: dark sea green.


SADDLEBROWN

static SADDLEBROWN: number = 0x8b4513

Defined in: src/math/Color.ts:539

Preset color: saddle brown.


DARKMAGENTA

static DARKMAGENTA: number = 0x8b008b

Defined in: src/math/Color.ts:541

Preset color: dark magenta.


DARKRED

static DARKRED: number = 0x8b0000

Defined in: src/math/Color.ts:543

Preset color: dark red.


BLUEVIOLET

static BLUEVIOLET: number = 0x8a2be2

Defined in: src/math/Color.ts:545

Preset color: blue violet.


LIGHTSKYBLUE

static LIGHTSKYBLUE: number = 0x87cefa

Defined in: src/math/Color.ts:547

Preset color: light sky blue.


SKYBLUE

static SKYBLUE: number = 0x87ceeb

Defined in: src/math/Color.ts:549

Preset color: sky blue.


GRAY

static GRAY: number = 0x808080

Defined in: src/math/Color.ts:551

Preset color: gray.


OLIVE

static OLIVE: number = 0x808000

Defined in: src/math/Color.ts:553

Preset color: olive.


PURPLE

static PURPLE: number = 0x800080

Defined in: src/math/Color.ts:555

Preset color: purple.


MAROON

static MAROON: number = 0x800000

Defined in: src/math/Color.ts:557

Preset color: maroon.


AQUAMARINE

static AQUAMARINE: number = 0x7fffd4

Defined in: src/math/Color.ts:559

Preset color: aquamarine.


CHARTREUSE

static CHARTREUSE: number = 0x7fff00

Defined in: src/math/Color.ts:561

Preset color: chartreuse.


LAWNGREEN

static LAWNGREEN: number = 0x7cfc00

Defined in: src/math/Color.ts:563

Preset color: lawn green.


MEDIUMSLATEBLUE

static MEDIUMSLATEBLUE: number = 0x7b68ee

Defined in: src/math/Color.ts:565

Preset color: medium slate blue.


LIGHTSLATEGRAY

static LIGHTSLATEGRAY: number = 0x778899

Defined in: src/math/Color.ts:567

Preset color: light slate gray.


SLATEGRAY

static SLATEGRAY: number = 0x708090

Defined in: src/math/Color.ts:569

Preset color: slate gray.


OLIVEDRAB

static OLIVEDRAB: number = 0x6b8e23

Defined in: src/math/Color.ts:571

Preset color: olive drab.


SLATEBLUE

static SLATEBLUE: number = 0x6a5acd

Defined in: src/math/Color.ts:573

Preset color: slate blue.


DIMGRAY

static DIMGRAY: number = 0x696969

Defined in: src/math/Color.ts:575

Preset color: dim gray.


MEDIUMAQUAMARINE

static MEDIUMAQUAMARINE: number = 0x66cdaa

Defined in: src/math/Color.ts:577

Preset color: medium aquamarine.


CORNFLOWERBLUE

static CORNFLOWERBLUE: number = 0x6495ed

Defined in: src/math/Color.ts:579

Preset color: cornflower blue.


CADETBLUE

static CADETBLUE: number = 0x5f9ea0

Defined in: src/math/Color.ts:581

Preset color: cadet blue.


DARKOLIVEGREEN

static DARKOLIVEGREEN: number = 0x556b2f

Defined in: src/math/Color.ts:583

Preset color: dark olive green.


INDIGO

static INDIGO: number = 0x4b0082

Defined in: src/math/Color.ts:585

Preset color: indigo.


MEDIUMTURQUOISE

static MEDIUMTURQUOISE: number = 0x48d1cc

Defined in: src/math/Color.ts:587

Preset color: medium turquoise.


DARKSLATEBLUE

static DARKSLATEBLUE: number = 0x483d8b

Defined in: src/math/Color.ts:589

Preset color: dark slate blue.


STEELBLUE

static STEELBLUE: number = 0x4682b4

Defined in: src/math/Color.ts:591

Preset color: steel blue.


ROYALBLUE

static ROYALBLUE: number = 0x4169e1

Defined in: src/math/Color.ts:593

Preset color: royal blue.


TURQUOISE

static TURQUOISE: number = 0x40e0d0

Defined in: src/math/Color.ts:595

Preset color: turquoise.


MEDIUMSEAGREEN

static MEDIUMSEAGREEN: number = 0x3cb371

Defined in: src/math/Color.ts:597

Preset color: medium sea green.


LIMEGREEN

static LIMEGREEN: number = 0x32cd32

Defined in: src/math/Color.ts:599

Preset color: lime green.


DARKSLATEGRAY

static DARKSLATEGRAY: number = 0x2f4f4f

Defined in: src/math/Color.ts:601

Preset color: dark slate gray.


SEAGREEN

static SEAGREEN: number = 0x2e8b57

Defined in: src/math/Color.ts:603

Preset color: sea green.


FORESTGREEN

static FORESTGREEN: number = 0x228b22

Defined in: src/math/Color.ts:605

Preset color: forest green.


LIGHTSEAGREEN

static LIGHTSEAGREEN: number = 0x20b2aa

Defined in: src/math/Color.ts:607

Preset color: light sea green.


DODGERBLUE

static DODGERBLUE: number = 0x1e90ff

Defined in: src/math/Color.ts:609

Preset color: dodger blue.


MIDNIGHTBLUE

static MIDNIGHTBLUE: number = 0x191970

Defined in: src/math/Color.ts:611

Preset color: midnight blue.


AQUA

static AQUA: number = 0x00ffff

Defined in: src/math/Color.ts:613

Preset color: aqua.


CYAN

static CYAN: number = 0x00ffff

Defined in: src/math/Color.ts:615

Preset color: cyan.


SPRINGGREEN

static SPRINGGREEN: number = 0x00ff7f

Defined in: src/math/Color.ts:617

Preset color: spring green.


LIME

static LIME: number = 0x00ff00

Defined in: src/math/Color.ts:619

Preset color: lime.


MEDIUMSPRINGGREEN

static MEDIUMSPRINGGREEN: number = 0x00fa9a

Defined in: src/math/Color.ts:621

Preset color: medium spring green.


DARKTURQUOISE

static DARKTURQUOISE: number = 0x00ced1

Defined in: src/math/Color.ts:623

Preset color: dark turquoise.


DEEPSKYBLUE

static DEEPSKYBLUE: number = 0x00bfff

Defined in: src/math/Color.ts:625

Preset color: deep sky blue.


DARKCYAN

static DARKCYAN: number = 0x008b8b

Defined in: src/math/Color.ts:627

Preset color: dark cyan.


TEAL

static TEAL: number = 0x008080

Defined in: src/math/Color.ts:629

Preset color: teal.


GREEN

static GREEN: number = 0x008000

Defined in: src/math/Color.ts:631

Preset color: green.


DARKGREEN

static DARKGREEN: number = 0x006400

Defined in: src/math/Color.ts:633

Preset color: dark green.


BLUE

static BLUE: number = 0x0000ff

Defined in: src/math/Color.ts:635

Preset color: blue.


MEDIUMBLUE

static MEDIUMBLUE: number = 0x0000cd

Defined in: src/math/Color.ts:637

Preset color: medium blue.


DARKBLUE

static DARKBLUE: number = 0x00008b

Defined in: src/math/Color.ts:639

Preset color: dark blue.


static NAVY: number = 0x000080

Defined in: src/math/Color.ts:641

Preset color: navy.


BLACK

static BLACK: number = 0x000000

Defined in: src/math/Color.ts:643

Preset color: black.

Accessors

rgb

Get Signature

get rgb(): number[]

Defined in: src/math/Color.ts:256

get rgb to array

Returns

number[]

Set Signature

set rgb(c): void

Defined in: src/math/Color.ts:263

set rgb by array

Parameters
c

number[]

Returns

void


rgba

Get Signature

get rgba(): number[]

Defined in: src/math/Color.ts:270

get rgba to array

Returns

number[]

Set Signature

set rgba(c): void

Defined in: src/math/Color.ts:277

set rgb by array

Parameters
c

number[]

Returns

void

Methods

convertToHDRRGB()

convertToHDRRGB(): Color

Defined in: src/math/Color.ts:99

convert to hdr color , channel a is intensity

Returns

Color


unSerialized()

unSerialized(data): this

Defined in: src/math/Color.ts:111

unSerialized color by data

Parameters

data

any

Returns

this


hexToRGB()

hexToRGB(value): Color

Defined in: src/math/Color.ts:123

update this color rgb from hexadecimal no alpha

Parameters

value

number

Returns

Color


hexToRGBA()

hexToRGBA(value): Color

Defined in: src/math/Color.ts:135

update this color rgb from hexadecimal has alpha

Parameters

value

number

Returns

Color


random()

static random(base?): Color

Defined in: src/math/Color.ts:147

random on color

Parameters

base?

number = 1.0

Returns

Color


randomRGB()

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

Defined in: src/math/Color.ts:160

generate a random color from per-channel seeds and base values

Parameters

seedR?

number = 0.5

seedG?

number = 0.5

seedB?

number = 0.5

baseR?

number = 0.5

baseG?

number = 0.5

baseB?

number = 0.5

Returns

Color


randomGray()

static randomGray(base?, random?): Color

Defined in: src/math/Color.ts:174

random on color

Parameters

base?

number = 0.5

random?

number = 0.5

Returns

Color


setTo()

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

Defined in: src/math/Color.ts:191

set rgba to this color

Parameters

r

number

red channel

g

number

green channel

b

number

blue channel

a

number

alpha channel

Returns

this


setHex()

setHex(hex): this

Defined in: src/math/Color.ts:203

update this color rgba from hexadecimal

Parameters

hex

string

hex string.

Returns

this


getHex()

getHex(): string

Defined in: src/math/Color.ts:240

convert this color to hex string code

Returns

string


clone()

clone(): Color

Defined in: src/math/Color.ts:285

clone this color

Returns

Color


copy()

copy(src): this

Defined in: src/math/Color.ts:293

copy color from source color

Parameters

src

Color

Returns

this


copyFromArray()

copyFromArray(arr, scalar?): this

Defined in: src/math/Color.ts:307

copy color from array

Parameters

arr

number[]

[ 255 , 255 , 255 , 255 ]

scalar?

number = 255

Returns

this


copyFromVector()

copyFromVector(value): this

Defined in: src/math/Color.ts:321

copy color from vector3 or vector4

Parameters

value

{ x: number, y: number, z: number, w?: number }

x

number

y

number

z

number

w?

number

Returns

this


hexRGBColor()

static hexRGBColor(hexColor, dst?): Color

Defined in: src/math/Color.ts:334

update this color rgb from hexadecimal no alpha

Parameters

hexColor

number

rgb color

dst?

Color = null

ref out color

Returns

Color


lerp()

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

Defined in: src/math/Color.ts:348

lerp two color

Parameters

v

number

c1

Color

c2

Color

target?

Color

Returns

Color