SVG图形编码_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:52:03
Original
1105 people have browsed it

svg:可以不改变质量的情况下缩放

  1. svg必须有包含
  2. 可以绘制不同的形状矩形:rect,圆形:circle,椭圆:ellipse,线:line,折线:polyline,多边形:polygon,路径:path
  3. 绘制不同的图形则应该使用不同的标签标记如圆形则使用circle
  4. 可以将svg保存为svg格式
  5. x,y表示起始坐标
  6. fill:填充的颜色,stroke:画的颜色,stroke-width:画的宽度(通俗来讲就是边框)
  7. 其实和css3的canvas差不多

矩形:rect

    

<svg>  <rect fill="red" height="100" id="rect" stroke="gray" stroke-width="10" width="100" x="20" y="20"></rect></svg>
Copy after login

圆角矩形:设置rx,ry(圆心的坐标)的值即可

<svg>  <circle id="circle"cx="100" cy="80" r="50" stroke="gray" stroke-width="10" fill="red">		</svg>
Copy after login

圆形:circle

circle:没有x,y的属性因为已经设置好了圆心cx,cy

<svg class="grid-50">  <rect fill="red" height="100" id="rect" stroke="gray" stroke-width="10" width="100" x="20" y="20"></rect></svg>
Copy after login

椭圆:ellipse

ellipse:椭圆其实就是矩形然后边框是圆角

<svg >  <ellipse  rx=100 ry=30 cx=150 cy=60 fill="yellow" stroke="gray" />	</svg> 
Copy after login

线段:line(两点确定一条直线)

<svg>  <line x1="0" y1="0" x2="200" y2="20" fill="gray" stroke="gray" stroke-width="2" /></svg>
Copy after login

折线:polyline(就是设置多个坐标点)

注意不能使用(0,0)是无效的

<svg>  <polyline points="0,0  0,20  20,20  20,40  40,40"  fill="white" stroke="gray" stroke-width="2" /></svg> 
Copy after login

多边形:polygon

当然更复杂的图形,只要知道各个点的坐标即可

<svg >  <polygon points="50,50 0,100 100,100 50,50" fill="blue" stroke="gray" stroke-width="1">	  </svg> 			
Copy after login

路径:path(上面所有的图形 都可以通过path来绘制)

下面的命令可用于路径数据:

  • 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 //椭圆
  • Z = closepath //结束路径
  • 注释:以上所有命令均允许小写字母。大写表示绝对定位,小写表示相对定位。

    必须按照规则书写

    <svg>  <path d="M50 50 L200 50 L200 0 L50 0 Z" fill="blue" stroke="gray" stroke-width="2" />	</svg>
    Copy after login

     

    demo: http://2.liteng.sinaapp.com/svg/index.html

    原文地址url: http://liteng.org/node/51

     

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!