Does (HTML5) Canvas have the equivalent of an image map?

前端 未结 5 1207
南旧
南旧 2020-12-09 17:35

Does the Canvas element have the equivalent of img\'s map, so you can define clickable areas on the canvas element?

There is brief mention of a map halfway down the

5条回答
  •  没有蜡笔的小新
    2020-12-09 18:18

    Have you considered using svg instead of canvas? With svg the graphic itself can contain all the information you need for identifying active regions, and you can attach event handlers just like you would on html elements.

    Some examples of how you can detect mouseevents on different parts of the geometry of svg shapes:

    http://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlObject/interact-pevents-08-f.html

    http://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlObject/interact-pevents-09-f.html

提交回复
热议问题