//功能:画实心圆
//参数:圆心坐标,半径,精确度,背景颜色
function SolidCircle(cx, cy, r, p, color) {
var s = 1 / (r / p);
for (var i = 0; i < Math.PI * 2; i += s) {
var div = document.createElement("div");
div.style.position = "absolute";
div.style.left = Math.sin(i) * r + cx + "px";
div.style.top = Math.cos(i) * r + cy + "px";
div.style.width = p + "px";
div.style.height = p + "px";
div.style.backgroundColor = color;
document.body.appendChild(div);
}
}
winWidth = document.body.clientWidth || document.documentElement.clientWidth
winHeight = document.body.clientHeight || document.documentElement.clientHeight
var centers = { centerW: winWidth / 2, centerH: winHeight / 2 };
console.log(centers)
SolidCircle(centers.centerW, centers.centerH, 300, 2, "#0a3a87");
网友评论