class Button { int x, y; // The x- and y-coordinates int bw; // Dimension (width and height) int bh; int me; // ID number for this button color baseGray; // Default gray value color overGray; // Value when mouse is over the button boolean over = false; // True when the mouse is over boolean pressed = false; // True when the mouse is over and pressed String colorMode; // int modeId; Button(int xp, int yp, int w, int h, String m, int id) { x = xp; y = yp; bw = w; bh = h; baseGray = 150; overGray = 200; colorMode = m; modeId = id; } // Updates the over field every frame void update() { if ((mouseX >= x) && (mouseX <= x+bw) && (mouseY >= y) && (mouseY <= y+bh)) { over = true; } else { over = false; } } boolean press() { if (over == true) { pressed = true; return true; } else { return false; } } void release() { pressed = false; // Set to false when the mouse is released } void display() { // fill white if mode selected, rollover effect for unselected mode if ((over == true) && (modeId != mode)) { fill(overGray); } else if (modeId == mode) { fill(255); } else { fill(baseGray); } stroke(100); rect(x, y, bw, bh); fill(0); text(colorMode, x+30, y+20); } }