Color.html 6.3 KB

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