Phr*_*ogz 3 animation svg smil
我正在尝试<animateMotion>通过使用keyTimes="…"and keyPoints="…"属性在SVG上使用非线性动画速率。它似乎不起作用:动画运动是尽可能线性的。
这是测试文件,尝试一下!
<svg xmlns="http://www.w3.org/2000/svg" xmlns:x="http://www.w3.org/1999/xlink"
viewBox="0 0 300 200">
<style>
path { stroke:#999 }
circle { fill-opacity:0.5; stroke:black }
</style>
<path id="p" d="M30,160 L270,40" />
<circle id="c" r="5" />
<animateMotion x:href="#c" fill="freeze"
dur="10s"
keyTimes="0;0.1;1"
keyPoints="0;0.9;1">
<mpath x:href="#p" />
</animateMotion>
</svg>
Run Code Online (Sandbox Code Playgroud)
工作时,球应在第一秒内沿路径移动90%,并在剩余的9秒内将最后10%的路径移动。我需要进行哪些更改才能使其正常工作?
我在网上找到了另一个可以正常运行的示例,因此我知道这不是我的OS /浏览器/版本存在问题。
(FWIW:Win7x64,Chrome30)
我发现了我的错误。尽管的默认值calcMode是linear我想要的,但我对规范的理解还不够深入,无法看到它是元素的不同默认值<animateMotion>。
添加显式即可calcMode="linear"解决此问题。
calcmode动画运动的默认值paced不是linear;
http://www.w3.org/TR/SVG/animate.html#AnimateMotionElement
\n\n并且,如果指定了calcmode = "paced" ,则任何 \xe2\x80\x98keyTimes\xe2\x80\x99 或 \xe2\x80\x98keySplines\xe2\x80\x99 将被忽略。
\n\nhttp://www.w3.org/TR/SVG/animate.html#CalcModeAttribute;
\n\n这就是为什么你没有得到所需的输出......
\n