I made a form of parking spaces in a RV storage facility. Each space was a button and irregularly shaped and at odd angles.
As you suggested given a mouse click, I selected all potential shapes close for performance. To determine which shape the click actually was I took all adjacent corners of a shape and formed triangles with the click. Then computed the areas of these triangles. If all areas are positive (or negative, depending which way you order the corners) the click is within the shape. This only works if the shapes are convex. On May 11, 2012 10:42 AM, "Ian Clark" <earthspo...@gmail.com> wrote: > To save me reinventing the wheel, has anybody written routines to act > on mouseclicks inside irregularly-shaped "buttons"? > > Techniques I'm considering: > > ++ Detecting if a point is inside an arbitrary polygon > > ++ Unions and differences of rectangles, triangles and sectors > > ++ Color of the pixel under the cursor > > If it works on a simple map of the USA, it'll probably work for my purpose. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm