// processing IDE 3.5.3 // button tutorial // http://kll.engineering-news.org/kllfusion01/articles.php?article_id=166 // the word hardcoded means instead using variables for position x,y,w,h,... // direct first try usually is to use pix positions. // you do several of this buttons and learn ( the hard way ) that you need hundred of code lines // and easy get lost if need searching on errors. // but THIS is our tutorial START: // a functioning toggle 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 }