SVG 是 使用XML描述的矢量文件 ,使用 http://www.w3.org/2000/svg 这个链接来标识文件是 SVG 的命名空间,这个链接是一个标志而已,用来告诉打开文件的软件:这个文件是 SVG 文件,而不是把它当成 XML 文 件打开。
兼容性
IE 9+Chrome 33.0+Firefox 28.0+Safari 7.0+位图:基于颜色的描述,描述的是一张图片中每一个像素点的颜色,整体组合在一起就形成了位图
矢量图:基于数学的描述
属性:
x 坐标x
y 坐标y
width 定义宽高
height 定义宽高
rx 定义矩形的圆角
ry 定义矩形的圆角
<svg width="100" height="50" style="background: rgb(225, 238, 210)"> <rect x="10" y="10" width="70" height="30 rx="10 ry="10" fill="#999"/> </svg>属性
cx 圆心坐标
cy 圆心坐标
r 圆的半径
<svg style="background: rgb(225, 238, 210)"> <circle cx="60" cy="60" r="50" fill="#999" /> </svg>属性
cx 椭圆中心点坐标
cy 椭圆中心点坐标
rx 两个维度的半径
ry 两个维度的半径
<svg style="background: rgb(225, 238, 210)"> <ellipse cx="60" cy="40" rx="50" ry="30" fill="#999" /> </svg>属性,描述的两个点的坐标
x1 第一个点的坐标
y1 第一个点的坐标
x2 第二个点的坐标
y2 第二个点的坐标
<svg style="background: rgb(225, 238, 210)"> <line x1="10" y1="10" x2="100" y2="30" style="stroke:rgb(99,99,99);stroke-width:2" /> </svg>属性
points 包含所有点坐标(‘,’将 x,y 隔开)
<svg style="background: rgb(225, 238, 210)"> <polyline points="10,20 100,20 100,60 30,50" style="stroke:rgb(99,99,99);stroke-width:2;fill:none"/> </svg>属性
points 包含所有点坐标(‘,’将 x,y 隔开)
<svg style="background: rgb(225, 238, 210)"> <polygon points="50,30 150,30 150,60 80,60 60,80" style="stroke:rgb(99,99,99);stroke-width:2;fill:#999"/> </svg>document.createElementNS(ns, tagName)
element.appendChild(childElement)
element.setAttribute(name, value)
element.getAttribute(name)
