|
@@ -9,16 +9,22 @@ THREE.Color = function ( hex ) {
|
|
this.hex;
|
|
this.hex;
|
|
this.__styleString = 'rgba(0, 0, 0, 1)';
|
|
this.__styleString = 'rgba(0, 0, 0, 1)';
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+ this.setHex( hex );
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
- this.setHex = function ( hex ) {
|
|
|
|
|
|
+THREE.Color.prototype = {
|
|
|
|
+
|
|
|
|
+ setHex: function ( hex ) {
|
|
|
|
|
|
this.hex = hex;
|
|
this.hex = hex;
|
|
this.updateRGBA();
|
|
this.updateRGBA();
|
|
this.updateStyleString();
|
|
this.updateStyleString();
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ },
|
|
|
|
|
|
- this.setRGBA = function ( r, g, b, a ) {
|
|
|
|
|
|
+ setRGBA: function ( r, g, b, a ) {
|
|
|
|
|
|
this.r = r;
|
|
this.r = r;
|
|
this.g = g;
|
|
this.g = g;
|
|
@@ -28,35 +34,33 @@ THREE.Color = function ( hex ) {
|
|
this.updateHex();
|
|
this.updateHex();
|
|
this.updateStyleString();
|
|
this.updateStyleString();
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ },
|
|
|
|
|
|
- this.updateHex = function () {
|
|
|
|
|
|
+ updateHex: function () {
|
|
|
|
|
|
this.hex = Math.floor( this.a * 255 ) << 24 | Math.floor( this.r * 255 ) << 16 | Math.floor( this.g * 255 ) << 8 | Math.floor( this.b * 255 );
|
|
this.hex = Math.floor( this.a * 255 ) << 24 | Math.floor( this.r * 255 ) << 16 | Math.floor( this.g * 255 ) << 8 | Math.floor( this.b * 255 );
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ },
|
|
|
|
|
|
- this.updateRGBA = function () {
|
|
|
|
|
|
+ updateRGBA: function () {
|
|
|
|
|
|
this.a = ( this.hex >> 24 & 255 ) / 255;
|
|
this.a = ( this.hex >> 24 & 255 ) / 255;
|
|
this.r = ( this.hex >> 16 & 255 ) / 255;
|
|
this.r = ( this.hex >> 16 & 255 ) / 255;
|
|
this.g = ( this.hex >> 8 & 255 ) / 255;
|
|
this.g = ( this.hex >> 8 & 255 ) / 255;
|
|
this.b = ( this.hex & 255 ) / 255;
|
|
this.b = ( this.hex & 255 ) / 255;
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ },
|
|
|
|
|
|
- this.updateStyleString = function () {
|
|
|
|
|
|
+ updateStyleString: function () {
|
|
|
|
|
|
this.__styleString = 'rgba(' + Math.floor( this.r * 255 ) + ',' + Math.floor( this.g * 255 ) + ',' + Math.floor( this.b * 255 ) + ',' + this.a + ')';
|
|
this.__styleString = 'rgba(' + Math.floor( this.r * 255 ) + ',' + Math.floor( this.g * 255 ) + ',' + Math.floor( this.b * 255 ) + ',' + this.a + ')';
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ },
|
|
|
|
|
|
- this.toString = function () {
|
|
|
|
|
|
+ toString: function () {
|
|
|
|
|
|
return 'THREE.Color ( r: ' + this.r + ', g: ' + this.g + ', b: ' + this.b + ', a: ' + this.a + ', hex: ' + this.hex + ' )';
|
|
return 'THREE.Color ( r: ' + this.r + ', g: ' + this.g + ', b: ' + this.b + ', a: ' + this.a + ', hex: ' + this.hex + ' )';
|
|
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- this.setHex( hex );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
};
|
|
};
|