关键词搜索

源码搜索 ×
×

Web笔记-html中svg的基本使用

发布2020-11-17浏览1208次

详情内容

程序运行截图如下:

代码如下:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6. <svg width="https://cdn.jxasp.com:9143/image/200" height="https://cdn.jxasp.com:9143/image/200">
  7. <rect x="0" y="0" width="100" height="100" fill="red"></rect>
  8. <line x1="100" y1="0" x2="https://cdn.jxasp.com:9143/image/200" y2="100" stroke="green" stroke-width="1"></line>
  9. <polygon points="0,100 0,200 100,200" fill="red"></polygon>
  10. <circle cx="150" cy="150" r="50" stroke-width="1" stroke="green" fill="red"></circle>
  11. </svg>
  12. </body>
  13. </html>

svg是矢量绘图,和canvas一样是一个标签。

 

浏览器中只有Dom元素才能被选中。

 

svg是通过svg标签来绘图。

canvas通过JavaScript API来绘图。

 

canvas绘制的图是不能被选中的。

svg是可以被选中的,每一个元素都是个dom。

 

Svg不管放多大,都可以保持在可升缩的范围内。而canvas放大就锯齿了(可以对其进行抗锯齿)。

 

Canvas适合做动画。

Svg适合做展示相关的。

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载