如何通过raphael js库在动画后绘制线条?
我想在5秒内画出一个形状,就像这样。我使用 raphael js 库。但是动画之后如何画线呢? (我的意思是画出移动轨迹)。谢谢。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
window.onload = function () {
var r = Raphael(0, 0, 500, 600);
var p = r.path("M100,100c0,50 100-50 100,0c0,50 -100-50 -100").attr({stroke: "none"}),
e = r.ellipse(104, 100, 4, 4).attr({stroke: "none", fill: "#f00"})
e.attr({rx: 5, ry: 5}).animateAlong(p, 5000, true);
}
</script>
</head>
<body>
<div id="stroke"></div>
</body>
</html>
I want to draw a shape during 5 seconds, like this. I use raphael js library. But how to draw the line after animation? (I mean draw the moving trajectory). Thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
window.onload = function () {
var r = Raphael(0, 0, 500, 600);
var p = r.path("M100,100c0,50 100-50 100,0c0,50 -100-50 -100").attr({stroke: "none"}),
e = r.ellipse(104, 100, 4, 4).attr({stroke: "none", fill: "#f00"})
e.attr({rx: 5, ry: 5}).animateAlong(p, 5000, true);
}
</script>
</head>
<body>
<div id="stroke"></div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 onAnimation 动态更新路径。这是一个粗略的方法
You could use onAnimation to update a path dynamically. Here's a crude way