SVG SMIL动画成长元素
SVG SMIL animation growing element
任何人都可以解释一下决定 "growing" 动画方向的因素吗?我会展示小例子
<svg version="1.1" id="Ring" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 450 320" style="enable-background:new 0 0 450 320;" xml:space="preserve">
<path id="innerRing" fill="none"; stroke="#F7DE4B"; stroke-width="10"; stroke-miterlimit="10"; d="M227.1,25.8c-43.4,0-78.6,8.6-78.6,19.4s35.2,19.4,78.6,19.4s78.6-8.6,78.6-19.4
S270.6,25.8,227.1,25.8z"/>
<animate xlink:href="#innerRing" attributeName="stroke-dasharray" from="0 168.409 0 168.409 " to="0 0 326.818 0" begin="0" dur="1" repeatCount="1" />
<path id="outerRingMin" fill="none"; stroke="#B2A31B"; stroke-width="0.9"; stroke-miterlimit="10";
d="M227.1,59.8c-40.5,0-73.2-6.5-73.2-14.5s32.8-14.5,73.2-14.5c40.5,0,73.2,6.5,73.2,14.5
S267.5,59.8,227.1,59.8"/>
<animate xlink:href="#outerRingMin" attributeName="stroke-dasharray" from="0 153.693 0 153.693" to="0 0 307.386 0" begin="0" dur="1" repeatCount="1" />
<path id="outerRingMax" fill="none"; stroke="#B2A31B"; stroke-width="0.9"; stroke-miterlimit="10"; d="M227.1,69c46,0,83.4-10.7,83.4-24s-37.3-24-83.4-24c-46,0-83.4,10.7-83.4,24
c0,13.2,36.7,23.8,82.1,24L227.1,69z"/>
<animate xlink:href="#outerRingMax" attributeName="stroke-dasharray" from="0 181.92 0 181.92" to="0 0 363.84 0" begin="0" dur="1" repeatCount="1" />
</svg>
为什么中间的圆圈(黄色)是从下往上上升的。 ?它是如何变化的?
因为中间圆的起点被翻转了。
最简单的修复方法是在中间圆圈中添加 stroke-dasshoffset 属性来移动笔划的起点,就像这样。
<path id="innerRing" fill="none" stroke="#F7DE4B"
stroke-dashoffset="168.409"
stroke-width="10" stroke-miterlimit="10"
d="M227.1,25.8c-43.4,0-78.6,8.6-78.6,19.4s35.2,19.4,78.6,19.4s78.6-8.6,78.6-19.4
S270.6,25.8,227.1,25.8z"/>
任何人都可以解释一下决定 "growing" 动画方向的因素吗?我会展示小例子
<svg version="1.1" id="Ring" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 450 320" style="enable-background:new 0 0 450 320;" xml:space="preserve">
<path id="innerRing" fill="none"; stroke="#F7DE4B"; stroke-width="10"; stroke-miterlimit="10"; d="M227.1,25.8c-43.4,0-78.6,8.6-78.6,19.4s35.2,19.4,78.6,19.4s78.6-8.6,78.6-19.4
S270.6,25.8,227.1,25.8z"/>
<animate xlink:href="#innerRing" attributeName="stroke-dasharray" from="0 168.409 0 168.409 " to="0 0 326.818 0" begin="0" dur="1" repeatCount="1" />
<path id="outerRingMin" fill="none"; stroke="#B2A31B"; stroke-width="0.9"; stroke-miterlimit="10";
d="M227.1,59.8c-40.5,0-73.2-6.5-73.2-14.5s32.8-14.5,73.2-14.5c40.5,0,73.2,6.5,73.2,14.5
S267.5,59.8,227.1,59.8"/>
<animate xlink:href="#outerRingMin" attributeName="stroke-dasharray" from="0 153.693 0 153.693" to="0 0 307.386 0" begin="0" dur="1" repeatCount="1" />
<path id="outerRingMax" fill="none"; stroke="#B2A31B"; stroke-width="0.9"; stroke-miterlimit="10"; d="M227.1,69c46,0,83.4-10.7,83.4-24s-37.3-24-83.4-24c-46,0-83.4,10.7-83.4,24
c0,13.2,36.7,23.8,82.1,24L227.1,69z"/>
<animate xlink:href="#outerRingMax" attributeName="stroke-dasharray" from="0 181.92 0 181.92" to="0 0 363.84 0" begin="0" dur="1" repeatCount="1" />
</svg>
因为中间圆的起点被翻转了。
最简单的修复方法是在中间圆圈中添加 stroke-dasshoffset 属性来移动笔划的起点,就像这样。
<path id="innerRing" fill="none" stroke="#F7DE4B"
stroke-dashoffset="168.409"
stroke-width="10" stroke-miterlimit="10"
d="M227.1,25.8c-43.4,0-78.6,8.6-78.6,19.4s35.2,19.4,78.6,19.4s78.6-8.6,78.6-19.4
S270.6,25.8,227.1,25.8z"/>