drawing program: how to draw ellipse to touch two points on the perimeter?
in
Programming Questions
•
1 year ago
I'm trying to draw an ellipse right under the user's mouse (as they drag). I'm close (below), but when I use the mouse coords for width and height, it draws a circle that fits inside where they're clicking instead of a circle whose perimeter is underneath the points they have clicked on. The problem becomes more significant as you draw a bigger circle (the second point goes pretty far to the right and below the circle).
Thanks for any help-
Thanks for any help-
- float startX, startY, x, y, w, h;
void setup() {
size(500,500);
noFill();
}
void draw () {
background(#808080);
ellipse(x, y, w, h);
}
void mouseDragged() {
x = (startX + mouseX) / 2.0;
y = (startY + mouseY) / 2.0;
w = abs(mouseX - startX);
h = abs(mouseY - startY);
}
void mousePressed() {
startX = mouseX;
startY = mouseY;
}
1