[28897] | 1 | <!DOCTYPE html>
|
---|
| 2 | <html lang="en">
|
---|
| 3 | <head>
|
---|
| 4 | <meta charset="utf-8" />
|
---|
| 5 | <script src="../../list.js"></script>
|
---|
| 6 | <script src="../../page.js"></script>
|
---|
| 7 | <link type="text/css" rel="stylesheet" href="../../page.css" />
|
---|
| 8 | </head>
|
---|
| 9 | <body>
|
---|
| 10 | <h1>[name]</h1>
|
---|
| 11 |
|
---|
| 12 | <div class="desc">
|
---|
| 13 | Represents a color.
|
---|
| 14 | </div>
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | <h2>Example</h2>
|
---|
| 18 | <code>var color = new THREE.Color();</code>
|
---|
| 19 | <code>var color = new THREE.Color( 0xff0000 );</code>
|
---|
| 20 | <code>var color = new THREE.Color("rgb(255,0,0)");</code>
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | <h2>Constructor</h2>
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | <h3>[name]( value )</h3>
|
---|
| 27 | <div>
|
---|
| 28 | 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"
|
---|
| 29 | </div>
|
---|
| 30 |
|
---|
| 31 | <h2>Properties</h2>
|
---|
| 32 |
|
---|
| 33 | <h3>.[page:Float r]</h3>
|
---|
| 34 | <div>
|
---|
| 35 | Red channel value between 0 and 1. Default is 1.
|
---|
| 36 | </div>
|
---|
| 37 |
|
---|
| 38 | <h3>.[page:Float g]</h3>
|
---|
| 39 | <div>
|
---|
| 40 | Green channel value between 0 and 1. Default is 1.
|
---|
| 41 | </div>
|
---|
| 42 |
|
---|
| 43 | <h3>.[page:Float b]</h3>
|
---|
| 44 | <div>
|
---|
| 45 | Blue channel value between 0 and 1. Default is 1.
|
---|
| 46 | </div>
|
---|
| 47 |
|
---|
| 48 | <h2>Methods</h2>
|
---|
| 49 |
|
---|
| 50 | <h3>.copy( [page:Color color] ) [page:Color this]</h3>
|
---|
| 51 | <div>
|
---|
| 52 | color â Color to copy.
|
---|
| 53 | </div>
|
---|
| 54 | <div>
|
---|
| 55 | Copies given color.
|
---|
| 56 | </div>
|
---|
| 57 |
|
---|
| 58 | <h3>.copyGammaToLinear( [page:Color color] ) [page:Color this]</h3>
|
---|
| 59 | <div>
|
---|
| 60 | color â Color to copy.
|
---|
| 61 | </div>
|
---|
| 62 | <div>
|
---|
| 63 | Copies given color making conversion from gamma to linear space.
|
---|
| 64 | </div>
|
---|
| 65 |
|
---|
| 66 | <h3>.copyLinearToGamma( [page:Color color] ) [page:Color this]</h3>
|
---|
| 67 | <div>
|
---|
| 68 | color â Color to copy.
|
---|
| 69 | </div>
|
---|
| 70 | <div>
|
---|
| 71 | Copies given color making conversion from linear to gamma space.
|
---|
| 72 | </div>
|
---|
| 73 |
|
---|
| 74 | <h3>.convertGammaToLinear() [page:Color this]</h3>
|
---|
| 75 | <div>
|
---|
| 76 | Converts this color from gamma to linear space.
|
---|
| 77 | </div>
|
---|
| 78 |
|
---|
| 79 | <h3>.convertLinearToGamma() [page:Color this]</h3>
|
---|
| 80 | <div>
|
---|
| 81 | Converts this color from linear to gamma space.
|
---|
| 82 | </div>
|
---|
| 83 |
|
---|
| 84 | <h3>.setRGB( [page:Float r], [page:Float g], [page:Float b] ) [page:Color this]</h3>
|
---|
| 85 | <div>
|
---|
| 86 | r â Red channel value between 0 and 1.<br />
|
---|
| 87 | g â Green channel value between 0 and 1.<br />
|
---|
| 88 | b â Blue channel value between 0 and 1.
|
---|
| 89 | </div>
|
---|
| 90 | <div>
|
---|
| 91 | Sets this color from RGB values.
|
---|
| 92 | </div>
|
---|
| 93 |
|
---|
| 94 | <h3>.getHex() [page:Integer]</h3>
|
---|
| 95 | <div>
|
---|
| 96 | Returns the hexadecimal value of this color.
|
---|
| 97 | </div>
|
---|
| 98 |
|
---|
| 99 | <h3>.getHexString() [page:String]</h3>
|
---|
| 100 | <div>
|
---|
| 101 | Returns the string formated hexadecimal value of this color.
|
---|
| 102 | </div>
|
---|
| 103 |
|
---|
| 104 | <h3>.setHex( [page:Integer hex] ) [page:Color this]</h3>
|
---|
| 105 | <div>
|
---|
| 106 | hex â Color in hexadecimal.<br />
|
---|
| 107 | </div>
|
---|
| 108 | <div>
|
---|
| 109 | Sets this color from a hexadecimal value.
|
---|
| 110 | </div>
|
---|
| 111 |
|
---|
| 112 | <h3>.setStyle( [page:String style] ) [page:Color this]</h3>
|
---|
| 113 | <div>
|
---|
| 114 | style â color as a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "#ff0000", "#f00", or "red"
|
---|
| 115 | </div>
|
---|
| 116 | <div>
|
---|
| 117 | Sets this color from a CSS-style string.
|
---|
| 118 | </div>
|
---|
| 119 |
|
---|
| 120 | <h3>.getStyle() [page:String]</h3>
|
---|
| 121 | <div>
|
---|
| 122 | Returns the value of this color as a CSS-style string. Example: rgb(255,0,0)
|
---|
| 123 | </div>
|
---|
| 124 |
|
---|
| 125 | <h3>.setHSL( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]</h3>
|
---|
| 126 | <div>
|
---|
| 127 | h â hue value between 0.0 and 1.0 <br />
|
---|
| 128 | s â saturation value between 0.0 and 1.0 <br />
|
---|
| 129 | l â lightness value between 0.0 and 1.0
|
---|
| 130 | </div>
|
---|
| 131 | <div>
|
---|
| 132 | Sets color from hsl
|
---|
| 133 | </div>
|
---|
| 134 |
|
---|
| 135 | <h3>.getHSL() [page:Object hsl]</h3>
|
---|
| 136 | <div>
|
---|
| 137 | Returns an object with properties h, s, and l.
|
---|
| 138 | </div>
|
---|
| 139 |
|
---|
| 140 | <h3>.offsetHSL( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]</h3>
|
---|
| 141 | <div>
|
---|
| 142 | Adds given h, s, and l to this color's existing h, s, and l values.
|
---|
| 143 | </div>
|
---|
| 144 |
|
---|
| 145 | <h3>.add ( [page:Color color] ) [page:Color this]</h3>
|
---|
| 146 | <div>
|
---|
| 147 | Adds rgb values of given color to rgb values of this color
|
---|
| 148 | </div>
|
---|
| 149 |
|
---|
| 150 | <h3>.addColors( [page:Color color1], [page:Color color2] ) [page:Color this]</h3>
|
---|
| 151 | <div>
|
---|
| 152 | Sets this color to the sum of color1 and color2
|
---|
| 153 | </div>
|
---|
| 154 |
|
---|
| 155 | <h3>.addScalar( [page:Number s] ) [page:Color this]</h3>
|
---|
| 156 | <div>
|
---|
| 157 | Adds s to the rgb values of this color
|
---|
| 158 | </div>
|
---|
| 159 |
|
---|
| 160 | <h3>.multiply( [page:Color color] ) [page:Color this]</h3>
|
---|
| 161 | <div>
|
---|
| 162 | Multiplies this color's rgb values by given color's rgb values
|
---|
| 163 | </div>
|
---|
| 164 |
|
---|
| 165 | <h3>.multiplyScalar( [page:Number s] ) [page:Color this]</h3>
|
---|
| 166 | <div>
|
---|
| 167 | Multiplies this color's rgb values by s
|
---|
| 168 | </div>
|
---|
| 169 |
|
---|
| 170 | <h3>.lerp( [page:Color color], alpha ) [page:Color this]</h3>
|
---|
| 171 | <div>
|
---|
| 172 | alpha -- a number between 0 and 1.
|
---|
| 173 | </div>
|
---|
| 174 | <div>
|
---|
| 175 | 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.
|
---|
| 176 | </div>
|
---|
| 177 |
|
---|
| 178 | <h3>.equals( [page:Color c] ) [page:Color this]</h3>
|
---|
| 179 | <div>
|
---|
| 180 | Compares this color and c and returns true if they are the same, false otherwise.
|
---|
| 181 | </div>
|
---|
| 182 |
|
---|
| 183 | <h3>.clone() [page:Color]</h3>
|
---|
| 184 | <div>
|
---|
| 185 | Clones this color.
|
---|
| 186 | </div>
|
---|
| 187 |
|
---|
| 188 | <h3>.set( value ) [page:Color this]</h3>
|
---|
| 189 | <div>
|
---|
| 190 | value -- either an instance of [page:Color], a [page:Integer hexadecimal] value, or a css style [page:String string]
|
---|
| 191 | </div>
|
---|
| 192 | <div>
|
---|
| 193 | Delegates to .copy, .setStyle, or .setHex depending on input type.
|
---|
| 194 | </div>
|
---|
| 195 |
|
---|
| 196 | <h2>Source</h2>
|
---|
| 197 |
|
---|
| 198 | [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
---|
| 199 | </body>
|
---|
| 200 | </html>
|
---|