SVG路径动画

本文展示了三个SVG动画效果:圆点沿着路径移动的动态动画,水珠沿直线流动的视觉效果,以及线条水流的流动动画。通过SVG的`<animateMotion>`和`<animate>`标签实现连续、循环的动画,为网页增添生动的视觉元素。

直接贴图和代码吧!

圆点动画

<svg width="350" height="200">
      <path d="M10 80 Q 77.5 10, 145 80 T 280 80" stroke="yellow" stroke-width="2" fill="transparent"></path>
      <circle cx="0" cy="0" r="2" fill="red">
          <animateMotion
                  path="M10 80 Q 77.5 10, 145 80 T 280 80"
                  dur="5s"
                  begin="1s"
                  fill="remove"
                  rotate="auto"
                  repeatCount="indefinite"
          >
          </animateMotion>
      </circle>
</svg>

圆点动画

水珠流动

<svg width="250" height="250">
     <path d="M10 80 H 100 V 200 H 10" stroke="orange"  stroke-linecap="round"  stroke-width="10" fill="transparent"></path>
     <rect width="6" height="2" rx="2" ry="2" fill="red" stroke-width="1" stroke="red" v-for="i in 20">
         <animateMotion
                 path="M10 80 H 100 V 200 H 10"
                 dur="10s"
                 :begin="1+(i - 1)*0.5+'s'"
                 fill="remove"
                 rotate="auto"
                 repeatCount="indefinite"
         >
         </animateMotion>
     </rect>
</svg>

水珠流动

水流

<svg width="250" height="250">
      <path d="M10 80 H 100 V 200 H 10" stroke="orange"  stroke-linecap="round"  stroke-width="10" fill="transparent"></path>
      <path d="M10 80 H 100 V 200 H 10" stroke="red" stroke-dasharray="320" stroke-dashoffset="0" stroke-linecap="round" stroke-width="10" fill="transparent">
          <animate attributeType="CSS" attributeName="stroke-dashoffset" from="320" to="0" dur="5s" repeatCount="indefinite"/> 
      </path>
</svg>

水流

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值