Back to index

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

Functions

def symRandom
def randomize
def randomfd
def tree
def start
def doit1
def doit2
def doit3
def main

Variables

tuple msg = main()

Function Documentation

def turtledemo.forest.doit1 (   level,
  pen 
)

Definition at line 65 of file forest.py.

00065 
00066 def doit1(level, pen):
00067     pen.hideturtle()
00068     start(pen, 20, -208)
00069     t = tree( [pen], 80, level, 0.1, [[ (45,0.69), (0,0.65), (-45,0.71) ]] )
00070     return t

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.forest.doit2 (   level,
  pen 
)

Definition at line 71 of file forest.py.

00071 
00072 def doit2(level, pen):
00073     pen.hideturtle()
00074     start(pen, -135, -130)
00075     t = tree( [pen], 120, level, 0.1, [[ (45,0.69), (-45,0.71) ]] )
00076     return t

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.forest.doit3 (   level,
  pen 
)

Definition at line 77 of file forest.py.

00077 
00078 def doit3(level, pen):
00079     pen.hideturtle()
00080     start(pen, 190, -90)
00081     t = tree( [pen], 100, level, 0.1, [[ (45,0.7), (0,0.72), (-45,0.65) ]] )
00082     return t
00083 
# Hier 3 Baumgeneratoren:

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 84 of file forest.py.

00084 
00085 def main():
00086     p = Turtle()
00087     p.ht()
00088     tracer(75,0)
00089     u = doit1(6, Turtle(undobuffersize=1))
00090     s = doit2(7, Turtle(undobuffersize=1))
00091     t = doit3(5, Turtle(undobuffersize=1))
00092     a = clock()
00093     while True:
00094         done = 0
00095         for b in u,s,t:
00096             try:
00097                 b.__next__()
00098             except:
00099                 done += 1
00100         if done == 3:
00101             break
00102 
00103     tracer(1,10)
00104     b = clock()
00105     return "runtime: %.2f sec." % (b-a)

Here is the call graph for this function:

def turtledemo.forest.randomfd (   t,
  distance,
  parts,
  angledist 
)

Definition at line 26 of file forest.py.

00026 
00027 def randomfd( t, distance, parts, angledist ):
00028     for i in range(parts):
00029         t.left(symRandom(angledist))
00030         t.forward( (1.0 * distance)/parts )

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.forest.randomize (   branchlist,
  angledist,
  sizedist 
)

Definition at line 21 of file forest.py.

00021 
00022 def randomize( branchlist, angledist, sizedist ):
00023     return [ (angle+symRandom(angledist),
00024               sizefactor*1.01**symRandom(sizedist))
00025                      for angle, sizefactor in branchlist ]

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.forest.start (   t,
  x,
  y 
)

Definition at line 55 of file forest.py.

00055 
00056 def start(t,x,y):
00057     colormode(255)
00058     t.reset()
00059     t.speed(0)
00060     t.hideturtle()
00061     t.left(90)
00062     t.penup()
00063     t.setpos(x,y)
00064     t.pendown()

Here is the caller graph for this function:

Definition at line 18 of file forest.py.

00018 
00019 def symRandom(n):
00020     return randrange(-n,n+1)

Here is the caller graph for this function:

def turtledemo.forest.tree (   tlist,
  size,
  level,
  widthfactor,
  branchlists,
  angledist = 10,
  sizedist = 5 
)

Definition at line 31 of file forest.py.

00031 
00032 def tree(tlist, size, level, widthfactor, branchlists, angledist=10, sizedist=5):
00033     # benutzt Liste von turtles und Liste von Zweiglisten,
00034     # fuer jede turtle eine!
00035     if level > 0:
00036         lst = []
00037         brs = []
00038         for t, branchlist in list(zip(tlist,branchlists)):
00039             t.pensize( size * widthfactor )
00040             t.pencolor( 255 - (180 - 11 * level + symRandom(15)),
00041                         180 - 11 * level + symRandom(15),
00042                         0 )
00043             t.pendown()
00044             randomfd(t, size, level, angledist )
00045             yield 1
00046             for angle, sizefactor in branchlist:
00047                 t.left(angle)
00048                 lst.append(t.clone())
00049                 brs.append(randomize(branchlist, angledist, sizedist))
00050                 t.right(angle)
00051         for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
00052                       angledist, sizedist):
00053             yield None
00054 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 107 of file forest.py.