Scaling Mouse Interactions
in
Programming Questions
•
3 years ago
I've pushed myself into a corner where I have to scale an entire sketch. The
scale() works well, however I have these mouse sensitive areas that don't scale with the render.
E.G.
- float xpos, ypos, r;
- void setup() {
- size(800, 800);
- xpos = width/2;
- ypos = height/2;
- r = 25;
- }
- void draw() {
- background(255);
- pushMatrix();
- scale(2.0);
- translate(-width/4, -height/4);
- if(sqrt(sq(xpos - mouseX) + sq(ypos - mouseY)) < r) fill(255, 0, 0);
- else fill(0, 0, 255);
- rect(xpos - r, ypos - r, r*2, r*2);
- popMatrix();
- }
Now I could use a multiplier on the radius to make
r
in the if statement reflect the new radius, 50, but I was wondering if there was a way that I could do it without having to actually rewrite the number value. I'm totally stumped...
1