Hello,
I want to creat a simple button but with a rect which rotate with a pushMatrix/popMatrix transformation.
Of course I can't use my overRect() method in this condition, but do you know how I can do ?
Thanks !
I want to creat a simple button but with a rect which rotate with a pushMatrix/popMatrix transformation.
Of course I can't use my overRect() method in this condition, but do you know how I can do ?
Thanks !
- color over = color(200, 0, 0);
color out = color(0);
color temp;
void draw() {
rectMode(CENTER);
int w =20, h =30;
int x =50, y =30;
pushMatrix();
translate(x, y);
rotate(PI/5);
fill(temp);
rect(0, 0, w, h);
if (overRect(x, y, w, h)) {
temp = over;
}
else {
temp = out;
}
popMatrix();
}
boolean overRect(float x, float y, int w, int h)
{
if (mouseX >= x - w/2 && mouseX <= x + w/2 &&
mouseY >= y - h/2 && mouseY <= y + h/2) {
return true;
}
else {
return false;
}
}
1