|
@@ -141,6 +141,12 @@ THREE.Color.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ getHex: function () {
|
|
|
+
|
|
|
+ return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
setHex: function ( hex ) {
|
|
|
|
|
|
hex = Math.floor( hex );
|
|
@@ -153,47 +159,30 @@ THREE.Color.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- setContextStyle: function ( contextStyle ) {
|
|
|
-
|
|
|
- var color = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i.exec(contextStyle);
|
|
|
-
|
|
|
- this.r = parseInt(color[1], 10) / 255;
|
|
|
- this.g = parseInt(color[2], 10) / 255;
|
|
|
- this.b = parseInt(color[3], 10) / 255;
|
|
|
-
|
|
|
- return this;
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- lerpSelf: function ( color, alpha ) {
|
|
|
-
|
|
|
- this.r += ( color.r - this.r ) * alpha;
|
|
|
- this.g += ( color.g - this.g ) * alpha;
|
|
|
- this.b += ( color.b - this.b ) * alpha;
|
|
|
+ getHexString: function () {
|
|
|
|
|
|
- return this;
|
|
|
+ return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );
|
|
|
|
|
|
},
|
|
|
|
|
|
- getHex: function () {
|
|
|
+ getContextStyle: function () {
|
|
|
|
|
|
- return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;
|
|
|
+ return 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';
|
|
|
|
|
|
},
|
|
|
|
|
|
- getHexString: function () {
|
|
|
+ setContextStyle: function ( style ) {
|
|
|
|
|
|
- return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );
|
|
|
+ var color = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i.exec( style );
|
|
|
|
|
|
- },
|
|
|
+ this.r = parseInt( color[ 1 ], 10 ) / 255;
|
|
|
+ this.g = parseInt( color[ 2 ], 10 ) / 255;
|
|
|
+ this.b = parseInt( color[ 3 ], 10 ) / 255;
|
|
|
|
|
|
- getContextStyle: function () {
|
|
|
-
|
|
|
- return 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';
|
|
|
+ return this;
|
|
|
|
|
|
},
|
|
|
|
|
|
-
|
|
|
getHSV: function ( hsv ) {
|
|
|
|
|
|
// based on MochiKit implementation by Bob Ippolito
|
|
@@ -263,6 +252,16 @@ THREE.Color.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ lerpSelf: function ( color, alpha ) {
|
|
|
+
|
|
|
+ this.r += ( color.r - this.r ) * alpha;
|
|
|
+ this.g += ( color.g - this.g ) * alpha;
|
|
|
+ this.b += ( color.b - this.b ) * alpha;
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
clone: function () {
|
|
|
|
|
|
return new THREE.Color().setRGB( this.r, this.g, this.b );
|