views:

92

answers:

1

I'm working on a Raphael JS project and need to display some transparent PNGs with only the parts that are non-transparent to be clickable. Is there a way to:

  • Upon mouse click, pull out the alpha of the current position. or
  • Generate a path which can be be used to define the clickable region (i.e. http://raphaeljs.com/australia.html)
A: 

As raphael is for vector graphics, it is the wrong tool for your problem with png. I think canvas is what you looking for. Load your image in an canvas (the canvas doesent need to be pushed in the DOM). On click check the coords and get the pixel out of the canvas.

But maybe it will be easier to convert you png to vector graphics and use raphael instead.

eskimoblood
I'd go completely with canvas except that there's a lot more to this piece. I believe I can however use canvas and determine the alpha and do something with it (http://stackoverflow.com/questions/667045/getpixel-from-html-canvas).
Caleb
Yes you can. But svg is build for something like this (detect mouseover), where you have to rebuild the feature with canvas.
eskimoblood