I am developing a 2D sketch that will include many (1,000+) irregular closed shapes, each made of two lines and two Bezier curves.
I would like to be able to both draw the shapes also be able to easily test whether each of them contains the mouse location.
Before I get too deep into the project, I am experimenting with possible approaches, and I have tried two ways to create the shapes:
Option 1. Use beginShape() and endShape()
Pro: Easy to draw/render/make visible.
Con: Difficult to determine whether or not the shape contains the mouse location.
Option 2. Import java.awt.geom.Path2D
Pro: Can easily test whether the shape contains the mouse.
Con: I can't figure out how to render it (e.g. give it a stroke and fill).
At this point, the only solution I can figure out is to simultaneously do both, by creating two co-located versions of each shape (a visible Processing version and an invisible Java Path2D version). This allows the shapes to be visible and also allows me to test whether they contain the mouse location. But it also seems really awkward and redundant. Any ideas for more elegant solutions, code examples, relevant libraries...?
Thanks!
1