Skip to content

Commit

Permalink
Merge pull request #6954 from RandomGamingDev/add-values-color-lerping
Browse files Browse the repository at this point in the history
Add list support for `lerpColor` like other color functions
  • Loading branch information
davepagurek authored Sep 17, 2024
2 parents 5042087 + 3ea6ae0 commit 17fe7b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/color/creating_reading.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,8 @@ p5.prototype.hue = function(c) {
* <a href="#/p5/colorMode">colorMode()</a>.
*
* @method lerpColor
* @param {p5.Color} c1 interpolate from this color.
* @param {p5.Color} c2 interpolate to this color.
* @param {p5.Color} c1 interpolate from this color (any value created by the color() function).
* @param {p5.Color} c2 interpolate to this color (any value created by the color() function).
* @param {Number} amt number between 0 and 1.
* @return {p5.Color} interpolated color.
*
Expand Down Expand Up @@ -1007,6 +1007,14 @@ p5.prototype.hue = function(c) {
*/
p5.prototype.lerpColor = function(c1, c2, amt) {
p5._validateParameters('lerpColor', arguments);

if (!(c1 instanceof p5.Color)) {
c1 = color(c1);
}
if (!(c2 instanceof p5.Color)) {
c2 = color(c2);
}

const mode = this._colorMode;
const maxes = this._colorMaxes;
let l0, l1, l2, l3;
Expand Down

0 comments on commit 17fe7b0

Please sign in to comment.