Mention Giampolo R's new FTP TLS support in the what's new file
[python.git] / Demo / turtle / tdemo_wikipedia.py
blob89e69950375cf6bd6f696d5984ba1268a431d9b4
1 """ turtle-example-suite:
3 tdemo_wikipedia3.py
5 This example is
6 inspired by the Wikipedia article on turtle
7 graphics. (See example wikipedia1 for URLs)
9 First we create (ne-1) (i.e. 35 in this
10 example) copies of our first turtle p.
11 Then we let them perform their steps in
12 parallel.
14 Followed by a complete undo().
15 """
16 from turtle import Screen, Turtle, mainloop
17 from time import clock, sleep
19 def mn_eck(p, ne,sz):
20 turtlelist = [p]
21 #create ne-1 additional turtles
22 for i in range(1,ne):
23 q = p.clone()
24 q.rt(360.0/ne)
25 turtlelist.append(q)
26 p = q
27 for i in range(ne):
28 c = abs(ne/2.0-i)/(ne*.7)
29 # let those ne turtles make a step
30 # in parallel:
31 for t in turtlelist:
32 t.rt(360./ne)
33 t.pencolor(1-c,0,c)
34 t.fd(sz)
36 def main():
37 s = Screen()
38 s.bgcolor("black")
39 p=Turtle()
40 p.speed(0)
41 p.hideturtle()
42 p.pencolor("red")
43 p.pensize(3)
45 s.tracer(36,0)
47 at = clock()
48 mn_eck(p, 36, 19)
49 et = clock()
50 z1 = et-at
52 sleep(1)
54 at = clock()
55 while any([t.undobufferentries() for t in s.turtles()]):
56 for t in s.turtles():
57 t.undo()
58 et = clock()
59 return "Laufzeit: %.3f sec" % (z1+et-at)
62 if __name__ == '__main__':
63 msg = main()
64 print msg
65 mainloop()