值得在SO 上阅读此答案,其中包含有关 dasharray 效果的信息,这可能很有用。这并不能直接回答馅饼的问题,但可能会给出一些想法。很大程度上取决于您希望动画的具体方式,以及这些是否适合您。
因此,您可以使用类似 "M 100, 100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0" 的字符串绘制一个完整的圆2 条弧线。
你也可以只用一个圆圈来做。因此,这里有一些内容,以及旁边的 Snap 示例,因为您将使用它,并且比较有用...
<svg width="600" height="425">
<path d="M 100, 100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0" fill="none" stroke="black" stroke-width="150" stroke-dasharray="0 600 600 0" stroke-dashoffset="1000">
<animate attributeType="XML" attributeName="stroke-dashoffset" from="0" to="600" dur="2s" repeatCount="1" fill="freeze"/>
</path>
<circle cx="150" cy="350" r="80" fill="none" stroke="red" stroke-width="161" stroke-dasharray="0 600 600 0" stroke-dashoffset="1000" >
<animate attributeType="XML" attributeName="stroke-dashoffset" from="0" to="600" dur="2s" repeatCount="1" fill="freeze">
</animate>
</circle>
</svg>
最后一点与 Snap.js 相同
var s = Snap(600,600);
var c = s.circle(150, 150, 80).attr({
fill: "none",
stroke: 'red',
strokeWidth: 161,
strokeDasharray: "0 600 600 0",
strokeDashoffset: 1000
});
Snap.animate(0,600, function( value ){
c.attr({ 'strokeDashoffset': value })
},5000 );
这是一个jsfiddle,他们都在