
    :h;                        d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
mZmZ ddl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)AnyAnyStrBinaryIO   )Image
ImageColor	ImageDraw	ImageFont	ImagePath)CoordsStrOrBytesPathc                      e Zd ZdZdddZy)Penz"Stores an outline color and width.c                F    t        j                  |      | _        || _        y N)r	   getrgbcolorwidth)selfr   r   opacitys       L/var/www/urcfiles/bundle/venv/lib/python3.12/site-packages/PIL/ImageDraw2.py__init__zPen.__init__$   s    &&u-

    N)r      )r   strr   intr   r   returnNone__name__
__module____qualname____doc__r    r   r   r   r   !   s
    ,r   r   c                      e Zd ZdZd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   r    r%   r   r   r'   r'   )   s
    .r   r'   c                  *    e Zd ZdZ	 d	 	 	 	 	 	 	 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__3   s*      &&u-
&&tT2	r   N)   )r   r   r.   zStrOrBytesPath | BinaryIOr/   floatr   r   r    r%   r   r   r*   r*   0   s1    * JL33 93AF3	3r   r*   c                     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y)Drawz4
    (Experimental) WCK-style drawing interface
    Nc                    t        |t              r&|d}t        |      t        j                  |||      }t        j                  |      | _        || _        d | _	        y )Nz>If image argument is mode string, size must be a list or tuple)

isinstancer   
ValueErrorr   newr
   r3   drawimage	transform)r   r9   r/   r   msgs        r   r   zDraw.__init__@   sR     eS!|V o%IIeT51ENN5)	
QUr   c                    | j                   S r   )r9   )r   s    r   flushz
Draw.flushO   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
                  r2t        j                  |      }	|	j                  | j
                         |	}|dv r|j                  d|       n$|j                  d|       |j                  d|       |dk(  r|j                  d|        t        | j                  |      |fi | y )Nr   )arclinefilloutliner@   r   )r5   r   r   r   r'   r:   r   Path
setdefaultgetattrr8   )
r   opxypenbrushkwargsrB   rA   r   paths
             r   renderzDraw.renderR   s    $c3iiGIIEs#kkGKKEeU#;;DU#99D>>>>"%DNN4>>*B fg.fd+i1<gu-		2r,V,r   c                (    |\  }}dd|dd|f| _         y)zSets a transformation offset.r   r   N)r:   )r   offsetxoffsetyoffsets       r   settransformzDraw.settransformv   s     #'QAw7r   c                6     | j                   d||g|||d 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`
        r?   startendNrL   r   rG   rH   rT   rU   optionss         r   r?   zDraw.arc{   s"     	E2sCWCEsCr   c                6     | j                   d||g|||d 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`
        chordrS   NrV   rW   s         r   rZ   z
Draw.chord   s"     	GREwEeEr   c                .     | j                   d||g|  y)z
        Draws an ellipse inside the given bounding box.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse`
        ellipseNrV   r   rG   rH   rX   s       r   r\   zDraw.ellipse   s     	Ir311r   c                .     | j                   d||g|  y)z
        Draws a line between the coordinates in the ``xy`` list.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line`
        r@   NrV   r]   s       r   r@   z	Draw.line   s     	FB.g.r   c                6     | j                   d||g|||d 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`
        pieslicerS   NrV   rW   s         r   r`   zDraw.pieslice   s"     	JCH'HCHr   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`
        polygonNrV   r]   s       r   rb   zDraw.polygon   s     	Ir311r   c                .     | j                   d||g|  y)zg
        Draws a rectangle.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
        	rectangleNrV   r]   s       r   rd   zDraw.rectangle   s     	KS373r   c                    | j                   r2t        j                  |      }|j                  | j                          |}| j                  j	                  |||j
                  |j                         y)zw
        Draws the string at the given position.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
        )r-   rA   N)r:   r   rC   r8   textr-   r   r   rG   rf   r-   rK   s        r   rf   z	Draw.text   sN     >>>>"%DNN4>>*B		r4diidjjAr   c                    | j                   r2t        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-   )r:   r   rC   r8   textbboxr-   rg   s        r   rj   zDraw.textbbox   sN     >>>>"%DNN4>>*B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`
        ri   )r8   
textlengthr-   )r   rf   r-   s      r   rl   zDraw.textlength   s"     yy##Dtyy#99r   )NN)r9   zImage.Image | strr/   z"tuple[int, int] | list[int] | Noner   z&float | tuple[float, ...] | str | Noner   r   )r   zImage.Imager   )rF   r   rG   r   rH   Pen | Brush | NonerI   zBrush | Pen | NonerJ   r   r   r   )rN   tuple[float, float]r   r   )rG   r   rH   rm   rT   r1   rU   r1   rX   r   r   r   )rG   r   rH   rm   rX   r   r   r   )rG   rn   rf   r   r-   r*   r   r   )rG   rn   rf   r   r-   r*   r   z!tuple[float, float, float, float])rf   r   r-   r*   r   r1   )r!   r"   r#   r$   r   r=   rL   rQ   r?   rZ   r\   r@   r`   rb   rd   rf   rj   rl   r%   r   r   r3   r3   ;   s    488<	V V 1V 6	V
 
V %)"-"- "-  	"-
 ""- "- 
"-H8
DD  D 	D
 D D 
D FF  F 	F
 F F 
F 2/II  I 	I
 I I 
I 24
B<%<-3<;?<	*< :r   r3   N)r$   
__future__r   typingr   r   r    r   r	   r
   r   r   _typingr   r   r   r'   r*   r3   r%   r   r   <module>rs      sH   (
 # ( ( @ @ + . .3 3x: x:r   