Class: Color
Defined in: node_modules/@types/three/src/math/Color.d.ts:200
Class representing a color.
A Color instance is represented by RGB components in the linear working color space, which defaults to
LinearSRGBColorSpace. Inputs conventionally using SRGBColorSpace (such as hexadecimals and CSS strings) are
converted to the working color space automatically.
// converted automatically from SRGBColorSpace to LinearSRGBColorSpace
const color = new THREE.Color().setHex( 0x112233 );
Source color spaces may be specified explicitly, to ensure correct conversions.
// assumed already LinearSRGBColorSpace; no conversion
const color = new THREE.Color().setRGB( 0.5, 0.5, 0.5 );
// converted explicitly from SRGBColorSpace to LinearSRGBColorSpace
const color = new THREE.Color().setRGB( 0.5, 0.5, 0.5, SRGBColorSpace );
If THREE.ColorManagement is disabled, no conversions occur. For details, see Color management.
Iterating through a Color instance will yield its components (r, g, b) in the corresponding order.
Constructors
Constructor
new Color(
color?):Color
Defined in: node_modules/@types/three/src/math/Color.d.ts:201
Parameters
color?
Returns
Color
Constructor
new Color(
r,g,b):Color
Defined in: node_modules/@types/three/src/math/Color.d.ts:202
Parameters
r
number
g
number
b
number
Returns
Color
Properties
b
b:
number
Defined in: node_modules/@types/three/src/math/Color.d.ts:222
Blue channel value between 0.0 and 1.0. Default is 1.
Default
1
g
g:
number
Defined in: node_modules/@types/three/src/math/Color.d.ts:216
Green channel value between 0.0 and 1.0. Default is 1.
Default
1
isColor
readonlyisColor:true
Defined in: node_modules/@types/three/src/math/Color.d.ts:204
r
r:
number
Defined in: node_modules/@types/three/src/math/Color.d.ts:210
Red channel value between 0.0 and 1.0. Default is 1.
Default
1
NAMES
staticNAMES:object
Defined in: node_modules/@types/three/src/math/Color.d.ts:375
List of X11 color names.
aliceblue
aliceblue:
15792383
antiquewhite
antiquewhite:
16444375
aqua
aqua:
65535
aquamarine
aquamarine:
8388564
azure
azure:
15794175
beige
beige:
16119260
bisque
bisque:
16770244
black
black:
0
blanchedalmond
blanchedalmond:
16772045
blue
blue:
255
blueviolet
blueviolet:
9055202
brown
brown:
10824234
burlywood
burlywood:
14596231
cadetblue
cadetblue:
6266528
chartreuse
chartreuse:
8388352
chocolate
chocolate:
13789470
coral
coral:
16744272
cornflowerblue
cornflowerblue:
6591981
cornsilk
cornsilk:
16775388
crimson
crimson:
14423100
cyan
cyan:
65535
darkblue
darkblue:
139
darkcyan
darkcyan:
35723
darkgoldenrod
darkgoldenrod:
12092939
darkgray
darkgray:
11119017
darkgreen
darkgreen:
25600
darkgrey
darkgrey:
11119017
darkkhaki
darkkhaki:
12433259
darkmagenta
darkmagenta:
9109643
darkolivegreen
darkolivegreen:
5597999
darkorange
darkorange:
16747520
darkorchid
darkorchid:
10040012
darkred
darkred:
9109504
darksalmon
darksalmon:
15308410
darkseagreen
darkseagreen:
9419919
darkslateblue
darkslateblue:
4734347
darkslategray
darkslategray:
3100495
darkslategrey
darkslategrey:
3100495
darkturquoise
darkturquoise:
52945
darkviolet
darkviolet:
9699539
deeppink
deeppink:
16716947
deepskyblue
deepskyblue:
49151
dimgray
dimgray:
6908265
dimgrey
dimgrey:
6908265
dodgerblue
dodgerblue:
2003199
firebrick
firebrick:
11674146
floralwhite
floralwhite:
16775920
forestgreen
forestgreen:
2263842
fuchsia
fuchsia:
16711935
gainsboro
gainsboro:
14474460
ghostwhite
ghostwhite:
16316671
gold
gold:
16766720
goldenrod
goldenrod:
14329120
gray
gray:
8421504
green
green:
32768
greenyellow
greenyellow:
11403055
grey
grey:
8421504
honeydew
honeydew:
15794160
hotpink
hotpink:
16738740
indianred
indianred:
13458524
indigo
indigo:
4915330
ivory
ivory:
16777200
khaki
khaki:
15787660
lavender
lavender:
15132410
lavenderblush
lavenderblush:
16773365
lawngreen
lawngreen:
8190976
lemonchiffon
lemonchiffon:
16775885
lightblue
lightblue:
11393254
lightcoral
lightcoral:
15761536
lightcyan
lightcyan:
14745599
lightgoldenrodyellow
lightgoldenrodyellow:
16448210
lightgray
lightgray:
13882323
lightgreen
lightgreen:
9498256
lightgrey
lightgrey:
13882323
lightpink
lightpink:
16758465
lightsalmon
lightsalmon:
16752762
lightseagreen
lightseagreen:
2142890
lightskyblue
lightskyblue:
8900346
lightslategray
lightslategray:
7833753
lightslategrey
lightslategrey:
7833753
lightsteelblue
lightsteelblue:
11584734
lightyellow
lightyellow:
16777184
lime
lime:
65280
limegreen
limegreen:
3329330
linen
linen:
16445670
magenta
magenta:
16711935
maroon
maroon:
8388608
mediumaquamarine
mediumaquamarine:
6737322
mediumblue
mediumblue:
205
mediumorchid
mediumorchid:
12211667
mediumpurple
mediumpurple:
9662683
mediumseagreen
mediumseagreen:
3978097
mediumslateblue
mediumslateblue:
8087790
mediumspringgreen
mediumspringgreen:
64154
mediumturquoise
mediumturquoise:
4772300
mediumvioletred
mediumvioletred:
13047173
midnightblue
midnightblue:
1644912
mintcream
mintcream:
16121850
mistyrose
mistyrose:
16770273
moccasin
moccasin:
16770229
navajowhite
navajowhite:
16768685
navy
navy:
128
oldlace
oldlace:
16643558
olive
olive:
8421376
olivedrab
olivedrab:
7048739
orange
orange:
16753920
orangered
orangered:
16729344
orchid
orchid:
14315734
palegoldenrod
palegoldenrod:
15657130
palegreen
palegreen:
10025880
paleturquoise
paleturquoise:
11529966
palevioletred
palevioletred:
14381203
papayawhip
papayawhip:
16773077
peachpuff
peachpuff:
16767673
peru
peru:
13468991
pink
pink:
16761035
plum
plum:
14524637
powderblue
powderblue:
11591910
purple
purple:
8388736
rebeccapurple
rebeccapurple:
6697881
red
red:
16711680
rosybrown
rosybrown:
12357519
royalblue
royalblue:
4286945
saddlebrown
saddlebrown:
9127187
salmon
salmon:
16416882
sandybrown
sandybrown:
16032864
seagreen
seagreen:
3050327
seashell
seashell:
16774638
sienna
sienna:
10506797
silver
silver:
12632256
skyblue
skyblue:
8900331
slateblue
slateblue:
6970061
slategray
slategray:
7372944
slategrey
slategrey:
7372944
snow
snow:
16775930
springgreen
springgreen:
65407
steelblue
steelblue:
4620980
tan
tan:
13808780
teal
teal:
32896
thistle
thistle:
14204888
tomato
tomato:
16737095
turquoise
turquoise:
4251856
violet
violet:
15631086
wheat
wheat:
16113331
white
white:
16777215
whitesmoke
whitesmoke:
16119285
yellow
yellow:
16776960
yellowgreen
yellowgreen:
10145074
Methods
[iterator]()
[iterator]():
Generator<number,void>
Defined in: node_modules/@types/three/src/math/Color.d.ts:370
Returns
Generator<number, void>
add()
add(
color):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:322
Parameters
color
Color
Returns
this
addColors()
addColors(
color1,color2):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:323
Parameters
color1
Color
color2
Color
Returns
this
addScalar()
addScalar(
s):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:324
Parameters
s
number
Returns
this
applyMatrix3()
applyMatrix3(
m):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:329
Applies the transform m to this color's RGB components.
Parameters
m
Returns
this
clone()
clone():
this
Defined in: node_modules/@types/three/src/math/Color.d.ts:270
Clones this color.
Returns
this
convertLinearToSRGB()
convertLinearToSRGB():
this
Defined in: node_modules/@types/three/src/math/Color.d.ts:298
Converts this color from LinearSRGBColorSpace to SRGBColorSpace.
Returns
this
convertSRGBToLinear()
convertSRGBToLinear():
this
Defined in: node_modules/@types/three/src/math/Color.d.ts:293
Converts this color from SRGBColorSpace to LinearSRGBColorSpace.
Returns
this
copy()
copy(
color):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:276
Copies given color.
Parameters
color
Color
Color to copy.
Returns
this
copyLinearToSRGB()
copyLinearToSRGB(
color):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:288
Copies given color making conversion from LinearSRGBColorSpace to SRGBColorSpace.
Parameters
color
Color
Color to copy.
Returns
this
copySRGBToLinear()
copySRGBToLinear(
color):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:282
Copies given color making conversion from SRGBColorSpace to LinearSRGBColorSpace.
Parameters
color
Color
Color to copy.
Returns
this
equals()
equals(
color):boolean
Defined in: node_modules/@types/three/src/math/Color.d.ts:337
Parameters
color
Color
Returns
boolean
fromArray()
fromArray(
array,offset?):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:344
Sets this color's red, green and blue value from the provided array or array-like.
Parameters
array
the source array or array-like.
number[] | ArrayLike<number>
offset?
number
(optional) offset into the array-like. Default is 0.
Returns
this
fromBufferAttribute()
fromBufferAttribute(
attribute,index):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:368
Parameters
attribute
InterleavedBufferAttribute | BufferAttribute<BufferAttributeEventMap>
index
number
Returns
this
getHex()
getHex(
colorSpace?):number
Defined in: node_modules/@types/three/src/math/Color.d.ts:303
Returns the hexadecimal value of this color.
Parameters
colorSpace?
string
Returns
number
getHexString()
getHexString(
colorSpace?):string
Defined in: node_modules/@types/three/src/math/Color.d.ts:308
Returns the string formatted hexadecimal value of this color.
Parameters
colorSpace?
string
Returns
string
getHSL()
getHSL(
target,colorSpace?):HSL
Defined in: node_modules/@types/three/src/math/Color.d.ts:310
Parameters
target
colorSpace?
string
Returns
getRGB()
getRGB(
target,colorSpace?):RGB
Defined in: node_modules/@types/three/src/math/Color.d.ts:312
Parameters
target
colorSpace?
string
Returns
getStyle()
getStyle(
colorSpace?):string
Defined in: node_modules/@types/three/src/math/Color.d.ts:318
Returns the value of this color in CSS context style. Example: rgb(r, g, b)
Parameters
colorSpace?
string
Returns
string
lerp()
lerp(
color,alpha):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:334
Parameters
color
Color
alpha
number
Returns
this
lerpColors()
lerpColors(
color1,color2,alpha):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:335
Parameters
color1
Color
color2
Color
alpha
number
Returns
this
lerpHSL()
lerpHSL(
color,alpha):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:336
Parameters
color
Color
alpha
number
Returns
this
multiply()
multiply(
color):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:332
Parameters
color
Color
Returns
this
multiplyScalar()
multiplyScalar(
s):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:333
Parameters
s
number
Returns
this
offsetHSL()
offsetHSL(
h,s,l):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:320
Parameters
h
number
s
number
l
number
Returns
this
set()
set(...
args):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:225
Parameters
args
[ColorRepresentation] | [number, number, number]
Returns
this
setColorName()
setColorName(
style,colorSpace?):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:265
Sets this color from a color name. Faster than .setStyle() method if you don't need the other CSS-style formats.
Parameters
style
string
Color name in X11 format.
colorSpace?
string
Returns
this
setFromVector3()
setFromVector3(
vector):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:231
Sets this color's r, g and b components from the x, y, and z components of the specified vector.
Parameters
vector
Returns
this
setHex()
setHex(
hex,colorSpace?):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:234
Parameters
hex
number
colorSpace?
string
Returns
this
setHSL()
setHSL(
h,s,l,colorSpace?):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:252
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.
colorSpace?
string
Returns
this
setRGB()
setRGB(
r,g,b,colorSpace?):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:242
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.
colorSpace?
string
Returns
this
setScalar()
setScalar(
scalar):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:233
Parameters
scalar
number
Returns
this
setStyle()
setStyle(
style,colorSpace?):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:258
Sets this color from a CSS context style string.
Parameters
style
string
colorSpace?
string
Returns
this
sub()
sub(
color):this
Defined in: node_modules/@types/three/src/math/Color.d.ts:331
Parameters
color
Color
Returns
this
toArray()
Call Signature
toArray(
array?,offset?):number[]
Defined in: node_modules/@types/three/src/math/Color.d.ts:352
Returns an array [red, green, blue], or copies red, green and blue into the provided array.
Parameters
array?
number[]
(optional) array to store the color to. If this is not provided, a new array will be created.
offset?
number
(optional) optional offset into the array.
Returns
number[]
The created or provided array.
Call Signature
toArray(
xyz,offset?):ArrayLike<number>
Defined in: node_modules/@types/three/src/math/Color.d.ts:360
Copies red, green and blue into the provided array-like.
Parameters
xyz
ArrayLike<number>
offset?
number
(optional) optional offset into the array-like.
Returns
ArrayLike<number>
The provided array-like.
toJSON()
toJSON():
number
Defined in: node_modules/@types/three/src/math/Color.d.ts:366
This method defines the serialization result of Color.
Returns
number
The color as a hexadecimal value.