o
    JAfy                     @   s\   d Z ddlmZmZ ddlmZ dd Zdd Zdd	 Z	e
d
kr,e	 Zee e  dS dS )a        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.
    )Turtlemainloop)perf_counterc                 c   sx    |dkr8g }| D ]}| | | }|| || || || q	t||| ||D ]}dV  q2dS dS )z 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.   N)forwardZcloneleftrightappendtree)ZplistlafZlstpqx r   &/usr/lib/python3.10/turtledemo/tree.pyr
      s   



	r
   c                  C   st   t  } | d  |   | d |  dd | d |   | d | 	  t
| gddd}|D ]}q5d S )Nr      Z   i.   A   gffffff?)r   ZsetundobufferZ
hideturtleZspeedZ	getscreenZtracerr   Zpenupr   Zpendownr
   )r   tr   r   r   r   maketree'   s   



r   c                  C   s   t  } t  t  }d||   S )Nzdone: %.2f sec.)clockr   )r   br   r   r   main5   s   r   __main__N)__doc__Zturtler   r   timer   r   r
   r   r   __name__msgprintr   r   r   r   <module>   s   
