hola,
Tu es almost there!
background(111); at begin of draw es importante
with circulo you store the data whether to draw circles or rects
you can do the same for color negro with another variable negro (to make color negro permanent)
circulo: you must use for every rect! I did it for 2 rects.
I also use ellipseMode(LEFT);
Example
boolean circulo = true;
void setup() {
size(400, 400);
//fill(#ED0E2C);
//if (circulo == true)
// ellipse(150, 150, 100, 100);
//else
// rect(100, 100, 100, 100);
ellipseMode(LEFT);
}
void draw() {
background(111);
fill(245);
stroke(0);
if (circulo)
ellipse(20, 40, 80, 75); //1
else
rect(20, 40, 80, 75); //1
fill(#F00F0F);
stroke(0);
if (circulo)
ellipse(20, 160, 80, 75);//2
else
rect(20, 160, 80, 75);//2
fill(#DE38C2);
stroke(0);
rect(20, 280, 80, 75);//3
fill(#817F81);
stroke(0);
rect(150, 40, 80, 75);//4
fill(#48E032);
stroke(245);
rect(150, 160, 80, 75);//5
fill(#C7F016);
stroke(0);
rect(150, 280, 80, 75);//6
fill(0);
stroke(0);
rect(280, 40, 80, 75);//7
fill(#1727C1);
stroke(0);
rect(280, 160, 80, 75);//8
fill(#0FE9F2);
stroke(0);
rect(280, 280, 80, 75);
if (mousePressed) {
if (mouseButton == RIGHT) {
fill(0);
rect(150, 160, 80, 75);//5
}
}
}
void mousePressed() {
if (mouseButton==RIGHT &&
mouseX>150 &&
mouseX<150+80 &&
mouseY>160 && mouseY<160+75) {
println("here");
// set variable negro?
}
if (mouseButton==LEFT &&
mouseX>150 &&
mouseX<150+80 &&
mouseY>160 && mouseY<160+75) {
println("here");
circulo = !circulo;
}
}