Complex variables

while @glv is close,
with his idea of a function what would be STEP 1

but only after STEP 0 is completed.

sorry @humano, that is not a functioning button

and if you not have the functions of a button,
how can that be arranged / rewritten from

  • basic button

TO

  • variables and functions
  • functions with arrays
  • class
  • array of class

because none of these steps you would understand nor would they work
with just your circles.


so i would recommend that you follow glv’s advice ( about variables and functions )
after you have, play, understand
something like i call a “hard coded button”

boolean sel = false;

void setup() {
  size(300,300);
}

void draw() {
  background(200, 200, 0);
  if (sel)   fill(0, 200, 0);
  else       fill(0, 0, 200);
  if (mouseX > 100 & mouseX < 180 & mouseY > 100 & mouseY < 130) stroke(200, 0, 200);
  else                                                           stroke(0, 200, 200);
  strokeWeight(3);
  rect(100, 100, 80, 30);
  noStroke();
  fill(200);
  text("press", 110, 120);
}

void mousePressed() {
  if (mouseX > 100 & mouseX < 180 & mouseY > 100 & mouseY < 130)  sel = !sel; // button action
}

well, this is not what you want, but it is the minimum what you need to start from.
sorry, i know its heavy.

3 Likes