xxxxxxxxxx
32
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
// to make a smoother transition
frameRate(20);
// creating an if statement, if framecount is __ color is __.
let fillColor1, fillColor2;
if (frameCount % 6 !== 0) {
fillColor1 = color(155, 114, 44);
fillColor2 = color(155, 44, 53);
} else {
fillColor1 = color(240, 193, 143);
fillColor2 = color(33, 56, 31);
}
let x = mouseX;
let y = mouseY;
let ix = width - mouseX; // Inverse X
let iy = height - mouseY; // Inverse Y
// fill the color to the circle.
noStroke();
fill(fillColor1);
ellipse(x, height / 2, y, y);
fill(fillColor2);
ellipse(ix, height / 2, iy, iy);
}