Browse Source

Adding Chromatic lerp function

Chromatic lerp using hsl unlike linear one using rgb
Remi 7 years ago
parent
commit
ecc4f3fe5e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/math/Color.js

+ 15 - 0
src/math/Color.js

@@ -540,6 +540,21 @@ Object.assign( Color.prototype, {
 		return this;
 
 	},
+	
+	lerpChromatic: function ( color, alpha  ) {
+
+		var hslA = this.getHSL();
+		var hslB = color.getHSL();
+
+		var h = _Math.lerp( hslA.h, hslB.h, alpha );
+		var s = _Math.lerp( hslA.s, hslB.s, alpha );
+		var l = _Math.lerp( hslA.l, hslB.l, alpha );
+
+		this.setHSL( h, s, l );
+
+		return this;
+
+	},
 
 	equals: function ( c ) {