87,989
社区成员
发帖
与我相关
我的任务
分享
//功能:画实心圆
//参数:圆心坐标,半径,精确度,背景颜色
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);
}
}
SolidCircle(450, 200, 200, 5, "green");