Making A Circle Out Of Squares

时间:2023-03-09 19:22:54
Making A Circle Out Of Squares

方形画圆

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

效果图:

Making A Circle Out Of Squares

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();