a
    If4                     @   s   d Z ddlT ddlmZmZ ddlmZmZ dZ	dede d  Z
d	d
 Zdd Zdd Zdd Zd&ddZdd Zdd Zdd Zdd ZddeddfddZefd d!Zd"d# Zed$kre Ze  d%S )'a         xturtle-example-suite:

          xtx_kites_and_darts.py

Constructs two aperiodic penrose-tilings,
consisting of kites and darts, by the method
of inflation in six steps.

Starting points are the patterns "sun"
consisting of five kites and "star"
consisting of five darts.

For more information see:
 http://en.wikipedia.org/wiki/Penrose_tiling
 -------------------------------------------
    )*)cospi)perf_countersleepgP/7?      
   c                 C   sT   t |  }td t|  td t| td t| td t|  td d S )N$   l      fltfdrtlfl r   #lib/python3.9/turtledemo/penrose.pykite   s    r   c                 C   sT   t |  }td t|  td t| td t| td t|  td d S )Nr
   r   r   r   r   r   r   dart%   s    r   c                 C   s   |dkrFt  \}}tt t|dt|d  }}}dt|||f< d S t|  }td t||d  t|  t	d t
||d  td t| t  t	d t
||d  td t|  t	d	 t||d  td d S )
Nr   r   Tr
      r            )posintheadingroundtiledictr   r   inflatedartr   r   inflatekitedr   nZpxpyhxyr   r   r   r   r#   1   s(    
"r#   c                 C   s   |dkrFt  \}}tt t|dt|d  }}}dt|||f< d S t|  }t||d  td t|  t	d t
||d  td t| t  t	d t
||d  t|  t	d	 d S )
Nr   r   Fr   r
   r   6   ~   r   )r   r   r   r    r!   r   r#   r   r   r   r"   r$   r%   r   r   r   r"   G   s"    
"r"   c                 C   s   t   | t|  } t| d | d | tD ]T}|\}}}t|| t| t| rftd tdd ntd tdd t  q*d S )Ng      Y@r   black)r         ?r   r   )r.   r   r   )	clearr   Z	shapesizer!   Zsetpos
setheadingshapeZcolorZstamp)r   r&   thkr(   r)   r*   r   r   r   drawZ   s    


r4   c                 C   s$   t dD ]}t| | td qd S N   H   )ranger#   r   r   r&   ir   r   r   sunj   s    
r;   c                 C   s$   t dD ]}t| | td qd S r5   )r8   r"   r   r9   r   r   r   staro   s    
r<   c                   C   sT   t d t  td t  tdt  t  td t  tdt  t d d S )Nr   d   r   r   r   )tracerZ
begin_polyr   Zend_polyZregister_shapeZget_polyr   r   r   r   r   
makeshapest   s    r?   c                   C   s$   t   t  t  t  td d S )Nuser)resetZhtZpur?   Z
resizemoder   r   r   r   start   s
    rB         )r   r   c                 C   sx   t | td i atd || | t| || td tdd tD }tdd tD }td|||| f  d S )Nr   r   c                 S   s   g | ]}t | r|qS r   r!   .0r)   r   r   r   
<listcomp>       ztest.<locals>.<listcomp>c                 S   s   g | ]}t | s|qS r   rE   rF   r   r   r   rH      rI   z"%d kites and %d darts = %d pieces.)gotor0   r!   r>   r4   lenprint)r   r&   funstartposr2   ZnkZndr   r   r   test   s    
rO   c                 C   sL   t   tdD ]8}t }td||  t }|| }|dk rtd|  qd S )N   i,  r   )rB   r8   clockrO   r   )rM   r:   abtr   r   r   demo   s    rU   c                   C   sj   t d tddd tt td tt td tdd tddd td	d
dd t	dddd dS )NZlogog333333?r   r   r-   i8gffffff?r   zPlease wait...center)zArial Blackr
   Zbold)ZalignZfontiX  rP   )F   u   )rN   ZDone)
modeZbgcolorrU   r;   r   r<   ZpencolorrJ   writerO   r   r   r   r   main   s    
r[   __main__N)r   )__doc__ZturtleZmathr   r   timer   rQ   r   r   r$   r   r   r#   r"   r4   r;   r<   r?   rB   rO   rU   r[   __name__msgZmainloopr   r   r   r   <module>   s(   

