2017-07-28 2 views
0

Ich habe folgenden SVG-Code:SVG animierten Farbverlauf

<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>

Ich suche die Gradienten zu animieren glatt zu halten in dem SVG-Behälter fließt, hinter dem Text. Wie Sie von this fiddle sehen können, ist es nervös. Wie behebe ich das? Vielen Dank!

Antwort

1

Um die Animation um den Startpunkt herum zu bewegen, fügen Sie einfach einen zusätzlichen Wert zu jedem values Attribut hinzu. Der Wert sollte die Startfarbe sein.

<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>