check if ellipse hit's line
in
Programming Questions
•
6 months ago
How can i check if the mouse hit's the line with a certain tolerance of lets say 5 pixels?
I could do it with bezierPoints (bp) over the line and check if the bp is closer then the tolerance.
However, i'm wondering if there are any other methods.
- void setup() {
- size(400, 400);
- smooth();
- }
- // . . . . . . . . . . . . . . . . . . .
- void draw() {
- background(255);
- stroke(0);
- line(30, 30, 250, 250);
- ellipse(mouseX, mouseY, 5, 5);
- }
- // . . . . . . . . . . . . . . . . . . .
1