Files
processing4/java/examples/Books/Processing Handbook/Synthesis/Synthesis_16_sodaprocessing/Control.pde
2012-04-08 18:07:42 +00:00

49 lines
719 B
Plaintext

class Control {
int x,y,w,h;
boolean over = false;
String label;
Control(int x, int y, int w, int h, String label) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.label = label;
}
boolean mouseIn() {
return over = mouseX>x&&mouseX<x+w&&mouseY>y&&mouseY<y+h;
}
boolean mousePressed() {
return mouseIn();
}
void mouseDragged() {
mouseIn();
}
boolean mouseReleased() {
return mouseIn();
}
void display() {
stroke(0x00,0x99,0xFF);
if (over)
fill(0xDD,0xDD,0xDD);
else
fill(0xFF,0xFF,0xFF);
rect(x,y,w,h);
drawContents();
stroke(0);
fill(0);
text(label, x+2, (y+h)-3);
}
void drawContents() {
}
}