[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)");

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"

Properties

.[page:Float r]

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

.[page:Float g]

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

.[page:Float b]

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

Methods

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

color — Color to copy.
Copies given color.

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

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

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

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

.convertGammaToLinear() [page:Color this]

Converts this color from gamma to linear space.

.convertLinearToGamma() [page:Color this]

Converts this color from linear to gamma space.

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

.getHex() [page:Integer]

Returns the hexadecimal value of this color.

.getHexString() [page:String]

Returns the string formated hexadecimal value of this color.

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

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

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

.getStyle() [page:String]

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

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

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

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

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

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

Sets this color to the sum of color1 and color2

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

Adds s to the rgb values of this color

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

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

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

Multiplies this color's rgb values by s

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

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

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

.clone() [page:Color]

Clones this 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]