B
    ΦZ^                 @   sT   d Z ddlT ddlmZmZ G dd deZdd Ze	dkrPe Z
ee
 e  d	S )
a&        turtle-example-suite:

        tdemo_fractalCurves.py

This program draws two fractal-curve-designs:
(1) A hilbert curve (in a box)
(2) A combination of Koch-curves.

The CurvesTurtle class and the fractal-curve-
methods are taken from the PythonCard example
scripts for turtle-graphics.
    )*)sleepperf_counterc               @   s$   e Zd Zdd Zdd Zdd ZdS )CurvesTurtlec             C   s   |dkrd S |  |d  | ||d |  | | | |d  | ||d | | | | ||d | | |d  | | | ||d |  |  |d  d S )Nr   Z      )lefthilbertZforwardright)selfsizelevelZparity r   D/work/yifan.wang/lscsoft/opt/python37/lib/python3.7/fractalcurves.pyr	      s    


zCurvesTurtle.hilbertc             C   s   dd l }d| ||j|  }|   | | |   | dd|d  |   x,t|D ] }| ||| | d|  q^W | 	dd|d  |   |   | 
| |   d S )Nr         r   ih  )mathZsinZpipufdpdrtrangefractalltZbk)r   nZradZlevdirr   Zedgeir   r   r   
fractalgon/   s    

zCurvesTurtle.fractalgonc             C   s   |dk r|  | d S | |d |d | | d|  | |d |d | | d|  | |d |d | | d|  | |d |d | d S )Nr      <   x   )r   r   r   r   )r   Zdistdepthr   r   r   r   r   B   s    
zCurvesTurtle.fractalN)__name__
__module____qualname__r	   r   r   r   r   r   r   r      s   r   c              C   s  t  } |   | d |   |  dd |   d}| d| d|  |   t	 }| 
d |   | | | |dd | | x0tdD ]$}| d | |d	|d
    qW |   x$td
D ]}| | | d qW |   x2tdD ]&}| |d|d
    | d qW |   t	 }d||  }td |   | d |   |  dd t	 }| dd |   | dddd |   |   | d | dddd |   t	 }|d||  7 }|S )Nr   r      iiZredr   r   @   r      B   zHilbert: %.2fsec. ZblackZblue      zKoch: %.2fsec.)r   resetZspeedZhtZ	getscreenZtracerr   Zsetposr   clockZ	fillcolorZ
begin_fillr   r	   r   r   r   Zend_fillr   Zcolorr   )Zftr   tar   tbZresr   r   r   mainN   s\    







r0   __main__N)__doc__ZturtleZtimer   r   r-   ZPenr   r0   r"   msgprintZmainloopr   r   r   r   <module>   s   =9