Color.html 5.6 KB

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