赞
踩
import turtle as tl
from math import sin
from math import pi
fill_color= {0:'purple', 1:'blueviolet'}
colors=["mediumslateblue","mediumpurple","indigo"]
R = 80
l1 = int(R*sin(pi/10)/sin(pi*126/180))
l2 = int(R*sin(pi/5)/sin(pi*126/180))
distanceList = [l1, l2, R]
angleList = [54, 162, 180]
myAngle= 0
myCounter = 0
counter = 0
def Tick():
global myCounter
global counter
global myAngle
tl.tracer(False)
oneDraw(myCounter,counter,myAngle)
tl.tracer(True)
myCounter = (myCounter + 1) % 3
counter = (counter + 1) % 10
myAngle=(myAngle+18)%360
tl.ontimer(Tick,100)
def oneDraw(counter,stepCounter,myAngle):
global distanceList, angleList
tl.reset()
for k in range(0,3):
tl.pencolor(colors[3-(k+1)])
for i in range(73):
tl.penup()
tl.home()
tl.left(myAngle)
tl.forward(200)
tl.right(myAngle)
tl.right(5*i)
tl.forward(R/2+k*R/4+counter*R/12)
tl.pendown()
tl.forward(R*sin((pi/2)*((i%5+1)/5))/10)
tl.penup()
tl.home()
tl.left(myAngle)
tl.forward(200)
tl.right(myAngle)
tl.right(stepCounter*36)
tl.left(126)
for i in range(10):
tl.fillcolor(fill_color.get(i%2))
tl.begin_fill()
for j in range(3):
tl.forward(distanceList[j])
tl.right(angleList[j])
tl.end_fill()
distanceList = list(reversed(distanceList))
angleList = list((angleList[1], angleList[0], angleList[2]))
def main():
Tick()
tl.mainloop()
main()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。