#1 基本概念和标签

2017-12-24  本文已影响8人  JamesSawyer

基本图形和属性

基本图形:

基本属性:

<rect>

包含属性:

#1 rect.jpg

示例

<svg>
    <rect x="10" y="10" width="100" height="50" fill="green" rx="10"></rect>
</svg>

<circle>

包含属性:

#2 circle.jpg

示例:

# 使用fill="transparent" 是因为svg会自动填充黑色
<svg>
    <circle cx="100" cy="100" r="30" stroke="red" stroke-width="10" fill="transparent"></circle>
</svg>

<ellipse>

椭圆,在圆的基础上多一个半径

包含属性:

#3 ellipse.jpg

示例:

<svg>
    <ellipse cx="60" cy="60" rx="50" ry="25" fill="pink"/>
</svg>

<line>

直线:

包含属性:

#4 line.jpg

示例:

<svg>
    <line x1="10" y1="10" x2="100" y2="100" stroke="blue"></line>
</svg>

<polyline>

折线,含有多个点,不会自动闭合第一个点

包含属性:

#5 polyline.jpg

示例:

<svg>
   <polyline points="10 10 20 0 40 40 80 10" stroke="red" stroke-width="2" fill="transparent"></polyline>
</svg>

// 或者使用逗号分割
<svg>
   <polyline points="10, 10, 20, 0, 40, 40, 80, 10" stroke="red" stroke-width="2" fill="transparent"></polyline>
</svg>

<polygon>

多边形和折线的唯一区别在于,多边形会把第一个点和最后一个点自动的闭合起来

包含属性:

#6 polygon.jpg

示例:

<svg>
   <polygon points="10 10 20 0 40 40 80 10" stroke="red" stroke-width="2" fill="transparent"></polygon>
</svg>

// 或者使用逗号分割
<svg>
   <polygon points="10, 10, 20, 0, 40, 40, 80, 10" stroke="red" stroke-width="2" fill="transparent" />
</svg>

本文来自学习笔记svg - 慕课网

上一篇 下一篇

猜你喜欢

热点阅读