Re: mathmatical question..
- Posted by David Alan Gay <moggie at INTERLOG.COM> May 29, 1997
- 943 views
> Assumes the polygon with arbitrary numbers of points is drawn on the > pixel-graphics screen, for example; > > polygon(RED,1,{{100,200},{200,200},......,} > > Problem is: > How can I know whether the mouse pointer is INSIDE the polygon or not, > at the time the mouse button is pressed? > > Bye! > from Lee, WooSeob It's not even a mathematical problem...it's more like a question of "Is the mouse pointer over an image?" There's two ways of attacking this. One way is to use get_pixel() using the returned mouse x and y co-ordinates to obtain the pixel colour of where the mouse pointer is at. In the case of your polygon above, you know you are over the polygon if the colour RED is returned. Admittedly. it's not good for a polygon with mulitple or shared colours, but it works if the polygon is a complex shape. Another way is to make a sequence representing a map of what space the polygon occupies, and then search it using find() with the x and y mouse pointer co-ordinates as the search argument. If you get a hit, you know you are over the shape. This is much more preferable if the icon you are trying to make clickable is multi-coloured. Hope this helps David Gay http://www.digital-liquid.com/abgte "A Beginner's Guide To Euphoria"