xxxxxxxxxx
let circleW=80;
let circleX, circleY;
let circleC;
let state=1;
let color1,color2,color3;
// Shape
function setup() {
createCanvas(windowWidth, windowHeight);
circleX = width/2;
circleY = height/2;
color1= color(255,255,0);
color2= color(255,0,255);
color3= color(0,255,255);
circleC=color1;
}
// SHAPE&PLACEMNT
function draw() {
background(circleC);
fill(0);
ellipse(circleX,circleY,circleW,circleW);
}
// MOUSE FUNCTION
function mousePressed(){
let d = dist(mouseX,mouseY,circleX,circleY);
if(d < circleW/2){
if(state==1){
circleC=color2;
state=2;
}else if(state==2){
circleC=color3;
state=3;
}else{
circleC=color1;
state=1;
}
}
}