SVG中的动画技术(2)

本文通过一个SVG动画实例展示了如何使用animateMotion元素实现一个圆形沿指定路径移动的效果。此例中定义了一个从左到右的贝塞尔曲线,并让圆形沿此路径进行无限循环运动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://blog.youkuaiyun.com/net_lover/archive/2002/01/25/6889.aspx

下面再看一个沿指定路径运动的例子:

xml 代码
  1. xml version="1.0" encoding="UTF-8" standalone="no"?>  
  2. "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">  
  3. <svg width="500" height="300" viewBox="0 0 500 300"  
  4. xmlns="http://www.w3.org/2000/svg">  
  5. <desc>沿路径运动的例子desc>  
  6. <defs>  
  7.   
  8. <linearGradient id="grad1" x1="0" y1="0" x2="0" y2="100%" gradientUnits="userSpace">  
  9. <stop offset="0%" style="stop-color: #88f;"/>  
  10. <stop offset="100%" style="stop-color: #008;"/>  
  11. linearGradient>  
  12. defs>  
  13. <rect x="1" y="1" width="498" height="298"  
  14. fill="none" stroke="blue" stroke-width="2" />  
  15.   
  16.   
  17. <path d="M100,250 C 100,50 400,50 400,250"  
  18. fill="none" stroke="blue" stroke-width="8" />  
  19.   
  20.   
  21. <circle r="25" style="fill:url(#grad1)">  
  22.   
  23. <animateMotion dur="6s" repeatCount="indefinite"  
  24. path="M100,250 C 100,50 400,50 400,250" rotate="auto" />  
  25. circle>  
  26. <text x="145" y="285" style="font-size:12pt">http://lucky.myrice.comtext>  
  27. svg>  
  28.   

 上面的例子应用了animateMotion动画元素,其属性设定和前面类似。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值