import turtle
class draw():
'''
定义一个可以画图的类
'''
def __init__(self):
self.colors = ['pink', 'yellow', 'blue', 'purple', 'magenta', 'cyan','red','indigo']
self.length = 200
def square(self, n):
'''
画n边形
:param n:
:return:
'''
angle1 = int(360 / n) + 1
for i in range(self.length):
i += 1
turtle.pencolor(self.colors[i % 4])
turtle.forward(i)
turtle.right(angle1)
def circle(self, n):
'''
画n个园交汇
:param n:
:return:
'''
angle1 = int(360 / n) + 1
for i in range(0,self.length,n):
i += n
for k in range(n):
turtle.pencolor(self.colors[k])
turtle.circle(i)
turtle.right(angle1)
def main():
turtle.speed(10)
start = draw()
start.square(4)
# start.circle(6)
turtle.exitonclick()