【发布时间】:2020-04-05 01:33:05
【问题描述】:
这里试图深入了解 SVG。有什么方法可以沿着 SVG 路径移动一个圆圈,圆圈从路径长度确定的特定点开始移动?
例如,当对象到达终点时,它又从头开始。使用什么属性来让圆从一个随机点移动,例如,从 from 20 而不是 0 to 100 开始?
SVG 中有一个直接的 from 和 to,但我不确定如何正确使用它。另外,我发现keytimes 在某些情况下很有用,但它并没有产生预期的结果。
在这里您可以看到 SVG 的 HTML 沿着一条路径移动,它当前从头开始:
<div id="pathContainer4">
<svg height="160" width="360">
<g fill="none" stroke="black" stroke-width="1">
<path stroke-dasharray="3" id="motionpath2"
d="M 10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />
</g>
<circle class="circle2" r=8 fill=red ;z-index=55>
<animateMotion dur="2s" repeatCount="indefinite"
rotate="auto" from="20" to="100">
<mpath href="#motionpath2" />
</animateMotion>
</circle>
</svg>
</div>
【问题讨论】:
-
不是没有javascript。纯 SMIL 中没有“随机”。
标签: html svg svg-animate