瀏覽代碼

Adding Chromatic lerp function

Chromatic lerp using hsl unlike linear one using rgb
Remi 7 年之前
父節點
當前提交
ecc4f3fe5e
共有 1 個文件被更改,包括 15 次插入0 次删除
  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 ) {