[name]

Represents a color.

Example

var color = new THREE.Color(); var color = new THREE.Color( 0xff0000 ); var color = new THREE.Color("rgb(255,0,0)"); var color = new THREE.Color( 1, 0, 0 );

Constructor

[name]( value )

value — optional argument that sets initial color. Can be a hexadecimal or a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "#ff0000", "#f00", or "red", or three arguments that represent color channels.

Properties

[property:Float r]

Red channel value between 0 and 1. Default is 1.

[property:Float g]

Green channel value between 0 and 1. Default is 1.

[property:Float b]

Blue channel value between 0 and 1. Default is 1.

Methods

[method:Color copy]( [page:Color color] ) [page:Color this]

color — Color to copy.
Copies given color.

[method:Color copyGammaToLinear]( [page:Color color] ) [page:Color this]

color — Color to copy.
Copies given color making conversion from gamma to linear space.

[method:Color copyLinearToGamma]( [page:Color color] ) [page:Color this]

color — Color to copy.
Copies given color making conversion from linear to gamma space.

[method:Color convertGammaToLinear]() [page:Color this]

Converts this color from gamma to linear space.

[method:Color convertLinearToGamma]() [page:Color this]

Converts this color from linear to gamma space.

[method:Color setRGB]( [page:Float r], [page:Float g], [page:Float b] ) [page:Color this]

r — Red channel value between 0 and 1.
g — Green channel value between 0 and 1.
b — Blue channel value between 0 and 1.
Sets this color from RGB values.

[method:Integer getHex]()

Returns the hexadecimal value of this color.

[method:String getHexString]()

Returns the string formated hexadecimal value of this color.

[method:Color setHex]( [page:Integer hex] ) [page:Color this]

hex — Color in hexadecimal.
Sets this color from a hexadecimal value.

[method:Color setStyle]( [page:String style] ) [page:Color this]

style — color as a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "#ff0000", "#f00", or "red"
Sets this color from a CSS-style string.

[method:String getStyle]()

Returns the value of this color as a CSS-style string. Example: rgb(255,0,0)

[method:Color setHSL]( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]

h — hue value between 0.0 and 1.0
s — saturation value between 0.0 and 1.0
l — lightness value between 0.0 and 1.0
Sets color from hsl

.getHSL() [page:Object hsl]

Returns an object with properties h, s, and l.

[method:Color offsetHSL]( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]

Adds given h, s, and l to this color's existing h, s, and l values.

[method:Color add]( [page:Color color] ) [page:Color this]

Adds rgb values of given color to rgb values of this color

[method:Color addColors]( [page:Color color1], [page:Color color2] ) [page:Color this]

Sets this color to the sum of color1 and color2

[method:Color addScalar]( [page:Number s] ) [page:Color this]

Adds s to the rgb values of this color

[method:Color multiply]( [page:Color color] ) [page:Color this]

Multiplies this color's rgb values by given color's rgb values

[method:Color multiplyScalar]( [page:Number s] ) [page:Color this]

Multiplies this color's rgb values by s

[method:Color lerp]( [page:Color color], alpha ) [page:Color this]

alpha -- a number between 0 and 1.
Linear interpolation of this colors rgb values and the rgb values of the first argument. The alpha argument can be thought of as the percent between the two colors, where 0 is this color and 1 is the first argument.

[method:Array toArray]( [page:Array array] )

array -- Optional array to store the color.
Returns an array [r,g,b]

[method:Color equals]( [page:Color c] ) [page:Color this]

Compares this color and c and returns true if they are the same, false otherwise.

[method:Color clone]()

Clones this color.

[method:Color set]( value ) [page:Color this]

value -- either an instance of [page:Color], a [page:Integer hexadecimal] value, or a css style [page:String string]
Delegates to .copy, .setStyle, or .setHex depending on input type.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]