plist is list of pens l is length of branch a is half of the angle between 2 branches f is factor by which branch is shortened from level to level.
(plist, l, a, f)
| 16 | from time import perf_counter as clock |
| 17 | |
| 18 | def tree(plist, l, a, f): |
| 19 | """ plist is list of pens |
| 20 | l is length of branch |
| 21 | a is half of the angle between 2 branches |
| 22 | f is factor by which branch is shortened |
| 23 | from level to level.""" |
| 24 | if l > 3: |
| 25 | lst = [] |
| 26 | for p in plist: |
| 27 | p.forward(l) |
| 28 | q = p.clone() |
| 29 | p.left(a) |
| 30 | q.right(a) |
| 31 | lst.append(p) |
| 32 | lst.append(q) |
| 33 | for x in tree(lst, l*f, a, f): |
| 34 | yield None |
| 35 | |
| 36 | def maketree(): |
| 37 | p = Turtle() |