How to draw a fill svg?

前端 未结 3 797
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-16 08:02

I want to animate my logo like drawing it for reveal it, it is looking like that:

is it possible to draw only with a fill? every tutorials i looked showed

相关标签:
3条回答
  • 2020-12-16 08:32

    this is the gradient solution i found:

    <defs>
        <lineargradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
          <stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:0">
    	  <animate attributeName="stop-opacity" values="0; 1" begin="middle1.end" dur="1s" fill="freeze" />
    	  </stop>
    	  <stop offset="40%" style="stop-color:rgb(255,255,255);stop-opacity:0">
    	   <animate attributeName="stop-opacity" values="0; 1" begin="2000ms" dur="1s" id="middle1" fill="freeze" /></stop>
    	   <stop offset="70%" style="stop-color:rgb(255,255,255);stop-opacity:0">
    	   <animate attributeName="stop-opacity" values="0; 1" begin="800ms" dur="2s" id="middle" fill="freeze" /></stop>
          <stop offset="100%" style="stop-color:rgb(255,255,255);stop-opacity:0">
    	  <animate attributeName="stop-opacity" values="0; 1" dur="1s" id="down" fill="freeze" /></stop>
        </lineargradient>
      </defs>

    https://jsfiddle.net/9mhxpbph/

    0 讨论(0)
  • 2020-12-16 08:42

    With a nice and simple logo like that, you can easily fake it by using strokes:

    1. Add a couple of "fake" lines to your SVG with stroke-width wide enough to cover the logo.
    2. Use the original logo path (.st1) as a clipPath on those lines to hide the parts that are outside the logo.
    3. Animate the "fake" lines. (How SVG Line Animation Works)

    Updated fiddle: https://jsfiddle.net/b4dn44kL/1/

    0 讨论(0)
  • 2020-12-16 08:42

    The short answer is no. There is no easy way to have the "drawn line" effect for an arbitrary filled shape. You could use a mask of a linear fill to "fill" it from top to bottom, or bottom to top. But that obviously would follow the shape of the line around the loop etc.

    You are pretty much stuck with using the traditional animation technique: draw a sequence of frames and show them one after the other.

    0 讨论(0)
提交回复
热议问题