Back to index

python3.2  3.2.2
Functions | Variables
turtledemo.wikipedia Namespace Reference

Functions

def mn_eck
def main

Variables

tuple msg = main()

Detailed Description

turtle-example-suite:

          tdemo_wikipedia3.py

This example is
inspired by the Wikipedia article on turtle
graphics. (See example wikipedia1 for URLs)

First we create (ne-1) (i.e. 35 in this
example) copies of our first turtle p.
Then we let them perform their steps in
parallel.

Followed by a complete undo().

Function Documentation

Definition at line 36 of file wikipedia.py.

00036 
00037 def main():
00038     s = Screen()
00039     s.bgcolor("black")
00040     p=Turtle()
00041     p.speed(0)
00042     p.hideturtle()
00043     p.pencolor("red")
00044     p.pensize(3)
00045 
00046     s.tracer(36,0)
00047 
00048     at = clock()
00049     mn_eck(p, 36, 19)
00050     et = clock()
00051     z1 = et-at
00052 
00053     sleep(1)
00054 
00055     at = clock()
00056     while any([t.undobufferentries() for t in s.turtles()]):
00057         for t in s.turtles():
00058             t.undo()
00059     et = clock()
00060     return "runtime: %.3f sec" % (z1+et-at)
00061 

Here is the call graph for this function:

def turtledemo.wikipedia.mn_eck (   p,
  ne,
  sz 
)

Definition at line 19 of file wikipedia.py.

00019 
00020 def mn_eck(p, ne,sz):
00021     turtlelist = [p]
00022     #create ne-1 additional turtles
00023     for i in range(1,ne):
00024         q = p.clone()
00025         q.rt(360.0/ne)
00026         turtlelist.append(q)
00027         p = q
00028     for i in range(ne):
00029         c = abs(ne/2.0-i)/(ne*.7)
00030         # let those ne turtles make a step
00031         # in parallel:
00032         for t in turtlelist:
00033             t.rt(360./ne)
00034             t.pencolor(1-c,0,c)
00035             t.fd(sz)

Here is the caller graph for this function:


Variable Documentation

Definition at line 63 of file wikipedia.py.