JavaScript raphael 圆形元素
我是 Raphael lib 的新手,我的问题如下:
我可以对圆形元素使用路径特定的方法(如 getTotalLength() 或 getPointAtLength() )吗?非常有帮助(一开始我认为圆以某种方式继承自路径 - 所以这应该是可能的......但它根本不起作用:(),即
var cir = paper.circle(100, 100, 20);
var totalength=cir.getTotalLength();
paper.text(50,150,'Length=('+totalength+')',20);
var pt = cir.getPointAtLength(0);
paper.text(50,250,'Point=('+pt.x+','+pt.y+')',20);
感谢对此的任何评论/提示/解释, 鲍里斯
I am a newbie to Raphael lib, my question is following:
can I use path specific methods (like getTotalLength()
or getPointAtLength()
) for a circle element - this would be quite helpfull (and at the begining I thought that circle somehow inherits from path - so that should be possible... but it simply does not work :( ), ie.
var cir = paper.circle(100, 100, 20);
var totalength=cir.getTotalLength();
paper.text(50,150,'Length=('+totalength+')',20);
var pt = cir.getPointAtLength(0);
paper.text(50,250,'Point=('+pt.x+','+pt.y+')',20);
thanks for any comments/hints/explanations on that,
Borys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遗憾的是你不能。 Circle 是它自己的 svg 元素。编写一些复制这些特定于路径的操作的函数并不难:
getTotalLength:
getPointAtLength:
你必须弄清楚圆的路径“开始”的位置,但有了这个设置,它就像:
Sadly you cannot. Circle is its own svg element. It wouldn't be too hard to write some functions that replicate these path-specific actions:
getTotalLength:
getPointAtLength:
You'd have to figure out where the circle's path 'starts', but with that set it's something like: