U
    Evf                     @  sh   d Z ddlm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`
    )annotations   )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-ciywl2yd/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 r   )r   r   r   )r   r   r   r   r   r   r   )   s    zBrush.__init__N)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 r   )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   -   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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 r   )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   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   r1   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`
        chordNr2   r3   r   r   r   r7   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`
        ellipseNr2   r   r-   r6   r   r   r   r8   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&   Nr2   r9   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`
        piesliceNr2   r3   r   r   r   r:      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`
        polygonNr2   r9   r   r   r   r;      s    zDraw.polygonc                 G  s   | j d|f|  dS )zg
        Draws a rectangle.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
        	rectangleNr2   r9   r   r   r   r<      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-   r=   r   r   r   r   r=      s    
z	Draw.textc                 C  s0   | j rt|}| | j  | jj|||jdS )z
        Returns bounding box (in pixels) of given text.

        :return: ``(left, top, right, bottom)`` bounding box

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textbbox`
        r   )r$   r   r*   r"   textbboxr   r>   r   r   r   r@      s    
zDraw.textbboxc                 C  s   | j j||jdS )z
        Returns length (in pixels) of given text.
        This is the amount by which following text should be offset.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.textlength`
        r?   )r"   
textlengthr   )r   r=   r   r   r   r   rA      s    zDraw.textlength)NN)N)r   r   r   r   r   r%   r.   r0   r1   r7   r8   r&   r:   r;   r<   r=   r@   rA   r   r   r   r   r   6   s   

			r   N)r   
__future__r    r   r   r   r   r   r	   r   r   r   r   r   r   r   <module>   s   	