svg

svg

svg: scalable vector graphics,可缩放的矢量图

  1. 该图片使用代码书写而成
  2. 缩放不会失真
  3. 内容轻量

怎么使用

svg可以嵌入浏览器,也可以单独成为一个文件

xml语言,svg使用该语言定义

    <style>
        img, embed, object, iframe{
            width: 100px;
            height: 100px;
        }
        p{
            width: 100px;
            height: 100px;
            background: url("imgs/weixin.svg") no-repeat center/cover;
        }
    </style>
</head>
<body>
    <img src="imgs/weixin.svg" alt="">
    <p></p>
    <embed src="imgs/weixin.svg" type="image/svg+xml">
    <object data="imgs/weixin.svg" type="image/svg+xml"></object>
    <iframe src="imgs/weixin.svg"></iframe>
</body>

书写svg代码

矩形:rect

<rect width="100" height="100" x="100" y="100" fill="red" stroke="#000" stroke-width="5" />

圆形:circle

<circle cx="200" cy="400" r="50" fill="transparent" stroke="#000" stroke-width="5"/>

椭圆:ellipse

<ellipse rx="80" ry="30" cx="200" cy="500" fill="red" stroke="#000" stroke-width="5" />

线条:line

<line x1="10" y1="10" x2="300" y2="30" stroke="#000" stroke-width="3" />

折线:polyline

<polyline points="300,100,350,100,350,150,400,150,400,200" fill="red" stroke="#000" stroke-width="3"/>

多边形:polygon

 <polygon points="300,300, 400, 400, 300, 500" fill="none" stroke="#000" stroke-width="3" /> -->

路径:path

<path d="M150 600 L300 600 L300 800 L150 800 Z" fill="red" style="stroke:#000; stroke-width:5" />

M = moveto
L = lineto
H = horizontal lineto
V = vertical lineto
C = curveto
S = smooth curveto
Q = quadratic Belzier curve
T = smooth quadratic Belzier curveto
A = elliptical Arc

A
半径1
半径2
顺时针旋转角度
小弧(0)或大弧(1)
顺时针(1)逆时针(0)

Z = closepath

例子

画太极图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值