xxxxxxxxxx
24
let step = 0.004;
let amount = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
if (amount > 1 || amount < 0) {
step *= -1;
}
amount += step;
let red = color(255, 0, 0);
let blue = color(0, 0, 255);
let redBlueLerp = lerpColor(red, blue, amount);
let blueRedLerp = lerpColor(blue, red, amount);
background(blueRedLerp);
noStroke();
fill(redBlueLerp);
rect(width/4, height/4, 200, 200);
}