HTML/HTML5 中使用 JS 的不规则锚点和形状
是否有可能在 JS 的某些表面上有不规则的形状,例如锚点,可以点击,并且在页面加载时在运行时变成一个球?我想要为那个可以是球的表面设置动画,并且还想跟踪特定点处的锚点形状。
那么用JS可以吗?如何才能实现这一目标?我无法找到任何解决方案。有没有一些 JS 库可以做到这一点?像processing.js 或Raphael js 之类的东西?
Is it possible to have irregular shapes like anchors on some surface in JS that can be clickable and it becomes a ball on runtime on page loads? I want to animate that surface that can be a ball and also want to track that which anchor shape is at particular point.
So is it possible using JS? How can this be achieved? I was unable to find any solution. Is there some JS library that can do this? Something like processing.js or Raphael js?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以推荐一个 HTML 图像地图吗?您可以在页面中嵌入 IMG 标签,设置其 usemap 属性,然后将该图像上的形状定义为可单击区域。
它没有画布那么多的功能,但在这种情况下,也许常规的 IMG 元素就可以了。
Could I suggest an HTML image map? You can embed an IMG tag in the page set it's usemap attribute and then define shapes on that image to be clickable areas.
It doesn't have as many features as a canvas but maybe a regular IMG element will do in this case.
我建议将 SVG 与优秀的 Raphael js 库一起使用。您可以使用纯 JavaScript(即无需额外插件)制作交互式动画,并且可以将这些对象制作为不规则锚点(覆盖
click
、mouseover
和mouseout
模拟锚点行为的事件)。另一种想法是使用HTML5画布,但这需要更多代码(技术还不成熟)并且可能无法在不同浏览器下工作。
I suggest using SVG with excelent Raphael js library. You can make interactive animations with pure javascript (i.e. without additional plugins) and those objects can be made irregular anchors (overriding
click
,mouseover
andmouseout
events to emulate anchor behaviour).Another idea is to use HTML5 canvas, but this requires more code (the technology is still immature) and may fail to work under different browsers.