X7ROOT File Manager
Current Path:
/usr/lib64/python3.8/turtledemo
usr
/
lib64
/
python3.8
/
turtledemo
/
ðŸ“
..
📄
__init__.py
(314 B)
📄
__main__.py
(13.91 KB)
ðŸ“
__pycache__
📄
bytedesign.py
(4.15 KB)
📄
chaos.py
(951 B)
📄
clock.py
(3.13 KB)
📄
colormixer.py
(1.31 KB)
📄
forest.py
(2.9 KB)
📄
fractalcurves.py
(3.39 KB)
📄
lindenmayer.py
(2.38 KB)
📄
minimal_hanoi.py
(2 KB)
📄
nim.py
(6.36 KB)
📄
paint.py
(1.26 KB)
📄
peace.py
(1.04 KB)
📄
penrose.py
(3.3 KB)
📄
planet_and_moon.py
(2.76 KB)
📄
rosette.py
(1.33 KB)
📄
round_dance.py
(1.76 KB)
📄
sorting_animate.py
(4.91 KB)
📄
tree.py
(1.37 KB)
📄
turtle.cfg
(160 B)
📄
two_canvases.py
(1.09 KB)
📄
yinyang.py
(820 B)
Editing: tree.py
#! /usr/bin/python3.8 """ turtle-example-suite: tdemo_tree.py Displays a 'breadth-first-tree' - in contrast to the classical Logo tree drawing programs, which use a depth-first-algorithm. Uses: (1) a tree-generator, where the drawing is quasi the side-effect, whereas the generator always yields None. (2) Turtle-cloning: At each branching point the current pen is cloned. So in the end there are 1024 turtles. """ from turtle import Turtle, mainloop from time import perf_counter as clock def tree(plist, l, a, f): """ 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.""" if l > 3: lst = [] for p in plist: p.forward(l) q = p.clone() p.left(a) q.right(a) lst.append(p) lst.append(q) for x in tree(lst, l*f, a, f): yield None def maketree(): p = Turtle() p.setundobuffer(None) p.hideturtle() p.speed(0) p.getscreen().tracer(30,0) p.left(90) p.penup() p.forward(-210) p.pendown() t = tree([p], 200, 65, 0.6375) for x in t: pass def main(): a=clock() maketree() b=clock() return "done: %.2f sec." % (b-a) if __name__ == "__main__": msg = main() print(msg) mainloop()
Upload File
Create Folder