SVG SMIL 动画(基本动画 、变换动画)
一、简介
动画标签:
<animate>、<animateTransform>、<animateMotion> ...
动画元素、属性定位以及动画参数设置:
attributeName
、attributeType
from
、to
、dur
、repeatCount
、fill
…calcMode
…
二、使用方式
定位动画目标
Internal Resource Identifier
定位,指定需要生效动画的标签
。<animate xlink:href="url(#rect1)"></animate>
包含在目标元素内,
对包含的父元素生效动画
。<rect x="0" ...><animate></animate> </rect>
设置要进行动画的属性以及变化范围、时间长度
<animate xlink:href="url(#rect1)"attributeType="XML"attributeName="x"from="0" to="100"dur="2s"repeatCount="1"> </animate>
三、基本动画
animate
支持叠加动画,也就是同一个标签支持添加多个animate
动画标签。效果
代码
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>html,body {margin: 0;padding: 0;background-color: #001122;/* 全屏 */width: 100%;height: 100%;/* 清空字号,免得影响 svg */line-height: 0;font-size: 0;}</style> </head> <body><!-- animateattributeType: 标签类型attributeName: 需要支持动画的属性begin: 动画开始时机from: 开始值to: 结束值dur: 动画时间fill: freeze(停留在最后)、none(默认,回到起点)repeatCount: 动画次数,indefinite(无限次),默认 1--><!-- svg --><svg width="100%" height="100%"><!-- 1 平移动画 --><rect x="50" y="10" width="40" height="40" fill="red"><!-- 动画 --><animate attributeType="XML"attributeName="x"from="50" to="200"dur="1s"repeatCount="indefinite"/><!-- 颜色变化 --><animate attributeType="XML"attributeName="fill"from="red" to="yellow"dur="1s"repeatCount="indefinite"/></rect><!-- 2 平移动画 - 往返 --><rect x="50" y="80" width="40" height="40" fill="red"><!-- 动画 --><animate id="goright1" attributeType="XML"attributeName="x"begin="0; goleft1.end"from="50" to="200"dur="1s"fill="freeze"/><animate id="goleft1" attributeType="XML"attributeName="x"begin="goright1.end"from="200" to="50"dur="1s"fill="freeze"/><!-- 颜色变化 --><animate attributeType="XML"attributeName="fill"from="red" to="yellow"dur="1s"repeatCount="indefinite"/></rect><!-- 3 平移动画 - 往返 - 暂停 --><rect x="200" y="150" width="40" height="40" fill="red"><!-- 动画 --><animate id="goleft2" attributeType="XML"attributeName="x"begin="0; goright2.end + 1s"from="200" to="50"dur="1s"fill="freeze"/><animate id="goright2" attributeType="XML"attributeName="x"begin="goleft2.end + 1s"from="50" to="200"dur="1s"fill="freeze"/><!-- 颜色变化 --><animate attributeType="XML"attributeName="fill"from="red" to="yellow"dur="1s"repeatCount="indefinite"/></rect></svg> </body> </html>
四、变换动画
animateTransform
支持叠加动画,也就是同一个标签不能添加多个animateTransform
动画标签。效果
代码
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>html,body {margin: 0;padding: 0;background-color: #001122;/* 全屏 */width: 100%;height: 100%;/* 清空字号,免得影响 svg */line-height: 0;font-size: 0;}</style> </head> <body><!-- animateTransformattributeType: 标签类型attributeName: 需要支持动画的属性type: 子属性begin: 动画开始时机from: 开始值to: 结束值dur: 动画时间fill: freeze(停留在最后)、none(默认,回到起点)repeatCount: 动画次数,indefinite(无限次),默认 1--><!-- svg --><svg width="100%" height="100%" viewBox="-400 -400 800 800"><!-- 1 原地旋转 --><rect x="0" y="0" width="40" height="40" fill="red"><!-- 动画 --><animateTransform attributeType="XML"attributeName="transform"type="rotate"from="0"to="360"dur="3s"repeatCount="indefinite"></rect><!-- 1 原地旋转 - 缩放 - 不支持多个动画叠加 --><rect x="0" y="80" width="40" height="40" fill="red"><!-- 动画 --><!-- <animateTransform attributeType="XML"attributeName="transform"type="rotate"from="0"to="360"dur="3s"repeatCount="indefinite"> --><animateTransform attributeType="XML"attributeName="transform"type="scale"from="1"to="2"dur="3s"repeatCount="indefinite"></rect></svg> </body> </html>
五、轨迹 Path 动画(animateMotion)
六、Scripting Animation(脚本动画)
七、参考文档
参考资料
http://www.w3.org/TR/SVG/animate.html
http://www.zhangxinxu.com/wordpress/?p=4333
SVG SMIL 动画(基本动画 、变换动画)相关推荐
- SVG SMIL animation动画详解
一.SVG SMIL animation概览 1. SMIL是什么? SMIL不是指「水蜜梨」,而是Synchronized Multimedia Integration Language(同步多媒体 ...
- 超级强大的SVG SMIL animation动画详解
超级强大的SVG SMIL animation动画详解 本文摘自超级强大的SVG SMIL animation动画详解_Zoomla!逐浪CMS官网 (z01.com),网站看上去有年头了,担心哪天会 ...
- [转]超级强大的SVG SMIL animation动画详解
超级强大的SVG SMIL animation动画详解 本文花费精力惊人,具有先驱前瞻性,转载规则以及申明见文末,当心予以追究. 本文地址:http://www.zhangxinxu.com/word ...
- SVG SMIL animation动画详解----转载
一.SVG SMIL animation概览 1. SMIL是什么? SMIL不是指「水蜜梨」,而是Synchronized Multimedia Integration Language(同步多媒体 ...
- html2d动画,HTML5之SVG 2D入门11—用户交互性(动画)介绍及应用
交互性 SVG拥有良好的用户交互性,例如: 1. SVG能响应大部分的DOM2事件. 2. SVG能通过cursor良好的捕捉用户鼠标的移动. 3. 用户可以很方便的通过设置svg元素的zoomAnd ...
- html文字自动上翻,jQuery超酷文字随机翻转变换动画特效
Flapper是一款效果非常酷的文字随机翻转变换动画jQuery特效.它的效果类似于机场或车站显示航班或车次的文字变换效果,每个文字都随机变换几次,然后才显示某个设定好的文字. 该文字特效可以显示文字 ...
- Flex的动画效果与变换(1)
Flex的动画效果与变换!(一) 在Flex里面不像在Flash里面随意制作动画了,Flex更趋向于应用程序,而不是动画制作了,所以没有了时间轴的概念.在Flex中使用动画效果,可以用Flex自带的E ...
- css 右上角 翻开动画_CSS3 transition动画、transform变换、animation动画
一.CSS3 transition动画 transition可以实现动态效果,实际上是一定时间之内,一组css属性变换到另一组属性的动画展示过程. 属性参数: 1.transition-propert ...
- Flutter Hero 实现径向变换动画 — 圆形变成矩形的转场动画
系列文章 Flutter 旋转动画 - RotationTransition Flutter 平移动画 - 4种实现方式 Flutter 淡入淡出与逐渐出现动画 Flutter 尺寸缩放.形状.颜色. ...
最新文章
- cmd文件内容添加到文件内容命令
- elasticsearch 路由文档到分片
- VS2013安装OpenCV4.1版本并搭建一个小程序
- Sequelize 中文文档 v4 - Querying - 查询
- 网络编程套接字API
- rocketmq 初探(四)
- Java_Date_01_判断两个时间相差的天数
- 字符串——垂直柱状图(洛谷 P1598)
- 外卖红包小程序0基础搭建附教程+源码
- [经验教程]iPhone苹果手机iOS系统App Store怎么下载手机APP到苹果iPhone手机?
- Python 下载百度文库
- iOS打包静态库(完整篇)
- ROMS海洋模式笔记
- mysql允许连接表为空_mysql – 选择一个表中的所有项并与另一个表连接,允许空值...
- 两直线平行交叉相乘_高中数学知识点:向量平行公式和垂直公式
- 我的世界java边境之地_我的世界边境之地是否存在 我的世界边境之地大揭秘
- Mac-修改MySQL密码
- Android Paging3的使用
- 【计算机基础】计算机网络
- 用python制作生日蛋糕图片大全_Python 制作微信全家福,你就是朋友圈最亮的仔!...
热门文章
- 性能监控与服务器监控
- 计算机设备驱动的作用,驱动程序是什么意思,电脑驱动程序有什么作用!
- 大连市计算机软件产业,大连市软件产业高技能型人才培养与市场需求拟合度研究.doc...
- hbase集群的搭建(完全分布式)
- Android实战(四)——正能量日报
- Java Back Propagation Neural Network(JAVA反向传播神经网络)
- 新东方老师谈如何学英语
- python自动化运维:python环境的安装
- 构造函数c语言引用,c – 定义的构造函数的“未定义引用”
- 3500字归纳总结:一名合格的软件测试工程师需要掌握的技能大全