使用 Raphael JS 从透明 PNG 创建路径/图像映射
我正在开发一个 Raphael JS 项目,需要显示一些透明的 PNG,其中只有不透明的部分可单击。有没有办法:
- 单击鼠标时,拉出当前位置的 alpha。 或
- 生成可用于定义可点击区域的路径(即 http://raphaeljs.com/australia。 html)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 raphael 用于矢量图形,因此它对于解决 png 问题来说是错误的工具。我认为画布正是您所寻找的。 将图像加载到画布中(画布不需要推入DOM)。单击后检查坐标并从画布中获取像素。
但也许将 png 转换为矢量图形并使用 raphael 会更容易。
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.