矢量文本图形-SVG专题教程 动画(2)

Foreso 2003-10-16 05:13:17
源代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- Author : Blueknight,Hangzhou,China 2000 -->
<svg width="100" height="100">
<g transform="translate(50,0)">
<rect x="50" width="10" height="10" style="fill: red">
<animateTransform attributeName="transform" type="rotate"
from="0" to="180" dur="5s" repeatCount="indefinite"/>
</rect>
</g>
</svg>




讲解:

  <g transform="translate(50,0)"></g>用于圆周运动的中心点调整.<rect>绘制一个矩形,然后利用<animateTransform .../>标签完成圆周运动.其中的attributeName用于决定运动的属性,type决定运动的类型,from,to决定运动的起始角度(这里根据不同的运动类型,数值有不同的含义).dur用于决定运动的持续时间,repeatCount决定循环次数.
...全文
29 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Foreso 2003-10-16
  • 打赏
  • 举报
回复
6. 沿路径旋转运动



源代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- Author : Blueknight,Hangzhou,China 2000 -->
<svg width="100" height="100">
<rect x="-5" y="-5" width="10" height="10" style="fill: red">
<animateMotion path="M10 50 C10 0 90 0 90 90" rotate="auto"
dur="5s" repeatCount="indefinite"/>
</rect>
</svg>


讲解:

  这里比沿路径运动多了一个rotate属性.rotate决定对象在运动过程是否沿路径方向旋转.auto为沿路径方向(就是始终垂直路径),auto-reverse为沿路径方向旋转180.也可自定义一个角度,例如60.
路径),auto-reverse为沿路径方向旋转180.也可自定义一个角度,例如60.
Foreso 2003-10-16
  • 打赏
  • 举报
回复

5. 沿路径运动



源代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- Author : Blueknight,Hangzhou,China 2000 -->
<svg width="100" height="100">
<rect x="-5" y="-5" width="10" height="10" style="fill: red">
<animateMotion path="M10 50 C10 0 90 0 90 90" dur="5s"
repeatCount="indefinite"/>
</rect>
</svg>



讲解:

  因为是沿着路径运动,所以需要motion,使用<animateMotion.../>标签.path定义了路径.起点(10,50),终点(90,90).

3,423

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧