Making A Circle Out Of Squares

方形画圆

解决方案: 循环偏移5角度画方形

效果图:

Python 源码

import turtle;

window = turtle.Screen();
window.bgcolor("pink")

def draw_circle():

    square = turtle.Turtle();
    square.shape("turtle");
    square.color("blue");
    square.speed(-3);
    max_rot = 360;
    init_rot = 0;
    while(init_rot<=max_rot):
        square.right(init_rot);
        i=0
        while(i<4):
            # draw square
            square.forward(100)
            square.right(90)
            i+=1;
        init_rot +=5
    print("success");

draw_circle();
window.exitonclick();
posted @ 2016-11-08 17:08  zhoucx6  阅读(203)  评论(0编辑  收藏  举报