From 2e2f095c7f19667e437b0a85b35c44e6809b59bf Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Tue, 9 Apr 2024 08:42:28 -0400 Subject: [PATCH 1/3] add list support for lerpColor like other color functions --- src/color/creating_reading.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/color/creating_reading.js b/src/color/creating_reading.js index 1a8665aad6..3bd4246881 100644 --- a/src/color/creating_reading.js +++ b/src/color/creating_reading.js @@ -960,8 +960,8 @@ p5.prototype.hue = function(c) { * colorMode(). * * @method lerpColor - * @param {p5.Color} c1 interpolate from this color. - * @param {p5.Color} c2 interpolate to this color. + * @param {p5.Color|Number[]} c1 interpolate from this color. + * @param {p5.Color|Number[]} c2 interpolate to this color. * @param {Number} amt number between 0 and 1. * @return {p5.Color} interpolated color. * @@ -1007,6 +1007,14 @@ p5.prototype.hue = function(c) { */ p5.prototype.lerpColor = function(c1, c2, amt) { p5._validateParameters('lerpColor', arguments); + + if (Array.isArray(c1)) { + c1 = color(c1); + } + if (Array.isArray(c2)) { + c2 = color(c2); + } + const mode = this._colorMode; const maxes = this._colorMaxes; let l0, l1, l2, l3; From 158a8bce1c4386b00bcd8d18b45c9105be93a0f9 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Mon, 9 Sep 2024 18:41:26 -0400 Subject: [PATCH 2/3] added documentation that's more similar to that of background() --- src/color/creating_reading.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/color/creating_reading.js b/src/color/creating_reading.js index 3bd4246881..806d0379f0 100644 --- a/src/color/creating_reading.js +++ b/src/color/creating_reading.js @@ -960,8 +960,8 @@ p5.prototype.hue = function(c) { * colorMode(). * * @method lerpColor - * @param {p5.Color|Number[]} c1 interpolate from this color. - * @param {p5.Color|Number[]} 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. * From 3ea6ae0024f69a9f47cbbd302a54282ddaa0c9b8 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Tue, 17 Sep 2024 17:10:41 -0400 Subject: [PATCH 3/3] added support for color convertable types other than lists --- src/color/creating_reading.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/color/creating_reading.js b/src/color/creating_reading.js index 806d0379f0..a84b7eabff 100644 --- a/src/color/creating_reading.js +++ b/src/color/creating_reading.js @@ -1008,10 +1008,10 @@ p5.prototype.hue = function(c) { p5.prototype.lerpColor = function(c1, c2, amt) { p5._validateParameters('lerpColor', arguments); - if (Array.isArray(c1)) { + if (!(c1 instanceof p5.Color)) { c1 = color(c1); } - if (Array.isArray(c2)) { + if (!(c2 instanceof p5.Color)) { c2 = color(c2); }