Color.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 copy]( [page:Color color] ) [page:Color this]</h3>
  42. <div>
  43. color — Color to copy.
  44. </div>
  45. <div>
  46. Copies given color.
  47. </div>
  48. <h3>[method:Color copyGammaToLinear]( [page:Color color] ) [page:Color this]</h3>
  49. <div>
  50. color — Color to copy.
  51. </div>
  52. <div>
  53. Copies given color making conversion from gamma to linear space.
  54. </div>
  55. <h3>[method:Color copyLinearToGamma]( [page:Color color] ) [page:Color this]</h3>
  56. <div>
  57. color — Color to copy.
  58. </div>
  59. <div>
  60. Copies given color making conversion from linear to gamma space.
  61. </div>
  62. <h3>[method:Color convertGammaToLinear]() [page:Color this]</h3>
  63. <div>
  64. Converts this color from gamma to linear space.
  65. </div>
  66. <h3>[method:Color convertLinearToGamma]() [page:Color this]</h3>
  67. <div>
  68. Converts this color from linear to gamma space.
  69. </div>
  70. <h3>[method:Color setRGB]( [page:Float r], [page:Float g], [page:Float b] ) [page:Color this]</h3>
  71. <div>
  72. r — Red channel value between 0 and 1.<br />
  73. g — Green channel value between 0 and 1.<br />
  74. b — Blue channel value between 0 and 1.
  75. </div>
  76. <div>
  77. Sets this color from RGB values.
  78. </div>
  79. <h3>[method:Integer getHex]()</h3>
  80. <div>
  81. Returns the hexadecimal value of this color.
  82. </div>
  83. <h3>[method:String getHexString]()</h3>
  84. <div>
  85. Returns the string formated hexadecimal value of this color.
  86. </div>
  87. <h3>[method:Color setHex]( [page:Integer hex] ) [page:Color this]</h3>
  88. <div>
  89. hex — Color in hexadecimal.<br />
  90. </div>
  91. <div>
  92. Sets this color from a hexadecimal value.
  93. </div>
  94. <h3>[method:Color setStyle]( [page:String style] ) [page:Color this]</h3>
  95. <div>
  96. style — color as a CSS-style string.
  97. </div>
  98. <div>
  99. 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.
  100. </div>
  101. <h3>[method:String getStyle]()</h3>
  102. <div>
  103. Returns the value of this color as a CSS-style string. Example: rgb(255,0,0)
  104. </div>
  105. <h3>[method:Color setHSL]( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]</h3>
  106. <div>
  107. h — hue value between 0.0 and 1.0 <br />
  108. s — saturation value between 0.0 and 1.0 <br />
  109. l — lightness value between 0.0 and 1.0
  110. </div>
  111. <div>
  112. Sets color from hsl
  113. </div>
  114. <h3>.getHSL() [page:Object hsl]</h3>
  115. <div>
  116. Returns an object with properties h, s, and l.
  117. </div>
  118. <h3>[method:Color offsetHSL]( [page:Float h], [page:Float s], [page:Float l] ) [page:Color this]</h3>
  119. <div>
  120. Adds given h, s, and l to this color's existing h, s, and l values.
  121. </div>
  122. <h3>[method:Color add]( [page:Color color] ) [page:Color this]</h3>
  123. <div>
  124. Adds rgb values of given color to rgb values of this color
  125. </div>
  126. <h3>[method:Color addColors]( [page:Color color1], [page:Color color2] ) [page:Color this]</h3>
  127. <div>
  128. Sets this color to the sum of color1 and color2
  129. </div>
  130. <h3>[method:Color addScalar]( [page:Number s] ) [page:Color this]</h3>
  131. <div>
  132. Adds s to the rgb values of this color
  133. </div>
  134. <h3>[method:Color multiply]( [page:Color color] ) [page:Color this]</h3>
  135. <div>
  136. Multiplies this color's rgb values by given color's rgb values
  137. </div>
  138. <h3>[method:Color multiplyScalar]( [page:Number s] ) [page:Color this]</h3>
  139. <div>
  140. Multiplies this color's rgb values by s
  141. </div>
  142. <h3>[method:Color lerp]( [page:Color color], alpha ) [page:Color this]</h3>
  143. <div>
  144. alpha -- a number between 0 and 1.
  145. </div>
  146. <div>
  147. 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.
  148. </div>
  149. <h3>[method:Array toArray]( [page:Array array] )</h3>
  150. <div>
  151. array -- Optional array to store the color.
  152. </div>
  153. <div>
  154. Returns an array [r,g,b]
  155. </div>
  156. <h3>[method:Color equals]( [page:Color c] ) [page:Color this]</h3>
  157. <div>
  158. Compares this color and c and returns true if they are the same, false otherwise.
  159. </div>
  160. <h3>[method:Color clone]()</h3>
  161. <div>
  162. Clones this color.
  163. </div>
  164. <h3>[method:Color set]( value ) [page:Color this]</h3>
  165. <div>
  166. value -- either an instance of [page:Color], a [page:Integer hexadecimal] value, or a css style [page:String string]
  167. </div>
  168. <div>
  169. Delegates to .copy, .setStyle, or .setHex depending on input type.
  170. </div>
  171. <h2>Source</h2>
  172. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  173. </body>
  174. </html>