2017-07-28 6 views
0

私は、次のSVGコードがあります。SVGアニメーショングラデーションカラー

<svg height="130" width="500"> 
 
    <defs> 
 
    <linearGradient id="logo-gradient" x1="0%" y1="0%" x2="100%" y2="100%"> 
 
     <stop offset="0%" stop-color="#054f16"> 
 
     <animate attributeName="stop-color" values="#054f16; #91bc9c" dur="4s" repeatCount="indefinite"></animate> 
 
     </stop> 
 
     <stop offset="100%" stop-color="#01FF89"> 
 
     <animate attributeName="stop-color" values="#91bc9c; #054f16" dur="4s" repeatCount="indefinite"></animate> 
 
     </stop> 
 
    </linearGradient> 
 
    </defs> 
 
    <ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#logo-gradient)" /> 
 
    <text fill="#ffffff" font-size="45" font-family="Verdana" x="50" y="86">SVG</text> 
 
    Sorry, your browser does not support inline SVG. 
 
</svg>

を私は、テキストの後ろに、SVGコンテナに流れるスムーズに保つために勾配をアニメーション化する探しています。 this fiddleからわかるように、それは不安定です。これをどうやって解決するのですか?ありがとう!

答えて

1

アニメーションを開始点から前後に循環させるには、各values属性に余分な値を追加するだけです。値は開始色でなければなりません。

<svg height="130" width="500"> 
 
    <defs> 
 
    <linearGradient id="logo-gradient" x1="0%" y1="0%" x2="100%" y2="100%"> 
 
     <stop offset="0%" stop-color="#054f16"> 
 
     <animate attributeName="stop-color" values="#054f16; #91bc9c; #054f16" dur="4s" repeatCount="indefinite"></animate> 
 
     </stop> 
 
     <stop offset="100%" stop-color="#01FF89"> 
 
     <animate attributeName="stop-color" values="#91bc9c; #054f16; #91bc9c" dur="4s" repeatCount="indefinite"></animate> 
 
     </stop> 
 
    </linearGradient> 
 
    </defs> 
 
    <ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#logo-gradient)" /> 
 
    <text fill="#ffffff" font-size="45" font-family="Verdana" x="50" y="86">SVG</text> 
 
    Sorry, your browser does not support inline SVG. 
 
</svg>