Skip to content

Commit 17fe7b0

Browse files
authored
Merge pull request #6954 from RandomGamingDev/add-values-color-lerping
Add list support for `lerpColor` like other color functions
2 parents 5042087 + 3ea6ae0 commit 17fe7b0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/color/creating_reading.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,8 @@ p5.prototype.hue = function(c) {
960960
* <a href="#/p5/colorMode">colorMode()</a>.
961961
*
962962
* @method lerpColor
963-
* @param {p5.Color} c1 interpolate from this color.
964-
* @param {p5.Color} c2 interpolate to this color.
963+
* @param {p5.Color} c1 interpolate from this color (any value created by the color() function).
964+
* @param {p5.Color} c2 interpolate to this color (any value created by the color() function).
965965
* @param {Number} amt number between 0 and 1.
966966
* @return {p5.Color} interpolated color.
967967
*
@@ -1007,6 +1007,14 @@ p5.prototype.hue = function(c) {
10071007
*/
10081008
p5.prototype.lerpColor = function(c1, c2, amt) {
10091009
p5._validateParameters('lerpColor', arguments);
1010+
1011+
if (!(c1 instanceof p5.Color)) {
1012+
c1 = color(c1);
1013+
}
1014+
if (!(c2 instanceof p5.Color)) {
1015+
c2 = color(c2);
1016+
}
1017+
10101018
const mode = this._colorMode;
10111019
const maxes = this._colorMaxes;
10121020
let l0, l1, l2, l3;

0 commit comments

Comments
 (0)