svg dom绘制五角星
2013-12-30 20:37
447 查看
<!DOCTYPE
html>
<html>
<head>
<meta
charset="utf-8">
<title>svg
dom绘制五角星</title>
<style>
#mystar{
border: 1px solid red;
width: 100px;
height: 100px;
}
</style>
<script>
function
createStar(){
var
root=document.getElementByIdx_x_x("mystar");
var
SVG="http://www.w3.org/2000/svg";
//创建我们的svg元素
var
svg=document_createElement_x_xNS(SVG,"svg");
svg.setAttribute("width","100");
svg.setAttribute("height","100");
var
polygon=document_createElement_x_xNS(SVG,"polygon");
for(var
i=0;i<10;i+=2){
var
p=svg.createSVGPoint();
p.x=Math.sin(Math.PI*2/5*i)*50+50;
p.y=Math.cos(Math.PI*2/5*i)*50+50;
polygon.points.appendItem(p);
}
//指定颜色(边框与填充)
polygon.setAttribute("stroke","blue");
polygon.setAttribute("fill","none");
polygon.setAttribute("stroke-width","3px");
svg.a(polygon);
root.a(svg);
}
</script>
</head>
<body
onload="createStar()">
<h3>svg
dom绘制五角星</h3>
<div
id="mystar"></div>
</body>
</html>
相关文章推荐
- SVG DOM通过path绘制五角星
- SVG Dom绘制圆形
- SVG Dom绘制椭圆
- SVG Dom绘制线段
- svg dom绘制文本
- svg dom绘制折线
- svg dom沿路径绘制文本
- SVG Dom绘制矩形
- SVG Dom使用g元素
- SVG DOM方式实现g元素的变形
- OpenGL&nbsp;绘制字母&nbsp;计算机图形学
- C# 绘制曲线(一)
- HTML DOM Table 对象
- 【转载】python xml.dom模块…
- matlab ezplot3 绘制三维函数图
- org.w3c.dom(java&nbsp;dom)解析XML文档
- 一段代码(SAX, DOM, 或…
- html5&nbsp;canvas&nbsp;如何清空之前绘制的…
- matlab ezsurf函数 绘制三维表面图
- Photoshop CS4绘制一只逼真的金蛋