如何用raphael js绘制曲线?

时间:2010-12-22 15:33:36

标签: javascript raphael

我希望在5秒内画出Shape M114,100c0,50 100-50 100,0c0,50 -100-50 -100,如何使用raphael js?

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Raphaël · Gear</title>
<style type="text/css">
body{overflow-x:hidden;overflow-y:scroll;width:100%;padding:0;margin:0;background-color:#022d00;}
</style>
<script src="raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
window.onload = function () {
    var paper = Raphael(0, 0, 500, 600);
    var path1=paper.path("M114 253").attr({"stroke": "#999", "stroke-width":1});

    path1.animate({path: "M114,100c0,50 100-50 100,0c0,50 -100-50 -100"},5000).attr({"stroke": "#999", "stroke-width":1});
});
}
</script>
</head>
<body>
    <div id="stroke"></div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

为path1取出一个'很多'的attr

var path1=paper.path("M114 253")

path1.animate({path: "M114,100c0,50 100-50 100,0c0,50 -100-50 -100"},5000).attr({"stroke": "#999", "stroke-width":1}); 

var path1=paper.path("M114 253").attr({"stroke": "#999", "stroke-width":1});      

path1.animate({path: "M114,100c0,50 100-50 100,0c0,50 -100-50 -100"},5000);

适合我。