我正在使用SVG尝试和动画渐变路径 - 创建一个尾巴/流星效果。在这样做的时候,我想要在尾部前部制作一个物体,我在下面的例子中展示了这些物体(圆圈)。试图动画SVG渐变
该示例在谷歌浏览器中几乎没有任何作用,还没有检查其他人......您可以看到我有5个圈/路径,只有其中一个正常工作。弯曲的人以与对象不同的速度对渐变进行动画处理,除了“几乎水平”的外,其他人不能正常工作。
有人可以请提供一些见解,为什么这不起作用,建议一种方法,我可以做到这一点,并提供一个例子,如果可能?
我几乎到了我会只写我自己在画布渲染代码,并使用JS库点... :(
<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>
水平或垂直线上不能有objectBoundingBox单位渐变。你必须将它们转换为userSpaceOnUse单位。这是你的问题的一部分。 –