SVG动画效果
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
随着人工智能的不断发展,web这门技术也越来越重要,很多人都开启了学习web学习,本文就介绍了web SVG学习的基础内容。
一、SVG是什么?
SVG 意为可缩放矢量图形(Scalable Vector Graphics)。
SVG 使用 XML 格式定义图像。
二、使用步骤
1.画图形
①画线
代码如下(示例):
-
<svg width="500" height="500">
-
<line x1="0" y1="0" x2="100" y2="100" stroke="red"></line>
-
</svg>
②圆
-
<svg width="500" height="500">
-
<circle cx="300" cy="300" r="100" fill="red" fill-opacity="0.3"></circle>
-
<circle cx="300" cy="300" r="100" fill="red" stroke="green" stroke-width="10" fill-opacity="0.3"></circle>
-
</svg>
-
③折线
-
<svg width="500" height="500">
-
<polyline points="0,0,0,100,50,100" stroke="green" fill="none"></polyline>
-
</svg>
④多边形
-
<svg width="500" height="500">
-
<polygon points="200 0 200 100 300 100 500 0" stroke="green" fill="none"></polygon>
-
</svg>
2.动画效果
平移
代码如下(示例):
-
<svg width="800" height="800">
-
<circle cx="100" cy="100" r="5">
-
<animate repeatCount="indefinite" attributeName="r" attributeType="XML" from="0" to="100" dur="1" fill="freeze"></animate>
-
<animate repeatCount="indefinite" attributeName="fill" attributeType="XML" from="black" to="blue" dur="1" fill="freeze"></animate>
-
<animate repeatCount="indefinite" attributeName="cx" attributeType="XML" from="100" to="600" dur="1" fill="freeze"></animate>
-
<animate repeatCount="indefinite" attributeName="cx" attributeType="XML" begin="1" from="600" to="100" dur="1" fill="freeze"></animate>
-
</circle>
-
</svg>
摇摆
代码如下(示例):
-
<svg width="1000" height="800">
-
<rect width="500" height="500" fill="red">
-
<animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" from="0 500 500 " to="360 300 300" dur="1"></animateTransform>
-
</rect>
-
</svg>
animateTransform 可能会标红,但不要担心。可以出效果的
总结
努力学习
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgbgajb
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13