SVG 动画渐变停止

Vin*_*ent 1 animation svg gradient

我有一个 SVG,我想从左到右和向后设置渐变停止动画。我设法从左到右设置动画,但我不知道如何设置动画。

这是我的代码:

<svg id="mySvg" width="700px" height="498px">
    <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-0.4998" y1="250" x2="700" y2="250">
          <stop  offset="0" style="stop-color:#FFFFFF;stop-opacity:0.1">
              <animate attributeName="offset" begin="0s" dur="2s" from="0" to="1" repeatCount="indefinite" />
          </stop>             
         <stop  offset="1" style="stop-color:#FFFFFF;stop-opacity:0.1"/>                                    
    </linearGradient>

    <path fill="url(#SVGID_1_)" d="M691.115,114.684c-9.084,0-16.193,7.1 ..."/>
</svg>
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能创建一个动画,使渐变停止不断从左向右和向后移动

非常感谢,

文森特

Rob*_*jon 6

不要使用 from 和 to 属性,而是尝试使用 values='0;1;0'。values 属性允许您指定随时间推移希望使用的任意数量的值,而不仅仅是两端的两个值。

有时可能难以消化,但规范中的相关章节涵盖了许多对动画有用的知识:http : //www.w3.org/TR/SVG/animate.html