xxxxxxxxxx
let cx, cy;
let cw = 80;
let on = true;
let color1, color2, color3;
let state = 0;
let bg;
function setup() {
createCanvas(windowWidth, windowHeight);
cx= width/2;
cy=height/2;
color1= color( 255, 0,134);
color2= color( 200, 0,0);
color3= color( 200, 242,34);
bg=color1;
}
function draw() {
background(bg);
if(state == 0){
bg=color1;
}else if (state == 1){
bg=color2;
}else {
bg=color3;
}
fill(255);
ellipse(cx,cy,cw,cw);
}
function mousePressed() {
let d = dist(cx, cy, mouseX, mouseY);
if (d < cw/2) {
//console.log("click");
if(state == 0){
state = 1;
} else if(state==1){
state = 2;
}else if (state==2){
state = 3
}else{
state=0
}
}
}