Animating SVG path fill bottom-top

戏子无情 提交于 2019-12-02 10:18:21

For those interested I have found the solution (not sure if that's the cleanest way to do it or not but never the less).

https://jsfiddle.net/812x1tqu/1/

    <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 148 148" style="enable-background:new 0 0 148 148;" xml:space="preserve">
<style type="text/css">
    .st0{stroke:#000;stroke-miterlimit:10;}
    .st1{stroke:#000;stroke-miterlimit:10;}
</style>

 <linearGradient id="blue-fill" x1="0.5" y1="1" x2="0.5" y2="0">
          <stop offset="100%" stop-opacity="1" stop-color="blue">
            <animate attributeName="offset" values="0;1" repeatCount="1" dur="3s" begin="0s"/>
          </stop>
          <stop offset="100%" stop-opacity="0" stop-color="blue">
            <animate attributeName="offset" values="0;1" repeatCount="1" dur="3s"  begin="0s"/>
          </stop>

      </linearGradient>

      <linearGradient id="pink-fill" x1="0.5" y1="1" x2="0.5" y2="0">
          <stop offset="0%" stop-opacity="0" stop-color="pink">
            <animate attributeName="offset" values="0;1" repeatCount="1" dur="3s" begin="3s" fill="freeze"/>
             <animate attributeName="stop-opacity" values="0;1" repeatCount="1" dur="0.1s" begin="3s" fill="freeze"/>

          </stop>
          <stop offset="100%" stop-opacity="0" stop-color="pink">
            <animate attributeName="offset" values="0;1" repeatCount="1" dur="3s"  begin="3s" fill="freeze" />
            <animate attributeName="stop-opacity" values="0;1" repeatCount="1" dur="3s" begin="6s" fill="freeze"/>


          </stop>

      </linearGradient>


<g id="XMLID_1_">
    <path fill="url(#blue-fill)" id="XMLID_4_" class="st0" d="M147.4,71.3L0.8,67.3c-0.2,2.2-0.3,4.4-0.3,6.7c0,40.6,32.9,73.5,73 .5,73.5s73.5-32.9,73.5-73.5
        C147.5,73.1,147.5,72.2,147.4,71.3z"/>
    <path fill="url(#pink-fill)" id="XMLID_3_" class="st1" d="M74,0.5C35.7,0.5,4.2,29.8,0.8,67.3l146.6,4.1C146.1,32,113.7,0.5,74,0.5z"/>
</g>
</svg>

**NOTE: The SVG path got a little messed up (and I did not feel like cleaning it up) but the animation code will be the same regardless.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!