Color.html 4.5 KB

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