
    g                        d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
 ddl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)BinaryIO   )Image
ImageColor	ImageDraw	ImageFont	ImagePath)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       C/var/www/openai/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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        |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   r0   drawimage	transform)r   r6   r,   r   msgs        r   r   zDraw.__init__@   sR     eS!|V o%IIeT51ENN5)	
r   c                    | j                   S r   )r6   )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
                  r0t        j                  |      }|j                  | j
                         |dk(  r| j                  j                  |||       y  t        | j                  |      |||       y )Nr   line)fillr   )r=   outline)r2   r   r   r   r$   r7   r
   Pathr5   r<   getattr)r   opxypenbrushr>   r=   r   s           r   renderzDraw.renderR   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)r7   )r   offsetxoffsetyoffsets       r   settransformzDraw.settransformj   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rE   r   rB   startendoptionss        r   rL   zDraw.arco   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`
        chordNrM   rN   s        r   rS   z
Draw.chordx   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`
        ellipseNrM   r   rB   rQ   s      r   rU   zDraw.ellipse   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`
        r<   NrM   rV   s      r   r<   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`
        piesliceNrM   rN   s        r   rY   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`
        polygonNrM   rV   s      r   r[   zDraw.polygon   s     	Ir,G,r   c                ,     | j                   d|g|  y)zg
        Draws a rectangle.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
        	rectangleNrM   rV   s      r   r]   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*   r=   N)r7   r
   r?   r5   textr*   r   r   rB   r_   r*   s       r   r_   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*   )r7   r
   r?   r5   textbboxr*   r`   s       r   rc   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`
        rb   )r5   
textlengthr*   )r   r_   r*   s      r   re   zDraw.textlength   s"     yy##Dtyy#99r   )NN)r6   zImage.Image | strr,   z"tuple[int, int] | list[int] | Noner   z&float | tuple[float, ...] | str | Noner   r   )r   zImage.Imager   )r   r   r    r!   r   r:   rE   rJ   rL   rS   rU   r<   rY   r[   r]   r_   rc   re   r"   r   r   r0   r0   ;   s}     488<	  1 6	
 
C08
57-*:-/	B<:r   r0   N)r!   
__future__r   typingr    r   r   r   r	   r
   _typingr   r   r$   r'   r0   r"   r   r   <module>rj      sE   (
 #  @ @ # . .3 3S: S:r   