javascript画圆

日期:2010-07-30    阅读:179   分类:Javascript

 //<![CDATA[
    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 += 3) {
                    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);
 //]]>

本页链接: http://www.scriptlover.com/static/669-javascript-圆

标签:

相关文章

网友评论

Leave a comment

 required

 required (Not published)

 required