""" turtle-example-suite:tdemo_round_dance.py(Needs version 1.1 of the turtle module thatcomes with Python 3.1)Dancing turtles have a compound shapeconsisting of a series of triangles ofdecreasing size.Turtles march along a circle while rotatingpairwise in opposite direction, with oneexception. Does that breaking of symmetryenhance the attractiveness of the example?Press any key to stop the animation.Technically: demonstrates use of compoundshapes, transformation of shapes as well ascloning turtles. The animation iscontrolled through update()."""from turtle import *def stop():global runningrunning = Falsedef main():global runningclearscreen()bgcolor("gray10")tracer(False)shape("triangle")f = 0.793402phi = 9.064678s = 5c = 1# create compound shapesh = Shape("compound")for i in range(10):shapesize(s)p =get_shapepoly()s *= fc *= ftilt(-phi)sh.addcomponent(p, (c, 0.25, 1-c), "black")register_shape("multitri", sh)# create dancersshapesize(1)shape("multitri")pu()setpos(0, -200)dancers = []for i in range(180):fd(7)tilt(-4)lt(2)update()if i % 12 == 0:dancers.append(clone())home()# dancerunning = Trueonkeypress(stop)listen()cs = 1while running:ta = -4for dancer in dancers:dancer.fd(7)dancer.lt(2)dancer.tilt(ta)ta = -4 if ta > 0 else 2if cs < 180:right(4)shapesize(cs)cs *= 1.005update()return "DONE!"if __name__=='__main__':print(main())mainloop()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。