Hit detection on non-transparent pixel

后端 未结 3 1951
[愿得一人]
[愿得一人] 2020-12-16 17:49

Given a PNG in a web context with some transparent pixels and some non-transparent pixels, is there a way in Javascript to determine if a user has clicked on a non-transpare

3条回答
  •  遥遥无期
    2020-12-16 18:50

    Canvas is the way to go for this purpose. But also remember that older internet explorer versions will not be capable of the getImageData() function. Even if you include excanvas.

    I made a small jquery plugin exactly for this purpose, maybe it will help you solving your problem without to completely reinvent the wheel. http://www.cw-internetdienste.de/pixelselection/

提交回复
热议问题