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>
相关推荐
paid槮10 小时前
HTML5如何创建容器
前端·html·html5
拾光拾趣录12 小时前
HTML行内元素与块级元素
前端·css·html
精神小伙2号20 小时前
css position
前端·css·html
鲸落✗21 小时前
黑色风格音乐播放器网站模板(附完整源码)
前端·html·web
东华果汁哥21 小时前
【URL 转换为PDF】HTML转换为PDF
前端·pdf·html
Tina学编程1 天前
HTML基础P1 | HTML基本元素
服务器·前端·html
山烛2 天前
小白学HTML,操作HTML网页篇(1)
运维·服务器·前端·python·html
GDAL2 天前
HTML 树结构(DOM)深入讲解教程
前端·html
蓝易云2 天前
精选HTML、JavaScript、ASP代码片段集锦
前端·后端·html
han_2 天前
CSS关键字:initial、revert、unset傻傻分不清
前端·css·html