Hit detection on non-transparent pixel

后端 未结 3 1945
[愿得一人]
[愿得一人] 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:46

    I know these things are out of fashion these days, but HTML image maps are still valid, and can accomplish adding hit targets to nearly-arbitrary shapes within an image. If you don't actually want to reload another page on click, you could probably change the anchor in the URL with this technique and pick up the change with a Javascript interval.

提交回复
热议问题