How can I detect if something exists within an ellipse drawn on the screen?

edited May 2015 in How To...

How can I detect if something exists within an ellipse drawn on the screen?

Answers

  • Easiest case is testing if a point is inside a circle. If the distance between a point and the center of the circle is less than (or equal) the radius of the circle then it is inside

  • edited May 2015

    You don't give a lot of details, but you ask if something is within an ellipse drawn on the screen. If that "thing" is represented by a point (or just a few of them), and the ellipse is indeed drawn, and it's on top of everything else and a unique color, you could just test the color of the pixel at that point (or points). If that pixel (or pixels) matches the ellipse's color, you're inside, otherwise, you're not.

  • Floritudes idea can be done when you have an invisible PGraphics pg the sign of your sketch and paint the ellipse here with one color (same size, same pos), the you can do the tests on pg. (then some of the constraints fall away)

Sign In or Register to comment.