
     f                        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dS )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dS )Penz"Stores an outline color and width.r      colorstrwidthintopacityreturnNonec                F    t          j        |          | _        || _        d S N)r   getrgbr   r   )selfr   r   r   s       Q/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/PIL/ImageDraw2.py__init__zPen.__init__$   s    &u--



    N)r   r   )r   r   r   r   r   r   r   r   __name__
__module____qualname____doc__r    r   r   r   r   !   s3        ,,      r   r   c                      e Zd ZdZddd	Zd
S )BrushzStores a fill colorr   r   r   r   r   r   r   c                8    t          j        |          | _        d S 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$   )   s3        . . . . . . .r   r$   c                      e Zd ZdZ	 dddZdS )Fontz Stores a TrueType font and color   r   r   fileStrOrBytesPath | BinaryIOsizefloatr   r   c                l    t          j        |          | _        t          j        ||          | _        d S r   )r   r   r   r	   truetypefont)r   r   r)   r+   s       r   r   zFont.__init__3   s.      &u--
&tT22			r   N)r(   )r   r   r)   r*   r+   r,   r   r   r   r"   r   r   r'   r'   0   s:        ** JL3 3 3 3 3 3 3r   r'   c                  r    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dS )Drawz4
    (Experimental) WCK-style drawing interface
    NimageImage.Image | strr+   "tuple[int, int] | list[int] | Noner   &float | tuple[float, ...] | str | Noner   r   c                    t          |t                    r)|d}t          |          t          j        |||          }t          j        |          | _        || _        d | _	        d S )Nz>If image argument is mode string, size must be a list or tuple)

isinstancer   
ValueErrorr   newr   r1   drawr2   	transform)r   r2   r+   r   msgs        r   r   zDraw.__init__@   sb     eS!! 	2|V oo%IeT511EN5))	
r   Image.Imagec                    | j         S r   )r2   )r   s    r   flushz
Draw.flushO   s
    z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        r.t          j        |          }|                    | j                   |dk    r| j        	                    |||           d S  t          | j        |          |||           d S )Nr   line)fillr   )rB   outline)r7   r   r   r   r$   r;   r
   Pathr:   rA   getattr)r   opxypenbrushrC   rB   r   s           r   renderzDraw.renderR   s   $c3 	 iGIEEs## 	 kGKEeU## 	;DDU## 	9D> 	)##BLL(((<<INN2G5N99999"GDIr""2D'BBBBBBr   c                *    |\  }}dd|dd|f| _         dS )zSets a transformation offset.r   r   N)r;   )r   offsetxoffsetyoffsets       r   settransformzDraw.settransformj   s$    #'QAw7r   c                (     | j         d|||g|R   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rJ   r   rG   startendoptionss        r   rQ   zDraw.arco   s*     	E2uc4G444444r   c                (     | j         d|||g|R   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`
        chordNrR   rS   s        r   rX   z
Draw.chordx   s*     	GR6g666666r   c                $     | j         d|g|R   dS )z
        Draws an ellipse inside the given bounding box.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.ellipse`
        ellipseNrR   r   rG   rV   s      r   rZ   zDraw.ellipse   s&     	Ir,G,,,,,,r   c                $     | j         d|g|R   dS )z
        Draws a line between the coordinates in the ``xy`` list.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.line`
        rA   NrR   r[   s      r   rA   z	Draw.line   s&     	FB)))))))r   c                (     | j         d|||g|R   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`
        piesliceNrR   rS   s        r   r^   zDraw.pieslice   s*     	JE39999999r   c                $     | j         d|g|R   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`
        polygonNrR   r[   s      r   r`   zDraw.polygon   s&     	Ir,G,,,,,,r   c                $     | j         d|g|R   dS )zg
        Draws a rectangle.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.rectangle`
        	rectangleNrR   r[   s      r   rb   zDraw.rectangle   s&     	K.g......r   c                    | j         r.t          j        |          }|                     | j                    | j                            |||j        |j                   dS )zw
        Draws the string at the given position.

        .. seealso:: :py:meth:`PIL.ImageDraw.ImageDraw.text`
        )r/   rB   N)r;   r
   rD   r:   textr/   r   r   rG   rd   r/   s       r   rd   z	Draw.text   sW     > 	)##BLL(((	r4didjAAAAAr   c                    | j         r.t          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
   rD   r:   textbboxr/   re   s       r   rh   zDraw.textbbox   sP     > 	)##BLL(((y!!"d!;;;r   c                D    | 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`
        rg   )r:   
textlengthr/   )r   rd   r/   s      r   rj   zDraw.textlength   s!     y##Dty#999r   )NN)r2   r3   r+   r4   r   r5   r   r   )r   r=   r   )r   r   r    r!   r   r?   rJ   rO   rQ   rX   rZ   rA   r^   r`   rb   rd   rh   rj   r"   r   r   r1   r1   ;   s         488<	       C C C C08 8 8
5 5 57 7 7- - -* * *: : :- - -/ / /	B 	B 	B< < <: : : : :r   r1   N)r!   
__future__r   typingr    r   r   r   r	   r
   _typingr   r   r$   r'   r1   r"   r   r   <module>ro      s%  ( 
 # " " " " "       @ @ @ @ @ @ @ @ @ @ @ @ @ @ # # # # # #       . . . . . . . .3 3 3 3 3 3 3 3S: S: S: S: S: S: S: S: S: S:r   