Color.html 5.1 KB

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