Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/api/math/Color.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ <h3>[method:Color lerp]( [param:Color color], [param:Float alpha] ) </h3>
this color and 1.0 is the first argument.
</p>

<h3>[method:Color lerpHSL]( [param:Color color], [param:Float alpha] ) </h3>
<p>
[page:Color color] - color to converge on.<br />
[page:Float alpha] - interpolation factor in the closed interval [0, 1].<br /><br />

Linearly interpolates this color's HSL values toward the HSL values of the passed argument.
It differs from the classic [page:.lerp] by not interpolating straight from one color to the other,
but instead going through all the hues in between those two colors.
The alpha argument can be thought of as the ratio between the two colors, where 0.0 is
this color and 1.0 is the first argument.
</p>

<h3>[method:Color multiply]( [param:Color color] ) </h3>
<p>Multiplies this color's RGB values by the given [page:Color color]'s RGB values.</p>

Expand Down
22 changes: 22 additions & 0 deletions src/math/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,28 @@ Object.assign( Color.prototype, {

},

lerpHSL: function () {

var hslA = { h: 0, s: 0, l: 0 };
var hslB = { h: 0, s: 0, l: 0 };

return function lerpHSL( color, alpha ) {

this.getHSL( hslA );
color.getHSL( hslB );

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 );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mugen87 Math or _Math? Both are used in this file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_Math. Math is the built-in object in JavaScript which has no lerp() function.


this.setHSL( h, s, l );

return this;

};

}(),

equals: function ( c ) {

return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
Expand Down