圆的参数方程 x=a+r cosθ y=b+r sinθ (a,b)为圆心坐标 r为圆半径 θ为参数
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
-
<html xmlns="">
-
<head>
-
<title> new document </title>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<style>
-
span{position:absolute; color: red}
-
</style>
-
</head>
-
<body>
-
</body>
-
<script type="text/javascript">
-
//
-
var showCircle = function() {
-
var PI = Math.PI;
-
return {
-
draw: function(r/*半径*/, _x/*x轴偏移*/, _y/*y轴偏移*/) {
-
// 获得x y坐标
-
var x, y;
-
for(var i = 0; i < 360; i += 6) {
-
x = Math.cos(PI / 180 * i) * r + _x;
-
y = Math.sin(PI / 180 * i) * r + _y;
-
var O = document.createElement('span');
-
O.appendChild(document.createTextNode('.'));
-
document.body.appendChild(O);
-
O.style.left = x + 'px';
-
O.style.top = y + 'px';
-
}
-
}
-
}
-
}();
-
-
showCircle.draw(100, 400, 200);
-
//]]>
-
</script>
-
</html>
阅读(1458) | 评论(0) | 转发(0) |