//A2-12 _ Create a button that changes the color of the background when it is clicked. //global variables int rectX = 30; int rectY = 25; int rectWidth = 240; int rectHeight = 45; PFont font; //setup method void setup(){ size (300,300); background (255); smooth (); } //draw method void draw(){ fill(70); rect (rectX-3, rectY-3, rectWidth+6, rectHeight+6); fill (0); rect (rectX, rectY, rectWidth, rectHeight); fill (211,28,218); font = loadFont ("ComicSansMS-Bold-28.vlw"); textFont (font, 18); text ("Change Background Color!!!", 40,45); textFont (font, 14); text ("Click here :-)", 100,65); } //method actives when mouse is pressed that changes the background color void mousePressed(){ float R = random(255); float G = random(255); float B = random(255); if (mouseX >= rectX && mouseX <= (rectX + rectWidth) && mouseY >= rectY && mouseY <= (rectY + rectHeight)){ background (R,G,B); } }