svg
**1 由顏色值構(gòu)成耘眨,矢量圖,放大不失真境肾;
2 不是h5新標(biāo)簽剔难;
3 有屬性,可以添加事件奥喻;
4 性能一般
**
- line
<svg width='600' height='600'>
<line x1=' ' y1=' ' x2=' ' y2=' ' stroke='red' stroke-width=' '></line>
</svg>
T糠伞!注意:svg繪制的圖形的標(biāo)簽都寫在svg標(biāo)簽里面衫嵌;
除了坐標(biāo)其他的屬性可以寫在css文件里面;
可以通過getStyle獲取樣式彻秆,通過getAttribute獲取屬性楔绞。
- 矩形
<rect width=' ' height=' ' x=' ' y=' ' fill=' ' fill-opacity=' '></rect>
- 圓形
<circle cx=' ' cy=' ' r=' '></circle>
- 橢圓
<ellipse rx=' ' ry=' ' cx=' ' cy=' '></ellipse>
- 路徑
<path d='M100 100 L200 250 L300 100...Z' stroke-lineCap=' ' stroke-lineJoin=' '></path>
!唇兑!注意:路徑里面的M相當(dāng)于canvas里面的moveTo()酒朵,L相當(dāng)于lineTo(),Z相當(dāng)于closePath().
- 文字
<text x=' ' y=' '>here is text</text>
- 創(chuàng)建svg標(biāo)簽
document.createElementNS('http://www.w3.org/2000/svg', '標(biāo)簽名')
T健蔫耽!注意:和普通創(chuàng)建元素不同,要寫空間名和要?jiǎng)?chuàng)建的標(biāo)簽名字留夜;
空間名固定匙铡,標(biāo)簽名為:line/circle/ellipse/path/rect等