首页 > 其他 > 详细

SVG初尝试(二)

时间:2019-04-05 00:53:17      阅读:167      评论:0      收藏:0      [点我收藏+]

基本图形

rect(矩形)、circle、ellipse(椭圆)、line(直线)、polyline(折线)、polygon(多边形)、path(可以绘制任意图形)

rect

技术分享图片

x,y定义矩形坐标,矩形左上角的位置
rx、ry定义矩形的圆角,只给一个值,两者一致

circle

技术分享图片

cx、cy定义圆的坐标,圆心的位置
r定义圆的半径

ellipse

技术分享图片

line

技术分享图片

polyline

技术分享图片

polygon

技术分享图片

基本属性

fill(填充颜色)、stroke(描边颜色)、stroke-width(描边粗细)、transform

示例

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div>
      <svg width="700" height="500" xmlns="http://www.w3.org/2000/svg">
        <rect 
            x="10" 
            y="10" 
            rx="5" 
            ry="5" 
            width="150" 
            height="100" 
            stroke="red" 
            fill="none">
        </rect>
    
        <circle 
            cx="250" 
            cy="60" 
            r="50" 
            stroke="red" 
            fill="none">
        </circle>
    
        <ellipse 
            cx="400" 
            cy="60" 
            rx="70" 
            ry="50" 
            stroke="red" 
            fill="red">
        </ellipse>
    
        <line 
            x1="10" 
            y1="120" 
            x2="160" 
            y2="220" 
            stroke="red">
        </line>
    
        <polyline 
            points="250 120 
                    300 220
                    200 220"
            stroke="red"
            fill="none">
        </polyline>
    
        <polygon 
            points="250 120 
                    300 220
                    200 220"
            stroke="red"
            stroke-width="5"
            fill="yellow"
            transform="translate(150 0)">
        </polygon>
    </svg>
  </div>
</body>
</html>

技术分享图片

SVG初尝试(二)

原文:https://www.cnblogs.com/raind/p/10657660.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!