Ich benutze SVG, um einen Gradientenpfad zu animieren und zu animieren - um einen Tail/Shooting-Star-Effekt zu erzeugen. Dabei möchte ich ein Objekt an der Vorderseite des Schwanzes animieren, das ich in meinem Beispiel unten gezeigt habe (die Kreise).Versuch, SVG-Gradient zu animieren
Das Beispiel funktioniert kaum in Google Chrome, habe andere nicht überprüft ... Sie können sehen, ich habe 5 Kreise/Pfade und nur 1 von ihnen funktioniert ordnungsgemäß. Der gekrümmte animiert den Gradienten mit einer anderen Geschwindigkeit als das Objekt und die anderen funktionieren überhaupt nicht richtig außer dem "fast-horizontalen".
Kann mir bitte jemand einen Einblick geben, warum das nicht funktioniert, einen Weg vorschlagen, wie ich das machen könnte und wenn möglich ein Beispiel geben?
Ich bin fast bis zu dem Punkt, wo ich werde einfach mein eigenes machen Code in Leinwand schreiben und eine JS-Bibliothek ... :(
<svg style="height: 400px; width: 100%" viewBox="0 0 500 200">
<path id="circlePath1" stroke-width="2" d="M10 100 Q 100 10, 150 80 T 300 100" stroke="url(#grad)" fill="transparent"></path>
\t <path id="circlePath2" stroke-width="2" d="M30 20 L 130 19" stroke="url(#grad)" fill="transparent"></path>
\t <path id="circlePath3" stroke-width="2" d="M30 10 L 130 10" stroke="url(#grad)" fill="transparent"></path>
\t <path id="circlePath4" stroke-width="2" d="M10 10 L 10 110" stroke="url(#grad)" fill="transparent"></path>
\t <path id="circlePath5" stroke-width="2" d="M10 20 L 20 110" stroke="url(#grad)" fill="transparent"></path>
\t
\t <linearGradient id='grad'>
\t \t <stop stop-opacity="0" stop-color='#800'>
\t \t \t <animate attributeName="offset" dur="2s" values='-0.20;0.80' repeatCount="indefinite" ></animate>
\t \t </stop>
\t \t <stop stop-color='#800' stop-opacity=".5">
\t \t \t <animate attributeName="offset" dur="2s" values='-0.02;0.98' repeatCount="indefinite" ></animate>
\t \t </stop>
\t \t <stop stop-opacity="0.5" stop-color='#800'>
\t \t \t <animate attributeName="offset" dur="2s" values='-0;1' repeatCount="indefinite" ></animate>
\t \t </stop>
\t \t <stop stop-opacity="0" stop-color='#800'>
\t \t \t <animate attributeName="offset" dur="2s" values='-0;1' repeatCount="indefinite" ></animate>
\t \t </stop>
\t </linearGradient>
\t
\t <circle id="c1" r="2.5" cx="" cy="" fill="#880000">
\t \t <animateMotion dur="2s" repeatCount="indefinite">
\t \t \t <mpath href="#circlePath1"></mpath>
\t \t </animateMotion>
\t </circle>
\t <circle id="c2" r="2.5" cx="" cy="" fill="#880000">
\t \t <animateMotion dur="2s" repeatCount="indefinite">
\t \t \t <mpath href="#circlePath2"></mpath>
\t \t </animateMotion>
\t </circle>
\t <circle id="c3" r="2.5" cx="" cy="" fill="#880000">
\t \t <animateMotion dur="2s" repeatCount="indefinite">
\t \t \t <mpath href="#circlePath3"></mpath>
\t \t </animateMotion>
\t </circle>
\t <circle id="c4" r="2.5" cx="" cy="" fill="#880000">
\t \t <animateMotion dur="2s" repeatCount="indefinite">
\t \t \t <mpath href="#circlePath4"></mpath>
\t \t </animateMotion>
\t </circle>
\t <circle id="c5" r="2.5" cx="" cy="" fill="#880000">
\t \t <animateMotion dur="2s" repeatCount="indefinite">
\t \t \t <mpath href="#circlePath5"></mpath>
\t \t </animateMotion>
\t </circle>
</svg>
Sie können keinen Gradienten der ObjektBoundingBox-Einheit auf einer horizontalen oder vertikalen Linie haben. Sie müssen sie in userSpaceOnUse-Einheiten konvertieren. Das ist Teil deines Problems. –