you can enhancement your code your start is good
here you can add buttons and control with mousePressed
Button red;
void setup() {
size (600, 650);
smooth();
background(0);
red = new Button("red color", 20, 20, 100, 50);
}
void draw() {
red.Draw();
}
void mousePressed()
{
if (red.mousePressed()) {
fill(222,0,0);
rect(12,111,230,230);
}
}
class Button {
String label;
float x;
float y;
float w;
float h;
Button(String labelB, float xpos, float ypos, float widthB, float heightB) {
label = labelB;
x = xpos;
y = ypos;
w = widthB;
h = heightB;
}
void Draw() {
fill(222,0,0);
stroke(141);
rect(x, y, w, h, 10);
textAlign(CENTER, CENTER);
fill(0);
text(label, x + (w / 2), y + (h / 2));
}
boolean mousePressed () {
if (mouseX > x && mouseX < (x + w) && mouseY > y && mouseY < (y + h)) {
return true;
}
return false;
}
}