<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head><title>javascript画圆</title></head>
<body>
<div id="svg" style="width:200px;height:200px;"> </div>
<script type="text/javascript">
var cont;
var circle=new Function();
if (document.createElementNS) {
svgNS = "http://www.w3.org/2000/svg";
svg = document.createElementNS(svgNS, "svg");
SVG = (svg.x != null);
createSVGVML = function(o, antialias) {
cont = document.createElementNS(svgNS, "svg");
o.appendChild(cont);
svgAntialias = antialias;
}
circle = function(diam, color) {
var o = document.createElementNS(svgNS, "circle");
o.setAttribute("shape-rendering", false);
o.setAttribute("stroke-width", "2px");
o.setAttribute("stroke-color", color);
o.setAttribute("r", Math.round(diam / 2));
o.setAttribute("cx", (diam / 2+2)+"px");
o.setAttribute("cy", (diam / 2+2)+"px");
o.setAttribute("stroke", color);
o.setAttribute("fill", "none");
o.style.cursor = "pointer";
cont.appendChild(o);
}
}
else if(document.createStyleSheet){
createSVGVML = function(o, antialias) {
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
var style = document.createStyleSheet();
style.addRule('v//:*', "behavior: url(#default#VML);");
style.addRule('v//:*', "antialias: "+antialias+";");
cont = o;
}
circle = function (diam, filled) {
var o = document.createElement("v:oval");
o.style.position = "absolute";
o.style.cursor = "pointer";
o.strokeweight = 2;
o.filled = filled;
o.style.width = diam + "px";
o.style.height = diam + "px";
cont.appendChild(o);
try{
return o;
}finally{
o=null;
}
}
}
createSVGVML(document.getElementById("svg"));
circle(100,"#cccccc");
</script>
</body>
</html>
svg,vml 画圆
最新推荐文章于 2013-01-08 16:06:36 发布