【发布时间】:2011-12-20 21:48:34
【问题描述】:
我想生成一个随时间变化的 SVG 渐变。
在此示例代码中,我想生成一个椭圆,其渐变为红色,带有随时间从西向东传播的黄色条纹(创建微光效果):
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" >
<animate
attributeName="offset"
from="0%"
to="100%"
repeatCount="indefinite"/>
</stop>
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
</defs>
<ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad1)" />
</svg>
这还不起作用,但我不确定是因为我做错了,还是我无法使用 SVG 渐变实现效果。
【问题讨论】: