//// procesing homework //// final //// laila shereen sakr 03.03.2008 // get some variables (dimensions of our angle) int h = 30; // button height int w = 40; // button width int xc = 200; // x of center of button int yc = 150; // y of center int xmin = xc - w/2; // left edge of button int xmax = xc + w/2; // right edge int ymin = yc - h/2; // top edge int ymax = yc + w/2; // bottom // setup the canvas void setup(){ size(400, 300); // do not want to change this later PImage b; b = loadImage("thepic.jpg"); image(b, 0, 0); frameRate(10); // slow } // draw something void draw(){ fill(255); // slider bg gray rect(40, 150 - h/2, 320, h); // our button drawB(); // draw my button ellipse(mouseX, mouseY, 40, 30); // small ellipse } boolean hot(int x, int y) { boolean temp = false; if (( y > ymin) && ( y < ymax )) { temp = true; } return temp; } // here is the button code void drawB() { if (( mousePressed == true ) && ( hot(mouseX, mouseY) == true)) { xc = mouseX; // relocate button } noStroke(); fill(100, 0, 0);// blue rect(xc - w/2, 150 - h/2, w, h); // our button } //// end