svg 动画

html 复制代码
<!DOCTYPE html>
<html>
<head>
    <title>SVG SMIL Animate with Path</title>
</head>
<body>

<!--动画属性-->
<h1>PATH </h1>
<svg width="300px" height="100px">
	<path d="M 100 100 L 300 100 L 100 300 z"
	fill="red" stroke="blue" stroke-width="20"   rx="30" ry="30"/>
</svg>



<!--动画属性-->
<h1>动画属性</h1>
<svg width="300px" height="100px">
    <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1"/>
    <circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
        <animate attributeName="cx" from="0" to="100" dur="5s" repeatCount="indefinite"/>
    </circle>
</svg>


<!--旋转动画-->
<h1>旋转动画</h1>
<svg width="300px" height="100px">
    <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" rx="30" ry="30"/>
    <rect x="0" y="50" width="15" height="34" fill="blue" stroke="black" stroke-width="1" transform="rotation">
        <!-- Rotate from 0 to 360 degrees, and move from 60 to 100 in the x direction. -->
        <!-- Keep doing this until the drawing no longer exists. -->
        <animateTransform
                attributeName="transform"
                begin="0s"
                dur="20s"
                type="rotate"
                from="0 60 60"
                to="360 100 60"
                repeatCount="indefinite"
        />
    </rect>
</svg>

<h1>路径动画</h1>
<!--线性运动-->
<h2>1.线性运动</h2>
<svg xmlns="http://www.w3.org/2000/svg" width="300px" height="100px">
    <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1"/>
    <circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
        <animateMotion path="M 0 0 H 300 Z" dur="3s" repeatCount="indefinite"/>
    </circle>
</svg>
<!--曲线运动-->
<h2>2.曲线运动</h2>
<svg width="300px" height="100px">
    <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1"/>
    <rect x="0" y="0" width="20" height="20" fill="blue" stroke="black" stroke-width="1">
        <animateMotion path="M 250,80 H 50 Q 30,80 30,50 Q 30,20 50,20 H 250 Q 280,20,280,50 Q 280,80,250,80Z"
                       dur="3s" repeatCount="indefinite" rotate="auto"/>
    </rect>
</svg>


<div>
    <br/>
    <a href="https://developer.mozilla.org/zh-CN/docs/Web/SVG/SVG_animation_with_SMIL">参考MDN开发文档SVG_animation_with_SMIL</a>
</div>

</body>
</html>
相关推荐
老虎06276 小时前
JavaWeb(苍穹外卖)--学习笔记04(前端:HTML,CSS,JavaScript)
前端·javascript·css·笔记·学习·html
三水气象台7 小时前
用户中心Vue3网页开发(1.0版)
javascript·css·vue.js·typescript·前端框架·html·anti-design-vue
祝余呀12 小时前
HTML初学者第三天
前端·html
zhanshuo19 小时前
不依赖框架,如何用 JS 实现一个完整的前端路由系统
前端·javascript·html
火柴盒zhang19 小时前
websheet在线电子表格(spreadsheet)在集团型企业财务报表中的应用
前端·html·报表·合并·spreadsheet·websheet·集团财务
孤水寒月1 天前
基于HTML的悬窗可拖动记事本
前端·css·html
祝余呀1 天前
html初学者第一天
前端·html
Eiceblue1 天前
使用 C# 发送电子邮件(支持普通文本、HTML 和附件)
开发语言·c#·html·visual studio
超级土豆粉1 天前
Turndown.js: 优雅地将 HTML 转换为 Markdown
开发语言·javascript·html
忧郁的蛋~1 天前
HTML表格导出为Excel文件的实现方案
前端·html·excel