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>
相关推荐
烤麻辣烫19 分钟前
黑马大事件学习-15(前端登录页面)
前端·css·vue.js·学习·html
询问QQ:48773927831 分钟前
Comsol光子晶体仿真:复现子刊论文的奇妙之旅
html
杨超越luckly1 小时前
HTML应用指南:利用GET请求获取全国新东方门店位置信息
前端·数据库·arcgis·html·门店数据
微风粼粼2 小时前
html对接阿里云百炼AI大模型
人工智能·阿里云·html
明朝百晓生3 小时前
强化学习[page14]【chapter7】Temporal-Difference Learning (TD learning)
前端·html
亿牛云爬虫专家3 小时前
当数据开始“感知页面”
javascript·html·爬虫代理·代理ip·playwright·页面渲染·dom结构
胡gh14 小时前
css的臂膀,前端动效的利器,还是布局的“隐形陷阱”?
前端·css·html
十一.36617 小时前
103-105 添加删除记录
前端·javascript·html
大怪v1 天前
【Virtual World 005】上帝之眼
前端·javascript·html
0思必得01 天前
[Web自动化] HTML元素及DOM元素
前端·python·自动化·html·web自动化