scale a ellipse according to mouse
in
Programming Questions
•
1 year ago
I did this before but that was with touch screen which was much easier.
I want to be able to scale a ellipse by dragging the mouse.
Scaling bigger is not a problem for me, but getting it smaller doesn't work out for me.
Can't be that hard lol :)
- float d =20;
- int mousePressX, mousePressY;
- float lastD;
- void setup() {
- size(400, 400);
- smooth();
- }
- // . . . . . . . . . . . . . . . . . . .
- void draw() {
- background(255);
- ellipse(width/2, height/2, d, d);
- }
- void mousePressed() {
- mousePressX = mouseX;
- mousePressY = mouseY;
- lastD = d;
- }
- // . . . . . . . . . . . . . . . . . . .
- void mouseDragged() {
- //d = lastD + dist(width/2, height/2, mouseX, mouseY)*2;
- //d = lastD + dist(mousePressX, mousePressY, mouseX, mouseY)*2;
- d = lastD - dist(width/2, height/2, mouseX, mouseY)*2;
- // float newD = dist(mousePressX, mousePressY, width/2, height/2);
- // d -= newD;
- // lastD = d;
- }
1