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>
相关推荐
Rauser Mack5 小时前
不懂编程,但是vibe coding一个扫雷游戏
人工智能·python·游戏·html·prompt
放下华子我只抽RuiKe55 小时前
FastAPI 全栈后端(二):路由与数据模型
前端·人工智能·react.js·前端框架·html·fastapi
dotnet907 小时前
PDF 页面尺寸上限是 14400。iText 直接加载成功的大图可能超过这个限制,需要在 setPageSize 之前等比缩放。
前端·javascript·html
神明不懂浪漫9 小时前
【第二章】HTML2——表格、表单标签
开发语言·经验分享·笔记·html
雨翼轻尘9 小时前
01_HTML基本结构
前端·html·基本结构
木头羊oll9 小时前
Uniapp 与 H5 在 App 端的交互
前端·javascript·html
杨超越luckly9 小时前
Agent应用指南:利用GET请求获取赛力斯汽车门店位置信息
python·html·汽车·可视化·门店
杨超越luckly10 小时前
Agent应用指南:利用GET请求获取理想汽车门店位置信息
前端·python·html·汽车·可视化
卷帘依旧21 小时前
H5新特性
html
#麻辣小龙虾#1 天前
小学三年级语文小游戏
css·html·css3