B
    ñ¶I`›  ã               @   s\   d Z ddlmZmZmZmZmZ G dd„ dƒZG dd„ dƒZG dd„ dƒZ	G d	d
„ d
ƒZ
dS )z]
(Experimental) WCK-style drawing interface operations

.. seealso:: :py:mod:`PIL.ImageDraw`
é   )ÚImageÚ
ImageColorÚ	ImageDrawÚ	ImageFontÚ	ImagePathc               @   s   e Zd ZdZddd„ZdS )ÚPenz"Stores an outline color and width.r   éÿ   c             C   s   t  |¡| _|| _d S )N)r   ÚgetrgbÚcolorÚwidth)Úselfr
   r   Úopacity© r   ú2/tmp/pip-unpacked-wheel-wndzrte2/PIL/ImageDraw2.pyÚ__init__!   s    zPen.__init__N)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s   r   c               @   s   e Zd ZdZddd„ZdS )ÚBrushzStores a fill colorr   c             C   s   t  |¡| _d S )N)r   r	   r
   )r   r
   r   r   r   r   r   )   s    zBrush.__init__N)r   )r   r   r   r   r   r   r   r   r   r   &   s   r   c               @   s   e Zd ZdZddd„ZdS )ÚFontz Stores a TrueType font and coloré   c             C   s   t  |¡| _t ||¡| _d S )N)r   r	   r
   r   ZtruetypeÚfont)r   r
   ÚfileÚsizer   r   r   r   0   s    zFont.__init__N)r   )r   r   r   r   r   r   r   r   r   r   -   s   r   c               @   s|   e Zd ZdZddd„Zdd„ Zd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d„ Zdd„ ZdS )ÚDrawz4
    (Experimental) WCK-style drawing interface
    Nc             C   s4   t |dƒst |||¡}t |¡| _|| _d | _d S )NZim)Úhasattrr   Únewr   r   ÚdrawÚimageÚ	transform)r   r   r   r
   r   r   r   r   ;   s
    
zDraw.__init__c             C   s   | j S )N)r   )r   r   r   r   ÚflushB   s    z
Draw.flushc             C   s®   d  }}d}t |tƒr$|j}|j}nt |tƒr:|j}|j}t |tƒrL|j}nt |tƒr\|j}| jrxt |¡}| | j¡ |dkr”| jj	|||d� nt
| j|ƒ|||d� d S )Nr   Úline)Úfillr   )r#   Úoutline)Ú
isinstancer   r
   r   r   r    r   ÚPathr   r"   Úgetattr)r   ÚopÚxyZpenZbrushr$   r#   r   r   r   r   ÚrenderE   s$    




zDraw.renderc             C   s   |\}}dd|dd|f| _ dS )zSets a transformation offset.r   é    N)r    )r   ÚoffsetZxoffsetZyoffsetr   r   r   Úsettransform]   s    zDraw.settransformc             G   s   | j d|||f|žŽ  dS )zÄ
        Draws an arc (a portion of a circle outline) between the start and end
        angles, inside the given bounding box.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.arc`
        ÚarcN)r*   )r   r)   ÚstartÚendÚoptionsr   r   r   r.   b   s    zDraw.arcc             G   s   | j d|||f|žŽ  dS )z·
        Same as :py:meth:`~PIL.ImageDraw2.Draw.arc`, but connects the end points
        with a straight line.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.chord`
        ÚchordN)r*   )r   r)   r/   r0   r1   r   r   r   r2   k   s    z
Draw.chordc             G   s   | j d|f|žŽ  dS )z‚
        Draws an ellipse inside the given bounding box.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse`
        ÚellipseN)r*   )r   r)   r1   r   r   r   r3   t   s    zDraw.ellipsec             G   s   | j d|f|žŽ  dS )zˆ
        Draws a line between the coordinates in the ``xy`` list.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line`
        r"   N)r*   )r   r)   r1   r   r   r   r"   |   s    z	Draw.linec             G   s   | j d|||f|žŽ  dS )zÁ
        Same as arc, but also draws straight lines between the end points and the
        center of the bounding box.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.pieslice`
        ÚpiesliceN)r*   )r   r)   r/   r0   r1   r   r   r   r4   „   s    zDraw.pieslicec             G   s   | j d|f|žŽ  dS )a  
        Draws a polygon.

        The polygon outline consists of straight lines between the given
        coordinates, plus a straight line between the last and the first
        coordinate.


        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.polygon`
        ÚpolygonN)r*   )r   r)   r1   r   r   r   r5   �   s    zDraw.polygonc             G   s   | j d|f|žŽ  dS )zg
        Draws a rectangle.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
        Ú	rectangleN)r*   )r   r)   r1   r   r   r   r6   š   s    zDraw.rectanglec             C   s8   | j rt |¡}|  | j ¡ | jj|||j|jd� dS )zw
        Draws the string at the given position.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
        )r   r#   N)r    r   r&   r   Útextr   r
   )r   r)   r7   r   r   r   r   r7   ¢   s    
z	Draw.textc             C   s   | j j||jd�S )zƒ
        Return the size of the given string, in pixels.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textsize`
        )r   )r   Útextsizer   )r   r7   r   r   r   r   r8   ­   s    zDraw.textsize)NN)N)r   r   r   r   r   r!   r*   r-   r.   r2   r3   r"   r4   r5   r6   r7   r8   r   r   r   r   r   6   s   

			r   N)r   Ú r   r   r   r   r   r   r   r   r   r   r   r   r   Ú<module>   s
   	