o
   duԕ                   @   s\   d Z ddlmZmZ ddlmZ G dd deZdd Ze	dkr,e Z
ee
 e  d	S d	S )
a        turtle-example-suite:

        tdemo_bytedesign.py

An example adapted from the example-suite
of PythonCard's turtle graphics.

It's based on an article in BYTE magazine
Problem Solving with Logo: Using Turtle
Graphics to Redraw a Design
November 1982, p. 118 - 134

-------------------------------------------

Due to the statement

t.delay(0)

in line 152, which sets the animation delay
to 0, this animation runs in "line per line"
mode as fast as possible.
    )Turtlemainloop)perf_counterc                   @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )Designerc                 C   s   |    tdD ]%}| d|  |   | |  | |    | d|  | d q|    | | | d | d|  | d |   | 	d| d| | 
 d	 d S )
N   g)P@H   $   g     8@   .   ga@T)uprangeforwarddownwheelpositionbackwardrightgotocenterpiece	getscreentracer)selfZhomePosscalei r   ;/app/.heroku/python/lib/python3.10/turtledemo/bytedesign.pydesign    s    


zDesigner.designc                 C   s   |  d tdD ]}| || q	|   | d tdD ]}| || q| d tdD ]}|   |  d | d|  |   | d|  q1| d | 	 
  d S )N6      r   r   r      )r   r   	pentpiecer   lefttripiecer   r   r   r   update)r   initposr   r   r   r   r   r   2   s    




zDesigner.wheelc                 C   s   |   }|   | d|  | d| | |   | | | | |   | d|  | d| | |   | | | | | d | 	 
  d S )Ng      @g     ?@r   )headingr   r   tripolyrr   r   
setheadingtripolylr!   r   r#   )r   r$   r   oldhr   r   r   r"   D   s   




zDesigner.tripiecec                 C   s   |   }|   | d|  |   tdD ]}| d|  | d q| d| d| |   | | | | | d|  |   tdD ]}| d|  | d qL| 	d| d| |   | | | | | 
d |    d S )N   r      r   K   )r%   r   r   r   r   r   pentrr   r'   pentlr!   r   r#   )r   r$   r   r)   r   r   r   r   r    U   s,   




zDesigner.pentpiecec                 C   >   |d| k rd S |  | | | | |d|  || d S N   gRQ?)r   r!   r.   r   sideZangr   r   r   r   r.   m      

zDesigner.pentlc                 C   r/   r0   )r   r   r-   r2   r   r   r   r-   s   r4   zDesigner.pentrc                 C   h   |d| k rd S |  | | d |  |d  | d |  |d  | d | |d | d S Nr   o   g{Gz?g?   g      ?)r   r   r&   r   r3   r   r   r   r   r&   y      



zDesigner.tripolyrc                 C   r5   r6   )r   r!   r(   r9   r   r   r   r(      r:   zDesigner.tripolylc                 C   s>   |  | | | |d| k rd S | |d|  || d S )Ng      @g333333?)r   r!   r   )r   sar   r   r   r   r      s   zDesigner.centerpieceN)__name__
__module____qualname__r   r   r"   r    r.   r-   r&   r(   r   r   r   r   r   r      s    

r   c                  C   s\   t  } | d |   |  d |  d t }| |  d t }d||  S )Nr   r1   zruntime: %.2f sec.)	r   ZspeedZ
hideturtler   delayr   clockr   r   )tZatetr   r   r   main   s   
rD   __main__N)__doc__Zturtler   r   timer   rA   r   rD   r=   msgprintr   r   r   r   <module>   s   u
