class LeadButtons{ float r; float g; float blu; float r2; float g2; float blu2; boolean playGuitar = true; boolean mouseOverTopBtn; boolean mouseOverBottomBtn; float x = (GRID_SPACE/5); float y = (GRID_SPACE/5); float btnWidth = (GRID_SPACE * 3); float btnHeight = ((GRID_SPACE * 2)/3); //constructor LeadButtons(){ } void display(){ if(playGuitar){ rollOverColor(); fill(r,g,blu); stroke(255); strokeWeight(3); rect((GRID_SPACE/5),(GRID_SPACE/5),(GRID_SPACE * 3),((GRID_SPACE * 2)/3)); noStroke(); fill(r2,g2,blu2); rect((GRID_SPACE/5),(GRID_SPACE + 3),(GRID_SPACE * 3),((GRID_SPACE * 2)/3)); showText(); } if(playGuitar == false){ rollOverColor(); fill(r,g,blu); stroke(255); noStroke(); rect((GRID_SPACE/5),(GRID_SPACE/5),(GRID_SPACE * 3),((GRID_SPACE * 2)/3)); stroke(255); strokeWeight(3); fill(r2,g2,blu2); rect((GRID_SPACE/5),(GRID_SPACE + 3),(GRID_SPACE * 3),((GRID_SPACE * 2)/3)); showText(); } } void rollOverColor(){ if(mouseOverTopBtn()){ r = 255; g = 143; blu = 5; r2 = 34; g2 = 48; blu2 = 188; } else if(mouseOverBottomBtn()){ r = 34; g = 48; blu = 188; r2 = 255; g2 = 143; blu2 = 5; } else{ r = 34; g = 48; blu = 188; r2 = 34; g2 = 48; blu2 = 188; } } boolean mouseOverTopBtn(){ if((mouseX > x) && (mouseX < (x + btnWidth)) && (mouseY > y) && (mouseY < (y + btnHeight))){ return true; } else { return false; } } boolean mouseOverBottomBtn(){ if((mouseX > x) && (mouseX < (x + btnWidth)) && (mouseY > (GRID_SPACE + 3)) && (mouseY < ((GRID_SPACE + 3) + btnHeight))){ return true; } else { return false; } } void mousePressed(){ if((mouseX > x) && (mouseX < (x + btnWidth)) && (mouseY > y) && (mouseY < (y + btnHeight))){ playGuitar = true; } if ((mouseX > x) && (mouseX < (x + btnWidth)) && (mouseY > (GRID_SPACE + 3)) && (mouseY < ((GRID_SPACE + 3) + btnHeight))){ playGuitar = false; } } void showText(){ textFont(OCR); fill(255); textAlign(CENTER); text("Guitar", (x + (GRID_SPACE * 1.5)), (y +GRID_SPACE/2)); text("Sax", (x + (GRID_SPACE * 1.5)), ((GRID_SPACE + 3) + (GRID_SPACE/2))); } }