o
    JAf4                     @   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rge Ze  d%S 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   )/usr/lib/python3.10/turtledemo/penrose.pykite      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%   r   r   c                 C   s   |dkr#t  \}}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r#t  \}}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| r3t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   


r5   c                 C   $   t dD ]}t| | td qd S N   H   )ranger$   r   r   r'   ir   r   r   sunj      

r=   c                 C   r6   r7   )r:   r#   r   r;   r   r   r   staro   r>   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   rB   c                   C   s$   t   t  t  t  td d S )Nuser)resetZhtZpurB   Z
resizemoder   r   r   r   start   s
   rE         )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   rH   rI   r   r   r   rK      rL   z"%d kites and %d darts = %d pieces.)gotor1   r"   rA   r5   lenprint)r   r'   funstartposr3   ZnkZndr   r   r   test   s   
rR   c                 C   sL   t   tdD ]}t }td||  t }|| }|dk r#td|  qd S )N   i,  r   )rE   r:   clockrR   r   )rP   r<   abtr   r   r   demo   s   rX   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  rS   )F   u   )rQ   ZDone)
modeZbgcolorrX   r=   r   r?   ZpencolorrM   writerR   r   r   r   r   main   s   
r^   __main__N)r   )__doc__Zturtlemathr   r   timer   rT   r   r   r%   r   r   r$   r#   r5   r=   r?   rB   rE   rR   rX   r^   __name__msgZmainloopr   r   r   r   <module>   s,   


