Browse Source

update style based on @mrdoob's suggestion here: https://github.com/mrdoob/three.js/pull/3109#issuecomment-13915971

Ben Houston 12 years ago
parent
commit
79050ff9c0
1 changed files with 46 additions and 46 deletions
  1. 46 46
      examples/js/math/ColorConverter.js

+ 46 - 46
examples/js/math/ColorConverter.js

@@ -2,81 +2,81 @@
  * @author bhouston / http://exocortex.com/
  */
 
-THREE.ColorConverter = function () {
+THREE.ColorConverter = {
 
-	return this;
+	fromRGB: function ( color, r, g, b ) {
 
-};
+		return color.setRGB( r, g, b );
 
-// these are all static functions that we are extending ColorConverter directly rather than its prorotype.
-THREE.ColorConverter.fromRGB = function ( color, r, g, b ) {
+	},
 
-	return color.setRGB( r, g, b );
+	fromHex: function ( color, hex ) {
 
-};
+		return color.setHex( hex );
 
-THREE.ColorConverter.fromHex = function ( color, hex ) {
+	},
 
-	return color.setHex( hex );
+	toHex: function ( color ) {
 
-};
+		return color.getHex();
 
-THREE.ColorConverter.toHex = function ( color ) {
+	},
+	 
+	toHexString: function ( color ) {
 
-	return color.getHex();
+		return color.getHexString( color );
 
-};
- 
-THREE.ColorConverter.toHexString = function ( color ) {
+	},
 
-	return color.getHexString( color );
+	fromHSL: function ( color, h, s, l ) {
 
-};
+		return color.setHSL( h, s, l );
+	},
 
-THREE.ColorConverter.fromHSL = function ( color, h, s, l ) {
+	toHSL: function ( color ) {
 
-	return color.setHSL( h, s, l );
-};
+		return color.getHSL( color );
 
-THREE.ColorConverter.toHSL = function ( color ) {
+	},
 
-	return color.getHSL( color );
+	fromHSV: function ( color, h, s, v ) {
 
-};
+		// https://gist.github.com/xpansive/1337890#file-index-js
+		return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 );
 
-THREE.ColorConverter.fromHSV = function ( color, h, s, v ) {
+	},
 
-	return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 ); // https://gist.github.com/xpansive/1337890#file-index-js
+	toHSV: function () {
 
-};
+		var hsv = { h: 0, s: 0, v: 0 };
 
-THREE.ColorConverter.toHSV = function () { // based on https://gist.github.com/xpansive/1337890#file-index-js
+		return function( color ) {
 
-	var hsv = { h: 0, s: 0, v: 0 };
+			var hsl = color.getHSL();
 
-	return function( color ) {
+			// based on https://gist.github.com/xpansive/1337890#file-index-js
+			hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l );
 
-		var hsl = color.getHSL();
-
-		hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l );
-
-		hsv.h = hsl.h;
-		hsv.s = 2 * hsl.s / ( hsl.l + hsl.s );
-		hsv.v = hsl.l + hsl.s;
-		
-		return hsv;
+			hsv.h = hsl.h;
+			hsv.s = 2 * hsl.s / ( hsl.l + hsl.s );
+			hsv.v = hsl.l + hsl.s;
+			
+			return hsv;
+			
+		}
 		
-	}
-}();
+	}(),
+
+	fromStyle: function ( color, style ) {
 
-THREE.ColorConverter.fromStyle = function ( color, style ) {
+		return color.setStyle( style );
 
-	return color.setStyle( style );
+	},
 
-};
+	toStyle: function ( color ) {
 
-THREE.ColorConverter.toStyle = function ( color ) {
+		return color.getStyle( color );
 
-	return color.getStyle( color );
+	}
 
-};
+};