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

互联网 | 编辑: 2006-03-22 00:00:00转载
源代码:
<?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决定循环次数.
源代码:
<?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).
源代码:
<?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).

每日精选

点击查看更多

首页 手机 数码相机 笔记本 游戏 DIY硬件 硬件外设 办公中心 数字家电 平板电脑