123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <script src="../../list.js"></script>
- <script src="../../page.js"></script>
- <link type="text/css" rel="stylesheet" href="../../page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <div class="desc">
- Represents a color.
- </div>
- <h2>Example</h2>
- <code>var color = new THREE.Color();</code>
- <code>var color = new THREE.Color( 0xff0000 );</code>
- <code>var color = new THREE.Color("rgb(255,0,0)");</code>
- <code>var color = new THREE.Color( 1, 0, 0 );</code>
- <h2>Constructor</h2>
- <h3>[name]( value )</h3>
- <div>
- 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.
- </div>
- <h2>Properties</h2>
- <h3>.[page:Float r]</h3>
- <div>
- Red channel value between 0 and 1. Default is 1.
- </div>
- <h3>.[page:Float g]</h3>
- <div>
- Green channel value between 0 and 1. Default is 1.
- </div>
- <h3>.[page:Float b]</h3>
- <div>
- Blue channel value between 0 and 1. Default is 1.
- </div>
- <h2>Methods</h2>
- <h3>.copy( [page:Color color] ) [page:Color this]</h3>
- <div>
- color — Color to copy.
- </div>
- <div>
- Copies given color.
- </div>
- <h3>.copyGammaToLinear( [page:Color color] ) [page:Color this]</h3>
- <div>
- color — Color to copy.
- </div>
- <div>
- Copies given color making conversion from gamma to linear space.
- </div>
- <h3>.copyLinearToGamma( [page:Color color] ) [page:Color this]</h3>
- <div>
- color — Color to copy.
- </div>
- <div>
- Copies given color making conversion from linear to gamma space.
- </div>
- <h3>.convertGammaToLinear() [page:Color this]</h3>
- <div>
- Converts this color from gamma to linear space.
- </div>
- <h3>.convertLinearToGamma() [page:Color this]</h3>
- <div>
- Converts this color from linear to gamma space.
- </div>
- <h3>.setRGB( [page:Float r], [page:Float g], [page:Float b] ) [page:Color this]</h3>
- <div>
- r — Red channel value between 0 and 1.<br />
- g — Green channel value between 0 and 1.<br />
- b — Blue channel value between 0 and 1.
- </div>
- <div>
- Sets this color from RGB values.
- </div>
- <h3>.getHex() [page:Integer]</h3>
- <div>
- Returns the hexadecimal value of this color.
- </div>
- <h3>.getHexString() [page:String]</h3>
- <div>
- Returns the string formated hexadecimal value of this color.
- </div>
- <h3>.setHex( [page:Integer hex] ) [page:Color this]</h3>
- <div>
- hex — Color in hexadecimal.<br />
- </div>
- <div>
- Sets this color from a hexadecimal value.
- </div>
- <h3>.setStyle( [page:String style] ) [page:Color this]</h3>
- <div>
- style — color as a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "#ff0000", "#f00", or "red"
- </div>
- <div>
- Sets this color from a CSS-style string.
- </div>
- <h3>.getStyle() [page:String]</h3>
- <div>
- Returns the value of this color as a CSS-style string. Example: rgb(255,0,0)
- </div>
- <h3>.setHSL( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]</h3>
- <div>
- h — hue value between 0.0 and 1.0 <br />
- s — saturation value between 0.0 and 1.0 <br />
- l — lightness value between 0.0 and 1.0
- </div>
- <div>
- Sets color from hsl
- </div>
- <h3>.getHSL() [page:Object hsl]</h3>
- <div>
- Returns an object with properties h, s, and l.
- </div>
- <h3>.offsetHSL( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]</h3>
- <div>
- Adds given h, s, and l to this color's existing h, s, and l values.
- </div>
- <h3>.add ( [page:Color color] ) [page:Color this]</h3>
- <div>
- Adds rgb values of given color to rgb values of this color
- </div>
- <h3>.addColors( [page:Color color1], [page:Color color2] ) [page:Color this]</h3>
- <div>
- Sets this color to the sum of color1 and color2
- </div>
- <h3>.addScalar( [page:Number s] ) [page:Color this]</h3>
- <div>
- Adds s to the rgb values of this color
- </div>
- <h3>.multiply( [page:Color color] ) [page:Color this]</h3>
- <div>
- Multiplies this color's rgb values by given color's rgb values
- </div>
- <h3>.multiplyScalar( [page:Number s] ) [page:Color this]</h3>
- <div>
- Multiplies this color's rgb values by s
- </div>
- <h3>.lerp( [page:Color color], alpha ) [page:Color this]</h3>
- <div>
- alpha -- a number between 0 and 1.
- </div>
- <div>
- 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.
- </div>
- <h3>.equals( [page:Color c] ) [page:Color this]</h3>
- <div>
- Compares this color and c and returns true if they are the same, false otherwise.
- </div>
- <h3>.clone() [page:Color]</h3>
- <div>
- Clones this color.
- </div>
- <h3>.set( value ) [page:Color this]</h3>
- <div>
- value -- either an instance of [page:Color], a [page:Integer hexadecimal] value, or a css style [page:String string]
- </div>
- <div>
- Delegates to .copy, .setStyle, or .setHex depending on input type.
- </div>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
- </html>
|