Connecting Tech Pros Worldwide Help | Site Map

Mouse over of arbitrary shapes

  #1  
Old March 12th, 2008, 12:45 PM
amaccormack@gmail.com
Guest
 
Posts: n/a
I can think of a number of ways do detect if the mouse if over (or
clicking on, etc) a arbitrary shaped bitmapped image (say, some sprite
where we want pixel-perfect click detection, not an enclosing
rectangle) , such as some kind of array with a mask in it, individual
lines of the sprite split into tiny rectangles, doing it all on the
server side via an XML request, but I wondered if anyone could offer
their experience or thoughts on the "best" way to do this that doesn't
eat too much client or server resources.
  #2  
Old March 12th, 2008, 03:05 PM
Erwin Moller
Guest
 
Posts: n/a

re: Mouse over of arbitrary shapes


amaccormack@gmail.com wrote:
Quote:
I can think of a number of ways do detect if the mouse if over (or
clicking on, etc) a arbitrary shaped bitmapped image (say, some sprite
where we want pixel-perfect click detection, not an enclosing
rectangle) , such as some kind of array with a mask in it, individual
lines of the sprite split into tiny rectangles, doing it all on the
server side via an XML request, but I wondered if anyone could offer
their experience or thoughts on the "best" way to do this that doesn't
eat too much client or server resources.
Hi,

What about the good old imagemap?
Google 'imagemap', and you'll find a lot of resources.

You can make arbitrary shapes in it, and define also your JavaScript
handlers.

Here is a quick starters guide:
http://www.w3schools.com/tags/tag_map.asp

Of course you can also homecook your own routine, based on the x and y
position of the mouse over the image, but why reinvent the wheel?

Regards,
Erwin Moller
Closed Thread