
    e                        d Z ddlmZ ddlmZmZmZmZmZ  G d d      Z	 G d d      Z
 G d	 d
      Z G d d      Zy)z]
(Experimental) WCK-style drawing interface operations

.. seealso:: :py:mod:`PIL.ImageDraw`
    )annotations   )Image
ImageColor	ImageDraw	ImageFont	ImagePathc                      e Zd ZdZddZy)Penz"Stores an outline color and width.c                F    t        j                  |      | _        || _        y N)r   getrgbcolorwidth)selfr   r   opacitys       0/usr/lib/python3/dist-packages/PIL/ImageDraw2.py__init__zPen.__init__!   s    &&u-

    N)r      __name__
__module____qualname____doc__r    r   r   r   r      s
    ,r   r   c                      e Zd ZdZddZy)BrushzStores a fill colorc                8    t        j                  |      | _        y r   )r   r   r   )r   r   r   s      r   r   zBrush.__init__)   s    &&u-
r   N)r   r   r   r   r   r   r   &   s
    .r   r   c                      e Zd ZdZddZy)Fontz Stores a TrueType font and colorc                n    t        j                  |      | _        t        j                  ||      | _        y r   )r   r   r   r   truetypefont)r   r   filesizes       r   r   zFont.__init__0   s(    &&u-
&&tT2	r   N)   r   r   r   r   r!   r!   -   s
    *3r   r!   c                  h    e Zd ZdZddZd ZddZd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zy)Drawz4
    (Experimental) WCK-style drawing interface
    Nc                    t        |d      st        j                  |||      }t        j                  |      | _        || _        d | _        y )Nim)hasattrr   newr   r)   drawimage	transform)r   r/   r&   r   s       r   r   zDraw.__init__;   s<    ud#IIeT51ENN5)	
r   c                    | j                   S r   )r/   )r   s    r   flushz
Draw.flushB   s    zzr   c                "   d x}}d}t        |t              r|j                  }|j                  }n(t        |t              r|j                  }|j                  }t        |t              r|j                  }nt        |t              r|j                  }| j
                  r0t        j                  |      }|j                  | j
                         |dk(  r| j                  j                  |||       y  t        | j                  |      |||       y )Nr   line)fillr   )r5   outline)
isinstancer   r   r   r   r0   r	   Pathr.   r4   getattr)r   opxypenbrushr6   r5   r   s           r   renderzDraw.renderE   s    $c3iiGIIEs#kkGKKEeU#;;DU#99D>>#BLL(<IINN2G5N9"GDIIr"2D'Br   c                (    |\  }}dd|dd|f| _         y)zSets a transformation offset.r   r   N)r0   )r   offsetxoffsetyoffsets       r   settransformzDraw.settransform]   s     #'QAw7r   c                0     | j                   d|||g|  y)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optionss        r   rE   zDraw.arcb   s     	E2uc4G4r   c                0     | j                   d|||g|  y)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`
        chordNrF   rG   s        r   rL   z
Draw.chordk   s     	GR6g6r   c                ,     | j                   d|g|  y)z
        Draws an ellipse inside the given bounding box.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse`
        ellipseNrF   r   r;   rJ   s      r   rN   zDraw.ellipset   s     	Ir,G,r   c                ,     | j                   d|g|  y)z
        Draws a line between the coordinates in the ``xy`` list.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line`
        r4   NrF   rO   s      r   r4   z	Draw.line|   s     	FB))r   c                0     | j                   d|||g|  y)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`
        piesliceNrF   rG   s        r   rR   zDraw.pieslice   s     	JE399r   c                ,     | j                   d|g|  y)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`
        polygonNrF   rO   s      r   rT   zDraw.polygon   s     	Ir,G,r   c                ,     | j                   d|g|  y)zg
        Draws a rectangle.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
        	rectangleNrF   rO   s      r   rV   zDraw.rectangle   s     	K.g.r   c                    | j                   r0t        j                  |      }|j                  | j                          | j                  j	                  |||j
                  |j                         y)zw
        Draws the string at the given position.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
        )r$   r5   N)r0   r	   r8   r.   textr$   r   r   r;   rX   r$   s       r   rX   z	Draw.text   sI     >>#BLL(		r4diidjjAr   c                    | j                   r0t        j                  |      }|j                  | j                          | j                  j	                  |||j
                        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$   )r0   r	   r8   r.   textbboxr$   rY   s       r   r\   zDraw.textbbox   sI     >>#BLL(yy!!"d!;;r   c                P    | j                   j                  ||j                        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   rX   r$   s      r   r^   zDraw.textlength   s"     yy##Dtyy#99r   )NNr   )r   r   r   r   r   r2   r>   rC   rE   rL   rN   r4   rR   rT   rV   rX   r\   r^   r   r   r   r)   r)   6   sO    C08
57-*:-/	B<:r   r)   N)r   
__future__r    r   r   r   r   r	   r   r   r!   r)   r   r   r   <module>ra      s?   (
 # @ @ . .3 3K: K:r   