* add Color.sub() * add tab * if result is negative set to 0 * revise doc of color.sub()
@@ -185,6 +185,11 @@
Adds given h, s, and l to this color's existing h, s, and l values.
</div>
+ <h3>[method:Color sub]( [page:Color color] ) [page:Color this]</h3>
+ <div>
+ Subtracts rgb components of given color from rgb components of this color. If a component is negative, it is set to zero.
+ </div>
+
<h3>[method:Color add]( [page:Color color] ) [page:Color this]</h3>
<div>
Adds rgb values of given color to rgb values of this color
@@ -381,6 +381,16 @@ THREE.Color.prototype = {
},
+ sub: function( color ) {
+ this.r = Math.max( 0, this.r - color.r );
+ this.g = Math.max( 0, this.g - color.g );
+ this.b = Math.max( 0, this.b - color.b );
+ return this;
+ },
add: function ( color ) {
this.r += color.r;