Hi!
I am trying to fade that background from one color to another. I’ve had success by following this very helpful post :
But I would like to fade another color in afterwards (so that there will be 3 color changes). Not having much luck, I thought the way to go would to be add another if statement but clearly I’m over looking something super obvious.
Here’s my code:
</
function setup(){
startColor = color(0);
newColor = color(84, 76, 166, 65);
amt = 0;
background(startColor);
}
function draw(){
background(lerpColor(startColor, newColor, smoothstep(0.3,0.9,amt)));
amt += 0.001;
if(amt >= 1){
//amt = 0.0
startColor = newColor;
newColor = color(134, 124, 242, 95)
}
///Additional Color
if(amt >= 1.5){
amt = 0.0
startColor = newColor;
newColor = color(109, 164, 166, 65)
}
}
function smoothstep(edge0, edge1, x){
x = constrain((x - edge0) / (edge1 - edge0), 0.0, 1.0);
return x * x * (3 -2 * x);
}
/>