| """ turtle-example-suite: |
| Displays a 'breadth-first-tree' - in contrast |
| to the classical Logo tree drawing programs, |
| which use a depth-first-algorithm. |
| (1) a tree-generator, where the drawing is |
| quasi the side-effect, whereas the generator |
| (2) Turtle-cloning: At each branching point the |
| current pen is cloned. So in the end there |
| from turtle import Turtle, mainloop |
| def tree(plist, l, a, f): |
| """ plist is list of pens |
| a is half of the angle between 2 branches |
| f is factor by which branch is shortened |
| for x in tree(lst, l*f, a, f): |
| t = tree([p], 200, 65, 0.6375) |
| print len(p.getscreen().turtles()) |
| return "done: %.2f sec." % (b-a) |
| if __name__ == "__main__": |