B
    ΦZ^                 @   sX   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rTe Z
ee
 e  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   |    xVtdD ]J}| d|  |   | |  | |    | d|  | d qW |    | | | 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   A/work/yifan.wang/lscsoft/opt/python37/lib/python3.7/bytedesign.pydesign    s     


zDesigner.designc             C   s   |  d xtdD ]}| || qW |   | d xtdD ]}| || qDW | d xFtdD ]:}|   |  d | d|  |   | d|  qlW | 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|  |   x(tdD ]}| d|  | d q0W | d| d| |   | | | | | d|  |   x(tdD ]}| d|  | d qW | 	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   s>   |d| k rd S |  | | | | |d|  || d S )N   gRQ?)r   r!   r.   )r   sideangr   r   r   r   r.   m   s
     

zDesigner.pentlc             C   s>   |d| k rd S |  | | | | |d|  || d S )Nr/   gRQ?)r   r   r-   )r   r0   r1   r   r   r   r   r-   s   s
     

zDesigner.pentrc             C   sh   |d| k rd S |  | | d |  |d  | d |  |d  | d | |d | d S )Nr   o   g{Gz?g?   g      ?)r   r   r&   )r   r0   r   r   r   r   r&   y   s     



zDesigner.tripolyrc             C   sh   |d| k rd S |  | | d |  |d  | d |  |d  | d | |d | d S )Nr   r2   g{Gz?g?r3   g      ?)r   r!   r(   )r   r0   r   r   r   r   r(      s     



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   r/   zruntime: %.2f sec.)	r   ZspeedZ
hideturtler   Zdelayr   clockr   r   )tZatetr   r   r   main   s    
r<   __main__N)__doc__Zturtler   r   Ztimer   r9   r   r<   r6   msgprintr   r   r   r   <module>   s   u