Your IP : 3.145.92.96
U
e5d� � @ s� d Z ddlmZmZmZmZ ddlmZ ddlm Z
dd� Zdd� Zd d
� Z
dd
d�Zdd� Zdd� Zdd� Zdd� Zdd� Zedkr�e� e� dS )a4 turtlegraphics-example-suite:
tdemo_forest.py
Displays a 'forest' of 3 breadth-first-trees
similar to the one in tree.
For further remarks see tree.py
This example is a 'breadth-first'-rewrite of
a Logo program written by Erich Neuwirth. See
http://homepage.univie.ac.at/erich.neuwirth/
� )�Turtle� colormode�tracer�mainloop�� randrange)�perf_counterc C s t | | d �S )N� r )�n� r �)/usr/lib64/python3.8/turtledemo/forest.py� symRandom s r
c s � �fdd�| D �S )Nc s, g | ]$\}}|t � � |d t �� f�qS )g)\��(�?)r
)�.0�angle�
sizefactor�� angledist�sizedistr r �
<listcomp> s �
�zrandomize.<locals>.<listcomp>r )�
branchlistr r r r r � randomize s �r c C s2 t |�D ]$}| �t|�� | �d| | � qd S )Ng �?)�range�leftr
Zforward)�tZdistance�partsr �ir r r �randomfd s r �
� c c s� |dkr�g }g }t t| |��D ]�\} }
| �|| � | �ddd| td� dd| td� d� | �� t| |||� dV |
D ]<\}}| �|� |�| � � � |�t
|
||�� | �|� q�qt||| |d ||||�D ]
}
d V q�d S )Nr � � � � r )
�list�zipZpensizeZpencolorr
�pendownr r �appendZcloner �right�tree)Ztlist�size�levelZwidthfactorZbranchlistsr r ZlstZbrsr r r r �xr r r r( s, �
�r( c C sL t d� | �� | �d� | �� | �d� | �� | �||� | �� d S )Nr r �Z )r �resetZspeed�
hideturtler ZpenupZsetposr% )r r+ �yr r r �start7 s
r0 c C s2 |� � t|dd� t|gd| ddddgg�}|S )N� i0����P 皙�����?��- g�G�z�?)r ��������?�����g���Q��?�r. r0 r( �r* Zpenr r r r �doit1A s r; c C s0 |� � t|dd� t|gd| dddgg�}|S )Niy���i~����x r3 r4 r7 r9 r: r r r �doit2G s r= c C s2 |� � t|dd� t|gd| ddddgg�}|S )N� i�����d r3 )r5 gffffff�?)r g
ףp=
�?)r8 r6 r9 r: r r r �doit3M s r@ c C s� t � } | �� tdd� tdt dd��}tdt dd��}tdt dd��}t� }d}|||fD ]&}z|�� W q\ |d7 }Y q\X q\|dkrNq�qNtdd � t� }d
|| S )N�K r � r )Zundobuffersize� r � r zruntime: %.2f sec.)r Zhtr r; r= r@ �clock�__next__)�p�u�sr �aZdone�br r r �mainT s$
rL �__main__N)r r )�__doc__Zturtler r r r Zrandomr �timer rE r
r r r( r0 r; r= r@ rL �__name__r r r r �<module> s