【发布时间】:2017-06-04 17:13:51
【问题描述】:
我想用 SVG 创建动画,但遇到了一些问题。 小圆圈将沿着大圆圈的路径移动。 这里有人可以用一些提示或简单的例子告诉我吗? 我用 css 试过,但这不是正确的方法。
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<svg>
<circle id="c1" cx="100" cy="100" r="90" stroke="#ccc" stroke-width="2" fill="none"/>
<circle id ="c2" cx="100" cy="10" r="8" stroke="#f00" stroke-width="3" fill="#fff"/>
</svg>
<script>
circle1=document.getElementById("c1");
circle2=document.getElementById("c2");
for (i=1;i<60;i++){
// here is must calc the points
//of the path of the circle
//that is difficult but not such a problem
//but i don´t see an animation
//but I see no animation
circle2.setAttribute("cx",100+i);
circle2.setAttribute("cy",100+i);
}
</script>
</body>
</html>
【问题讨论】:
标签: javascript svg