Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/PIL/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/PIL/__pycache__/ImageDraw.cpython-312.pyc

�

&ٜg#����UddlmZddlZddlZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZdd	lmZd
ed<	ej.j0Ze	rddlmZmZe
eeed
fe fZ!	Gd�d�Z"ddd�Z#	d					dd�Z$		d											dd�Z%								dd�Z&						dd�Z'y#e$rdZY�dwxYw)�)�annotationsN)�Sequence)�
ModuleType)�
TYPE_CHECKING�Any�AnyStr�Callable�Union�cast�)�Image�
ImageColor)�	deprecate)�Coordsz(Callable[[], Image.core._Outline] | None�Outline)�
ImageDraw2�	ImageFont.c���eZdZUdZded<dd d�Z		d!d�Z				d"d�Z	d					d#d�Z		d$											d%d�Z		d							d&d	�Z
			d'													d(d
�Z			d'									d)d�Z			d'											d*d�Z
			d+									d,d
�Z		d-							d.d�Z			d'													d(d�Zdd/d�Z			d'									d)d�Z				d0													d1d�Z			d'									d)d�Z				d0dd�													d2d�Zd3d�Zd4d�Z								d5d�Z											d6																															d7d�Z											d6dd�																													d8d�Z					d9dd�															d:d�Z									d;dd�																									d<d�Z									d;dd�																									d<d�Zy)=�	ImageDrawN�NImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | None�fontc��|j�|jr|j�d}|�|j}||jk7r$|dk(r|jdk(rd}n
d}t	|��|dk(r|j
|_nd|_||_|j|_tjj|j|�|_
||_|dvr!|jjd�|_n |jjd	�|_|d
vrd|_
d
|_yd|_
d
|_y)a�
        Create a drawing instance.

        :param im: The image to draw in.
        :param mode: Optional mode to use for color values.  For RGB
           images, this argument can be RGB or RGBA (to blend the
           drawing into the image).  For all other modes, this argument
           must be the same as the image mode.  If omitted, the mode
           defaults to the mode of the image.
        rN�RGBA�RGBrz
mode mismatch�P)�I�F���)�1rrrr�LF)�load�readonly�_copy�mode�
ValueError�palette�_image�imr
�core�draw�draw_ink�ink�fontmode�fill)�selfr(r$�blend�msgs     �8/usr/local/lib/python3.12/site-packages/PIL/ImageDraw.py�__init__zImageDraw.__init__Es
��	���	�
�;�;��H�H�J����<��7�7�D��2�7�7�?��v�~�"�'�'�U�"2���%�� ��o�%��3�;��:�:�D�L��D�L�����%�%����J�J�O�O�D�G�G�U�3��	���	��:���y�y�)�)�!�,�D�H��y�y�)�)�"�-�D�H��'�'��D�M���	� �D�M���	�c�j�|jsddlm}|j�|_|jS)a=
        Get the current default font.

        To set the default font for this ImageDraw instance::

            from PIL import ImageDraw, ImageFont
            draw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")

        To set the default font for all future ImageDraw instances::

            from PIL import ImageDraw, ImageFont
            ImageDraw.ImageDraw.font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")

        If the current default font is ``None``,
        it is initialized with ``ImageFont.load_default()``.

        :returns: An image font.r�r)r�r�load_default)r/rs  r2�getfontzImageDraw.getfontos*��(�y�y�#�.�	�.�.�0�D�I��y�y�r4c�V�|�ddlm}|j|�S|j�S)Nrr6)r7rr8r9)r/�	font_sizers   r2�_getfontzImageDraw._getfont�s,��� �#�)�9�)�)�)�4�4��<�<�>�!r4c��d}d}|�.|�,|jr|j}||fS|j}||fS|��t|t�r t	j
||j�}|jr6t|t�r&|jj||j�}|jj|�}|��t|t�r t	j
||j�}|jr6t|t�r&|jj||j�}|jj|�}||fS�N)r.r,�
isinstance�strr�getcolorr$r&�tupler'r*r+)r/r,r.�
result_ink�result_fills     r2�_getinkzImageDraw._getink�s ���
����;�4�<��y�y�"�h�h�� �;�&�&�"�X�X�
��;�&�&����c�3�'�$�-�-�c�4�9�9�=�C��<�<�J�s�E�$:��,�,�/�/��T�[�[�A�C�!�Y�Y�/�/��4�
����d�C�(�%�.�.�t�T�Y�Y�?�D��<�<�J�t�U�$;��<�<�0�0��t�{�{�C�D�"�i�i�0�0��6���;�&�&r4c�p�|j|�\}}|� |jj|||||�yy)zDraw an arc.N)rEr*�draw_arc)r/�xy�start�endr.�widthr,s       r2�arcz
ImageDraw.arc�s:���L�L��&�	��T��?��I�I���r�5�#�s�E�:�r4c��|j�|j|�\}}|�|}|�(|jj||j|�yy)zDraw a bitmap.N)r!rEr*�draw_bitmapr()r/rH�bitmapr.r,s     r2rOzImageDraw.bitmap�sM��	���
��L�L��&�	��T��;��C��?��I�I�!�!�"�f�i�i��5�r4c���|j||�\}}|�|jj||||d�|�-||k7r'|dk7r!|jj||||d|�yyyy)z
Draw a chord.Nrr)rEr*�
draw_chord�	r/rHrIrJr.�outlinerKr,�fill_inks	         r2�chordzImageDraw.chord�sn�����W�d�3�
��X����I�I� � ��U�C��1�=��?�s�h��5�A�:��I�I� � ��U�C��a��?�4>��?r4c���|j||�\}}|�|jj||d�|�+||k7r%|dk7r|jj||d|�yyyy)zDraw an ellipse.Nrr)rEr*�draw_ellipse�r/rHr.rSrKr,rTs       r2�ellipsezImageDraw.ellipse�sf�����W�d�3�
��X����I�I�"�"�2�x��3��?�s�h��5�A�:��I�I�"�"�2�s�A�u�5�4>��?r4c�h�|d|z
|d|z
|d|z|d|zf}|j||||�y)z4Draw a circle given center coordinates and a radius.rrN)rY)r/rH�radiusr.rSrK�
ellipse_xys       r2�circlezImageDraw.circle�sD����e�f�n�b��e�f�n�b��e�f�n�b��e�f�n�U�
����Z��w��6r4c
����|j|�d}|��R|jj||��|dk(�r.�dkD�r't|dtt
f�rt
ttt|�}nGtdt|�d�D�cgc](}t
ttt|||dz����*}}tdt|�dz
�D�]�}||}||dz
|f|||dzffD�	�
cgc]C\}	}
tjtj|
d|	dz
|	d|
dz
��dz��E}}	}
|d|dk(r�w						d�fd�}|d|dkDxr|dd	z
|dkDxs|d|dkxr|dd	z|dkD}
|d�dzz
dz|d�dzz
dzf|d�dzzdz
|d�dzzdz
fg}|
r|dd
z|dd
z}
}	n|dd
z
|dd
z
}
}	|j||	d
z
|
d
z
|��dkDs��7|
r |||dd
z�||||dd
z�g}n|||dd
z
�||||dd
z
�g}|j||d�
����yyyycc}wcc}
}	w)z6Draw a line, or a connected sequence of line segments.rN�curve��r�hc���|\}}|dz}�dzdz
}td�||tjtj|��zf||tjtj|��zffD��S)N�Zrarc3�K�|]9\}}||dkDrtj|�ntj|�z���;y�w)rN)�math�floor�ceil)�.0�p�p_ds   r2�	<genexpr>z9ImageDraw.line.<locals>.coord_at_angle.<locals>.<genexpr>s=����%�+���3��C�!�G����C�����3��P�+�s�?A)rBrf�cos�radians�sin)�coord�angle�x�y�distancerKs     �r2�coord_at_anglez&ImageDraw.line.<locals>.coord_at_angles���� %���1�����#(�1�9�q�=��$�%�"#�H�t�x�x����U�8K�/L�$L� M�!"�H�t�x�x����U�8K�/L�$L� M�+�%� �r4�rd��)rK)rp�Sequence[float]rq�float�returnztuple[float, ...])rEr*�
draw_linesr?�listrBrrrz�range�lenrf�degrees�atan2�pieslice�line)r/rHr.rK�jointr,�points�i�pointrIrJ�anglesru�flipped�coords�
gap_coordss   `            r2r�zImageDraw.line�s)����l�l�4� ��#���?��I�I� � ��S�%�0����E�A�I��b��e�d�E�]�3�!�(�8�E�?�";�R�@�F�"'�q�#�b�'�1�!5��!5�A��X�e�_�e�B�q�1�q�5�M�.B�C�!5����q�#�f�+��/�2�A�"�1�I�E�
$�A��E�]�E�2�"�F�1�q�5�M�2�+��+�J�E�3����T�Z�Z��A���q��0A�5��8�c�RS�f�CT�%U�V���+����a�y�F�1�I�-� ��.��7<��*���q�	�F�1�I�-�M�&��)�c�/�F�1�I�2M�Q� ��)�f�Q�i�/�O�F�1�I��O�f�Q�i�4O���q��E�A�I�-��1�5��8�e�a�i�3G�!�3K�L��q��E�A�I�-��1�5��8�e�a�i�3G�!�3K�L��F��&,�Q�i�"�n�f�Q�i�"�n�s��&,�Q�i�"�n�f�Q�i�"�n�s���M�M�&�%�"�*�c�B�h��E��q�y�"� .�u�f�Q�i�"�n� E� %� .�u�f�Q�i�"�n� E�*�J�!/�u�f�Q�i�"�n� E� %� .�u�f�Q�i�"�n� E�*�J�
�	�	�*�d�!�	�<�o3�%.������s
�-I,�9AI1c���|j�|j||�\}}|�|jj||d�|�$||k7r|jj||d�yyy)z(Experimental) Draw a shape.Nrr)�closerEr*�draw_outline)r/�shaper.rSr,rTs      r2r�zImageDraw.shape<se��	���
����W�d�3�
��X����I�I�"�"�5�(�A�6��?�s�h���I�I�"�"�5�#�q�1� /�?r4c���|j||�\}}|�|jj||||d�|�-||k7r'|dk7r!|jj||||d|�yyyy)zDraw a pieslice.Nrr)rEr*�
draw_pieslicerRs	         r2r�zImageDraw.piesliceJsn�����W�d�3�
��X����I�I�#�#�B��s�H�a�@��?�s�h��5�A�:��I�I�#�#�B��s�C��E�B�4>��?r4c�j�|j|�\}}|�|jj||�yy)z#Draw one or more individual pixels.N)rEr*�draw_points)r/rHr.r,s    r2r�zImageDraw.pointZs2���L�L��&�	��T��?��I�I�!�!�"�c�*�r4c��|j||�\}}|�|jj||d�|���||k7�r�|dk7�r�|dk(r|jj||d|�y|j��ft	j
d|jj�}|jd�d}|j�}	t|	�}
|
jj||d�|j�}t|�}
|dzdz
}|
jj||d|�|j||	��t	j
|j|jj�}t|�}
|
jj||d|�|jj|jd|jz|j�yyyyy)zDraw a polygon.Nrrrra)�mask�rr)rEr*�draw_polygonr(r
�new�size�copy�Draw�paster$)
r/rHr.rSrKr,rTr��mask_ink�fill_imr*�ink_imr(s
             r2�polygonzImageDraw.polygon`s}�����W�d�3�
��X����I�I�"�"�2�x��3��?�s�h��5�A�:���z��	�	�&�&�r�3��5�9����$��y�y��d�g�g�l�l�3���<�<��?�1�-���)�)�+���G�}���	�	�&�&�r�8�Q�7�������F�|����	�A�
���	�	�&�&�r�8�Q��>��
�
�6��
�0��Y�Y�t�y�y�$�'�'�,�,�7���B�x���	�	�&�&�r�3��5�9����
�
�b�e�e�V�b�g�g�%5�t�w�w�?�)%�4>��?r4c�F�t|||�}|j||||�y)zDraw a regular polygon.N)�!_compute_regular_polygon_verticesr�)r/�bounding_circle�n_sides�rotationr.rSrKrHs        r2�regular_polygonzImageDraw.regular_polygon�s$��/����
R�����R��w��.r4c���|j||�\}}|�|jj||d�|�+||k7r%|dk7r|jj||d|�yyyy)zDraw a rectangle.Nrr)rEr*�draw_rectanglerXs       r2�	rectanglezImageDraw.rectangle�sf�����W�d�3�
��X����I�I�$�$�R��1�5��?�s�h��5�A�:��I�I�$�$�R��a��7�4>��?r4)�cornersc
���������������t|dttf�r(tttt
|�\\��\��nttt
|�\������kr
d}t
|����kr
d}t
|����d�|dz�t���t���t���t���d\��t��r<���z
dz
k\��r��z
����z
dz
k\��r��z
��r�r�j|||��S�dk(st��s�j|||��St�dz�}�j||�\��d
������������fd	�}	���|	d
��r.�jj��|zdz��|z
dz
f�d�n>�|z
dz
�|zdzkDr-�jj�|zdz��|z
dz
�f�d��s��s����|z�g}
�dr|
dxx|dzz
cc<�dr|
dxx|dzzcc<�jj|
�d��|z
���g}�dr|dxx|dzz
cc<�dr|dxx|dzzcc<�jj|�d����h��k7�ra�dk7�rZ|	d��s������zdz
g}�dr|dxx|dzz
cc<�dr|dxx|dzzcc<�jj|�d����z
dz��g}
�dr|
dxx|dzz
cc<�dr|
dxx|dzzcc<�jj|
�d��s�����zdz
�g}
�dr|
dxx|dzz
cc<�dr|
dxx|dzzcc<�jj|
�d���z
dz���g}�dr|dxx|dzz
cc<�dr|dxx|dzzcc<�jj|�d�yyyyy)zDraw a rounded rectangle.rz&x1 must be greater than or equal to x0z&y1 must be greater than or equal to y0N)TTTTra)FFrc����r��
��z�
�zfddf���z
��z�fddff}nv�r��
��z�
�zfddf��z
�
��
�zfddff}nUt�fd�t��
��z�
�zfddf��z
�
��
�zfddf��z
��z
��fddf���z
��z�fddff�D��}|D]A}|r�	jj|�dfz��$�	jj|��
fz��Cy)Nrvrbrrd�c3�2�K�|]\}}�|r|���y�wr>�)rir��partr�s   �r2rlzDImageDraw.rounded_rectangle.<locals>.draw_corners.<locals>.<genexpr>�s*������$���4��q�z��$�s�r)rB�	enumerater*r�rG)r��partsr�r��drT�full_x�full_yr,r/rK�x0�x1�y0�y1s   ������������r2�draw_cornersz1ImageDraw.rounded_rectangle.<locals>.draw_corners�sa�����"�b�1�f�b�1�f�-�s�C�8��"�q�&�"�q�&�"�-�q�#�6�����"�b�1�f�b�1�f�-�r�3�7��1�f�b�"�b�1�f�-�s�B�7�����#,� �"�b�1�f�b�1�f�5�s�C�@� �1�f�b�"�b�1�f�5�s�C�@� �1�f�b�1�f�b�"�5�q�"�=� �"�q�&�"�q�&�"�5�r�3�?�	�$�������+�D�I�I�+�+�d�h��]�.B�D�&�D�I�I�&�&���e��)<�>�	r4TrxF)r��boolr{�None)r?r}rBrrrzr%�round�allrY�anyr��intrEr*r�)r/rHr[r.rSrKr�r1�rr��left�right�top�bottomr�rTr�r�r,r�r�r�r�s`    ``       @@@@@@@@@r2�rounded_rectanglezImageDraw.rounded_rectangle�sW�����b��e�d�E�]�+�!%�h�x���&?��!D��H�R��h�r�2�!�(�5�/�2�6�N�B��B��
��7�:�C��S�/�!�
��7�:�C��S�/�!��?�.�G��Q�J��
�2�Y��
�2�Y��
�2�Y��
�2�Y��%�����w�<��"�r�'�A�+�%�F����G���"�r�'�A�+�%�F����G���&��|�|�B��g�u�=�=���6��W���>�>�"�d�G�U�;�;���Q��K�����W�d�3�
��X� 	?� 	?� 	?�D�������	�	�(�(�"�b�1�f�q�j�"�b�1�f�q�j�)I�8�UV�W��a��!��b�1�f�q�j�(��	�	�(�(�"�q�&�1�*�b�"�q�&�1�*�b�)I�8�UV�W��&��B��Q���+���1�:���G�q�1�u�$�G��1�:���G�q�1�u�$�G��	�	�(�(��x��;��a���R��,���1�:��!�H��A��%�H��1�:��!�H��A��%�H��	�	�(�(���!�<��?�s�h��5�A�:������2�r�2��:��>�2���1�:���F�a�!�e�O�F��1�:���F�a�!�e�O�F��	�	�(�(��c�1�5��b�5�j�1�n�b�"�5���1�:��1�I��Q��&�I��1�:��1�I��Q��&�I��	�	�(�(���a�8���B��U�
�Q���3���1�:���G�q�1�u�$�G��1�:���G�q�1�u�$�G��	�	�(�(��s�A�6��e��a���R��4���1�:��!�H��A��%�H��1�:��!�H��A��%�H��	�	�(�(���Q�7��#4>��?r4c�2�t|t�rdnd}||vS�N�
�
)r?r@)r/�text�split_characters   r2�_multiline_checkzImageDraw._multiline_check+s��",�T�3�"7�$�U���$�&�&r4c�P�|jt|t�rd�Sd�Sr�)�splitr?r@)r/r�s  r2�_multiline_splitzImageDraw._multiline_split0s"���z�z�*�T�3�"7�$�C�C�U�C�Cr4c�>�|jdd||��d|z|zS)Nr��A)�stroke_widthrx)�textbbox)r/r�spacingr�s    r2�_multiline_spacingzImageDraw._multiline_spacing3s2��
�M�M�&�#�t�,�M�G��J��
��
�	
r4c��������	�
�
����
r�jdvr
d}t|���� �j�jd����j	��r�j��|��||��	�
||�
�
Sd�fd�}d	d
����
�	���
���fd�
}||�}|�.d}|r|�||�n|}|�|||�||d�y||�yy)z
Draw text.�rr�3Embedded color supported only in RGB and RGBA modesNr;c�@���j|�\}}|�|�J�|S|Sr>)rE)r.r,rTr/s   �r2�getinkzImageDraw.text.<locals>.getinkos0��� �L�L��.�M�C���{��+�+�+����Jr4rc�v���j}|dk(r�rd}g}td�D]}|jt�|���!t	j
�d�dt	j
�d�df}	�j�|g�
�����|�||d����\}}|d|dz|d|dzg}|dk(r�||jd�}}tjd|�d}	|jd|	�|\}
}�j�B�jj||
||
|j dz||j dzf|�yy�j"j%|||�y#t$rE	�j�|���|�|g�
��d|i���}n #t$r�j��}YnwxYwY��wxYw)	Nrrrar)�	direction�features�languager��anchorr,rIrIrxr�)r-r~�appendr�rf�modf�getmask2�AttributeError�getmask�	TypeError�getband�struct�pack�fillbandr(r�r�r*rN)r,r�r$rpr�rIr��offset�color�	ink_alpharrrsr��argsr��embedded_colorr�r�kwargsr�r/r�rHs            �����������r2�	draw_textz!ImageDraw.text.<locals>.draw_textvs	����=�=�D��q� �^����E��1�X�����S��A��Z�(���Y�Y�r�!�u�%�a�(�$�)�)�B�q�E�*:�1�*=�>�E�
.�,�t�}�}��� �� �(�%�%�!-�!��� �� ���f��q��F�1�I�-�u�Q�x�&��)�/C�D��$�v�~�#�D�L�L��O�t��"�K�K��S�1�!�4�	����q�)�,����1��7�7�&��G�G�M�M���1�a�$�)�)�A�,�&6��D�I�I�a�L�8H�I�4��'�
�	�	�%�%�e�T�3�7��;"�
.�.�'�4�<�<���!� � �$������$��!��D��!�.��<�<��-�D�.��
.�s6�=8E*�*	F8�4F�F8�F1�.F8�0F1�1F8�7F8)r.�_Ink | Noner{r�)r)r,r�r�rzr{r�)r$r%r<�getr��multiline_text)r/rHr�r.rr�r��alignr�r�r�r��stroke_fillr�r�r�r1r�r�r,�
stroke_inks``` ``  ```  ```     r2r�zImageDraw.text?s�����0�d�i�i��>�G�C��S�/�!��<��=�=����K�!8�9�D�� � ��&��&�&���������������
� 	�4	8�4	8�4	8�l�T�l���?��J��4?�4K�V�K�0�QT�
��%��*�l�3��#�q�!��#��r4)r;c��|dk(r
d}t|��|�d}n/t|�dk7r
d}t|��|ddvr
d}t|��|�|j|�}g}d	}|j|�}|j	|||�}|D]5}|j||||	|
�
�}|j
|�t||�}�7|d}|ddk(r|t|�dz
|zdzz}n|dd
k(r|t|�dz
|zz}t|�D]\}}|d	}|||z
}|d	dk(r	||dzz}n
|d	dk(r||z}|dk(rn&|dk(r	||dzz
}n|dk(r||z
}n
d}t|��|j||f||||||	|
|||
��||z
}��y)N�ttb�/ttb direction is unsupported for multiline text�lara�#anchor must be a 2 character stringr�tb�'anchor not supported for multiline textr)r�r�r��m�@r�r�r��centerr��)align must be "left", "center" or "right")r�r�r�r�r�r�)
r%rr<r�r��
textlengthr��maxr�r�)r/rHr�r.rr�r�r�r�r�r�r�r�r�r;r1�widths�	max_width�lines�line_spacingr��
line_widthr��idxr��width_differences                          r2r�zImageDraw.multiline_text�s��.���C�C��S�/�!��>��F�
��[�A�
�7�C��S�/�!�
�A�Y�$�
�;�C��S�/�!��<��=�=��+�D����	��%�%�d�+���.�.�t�W�l�K���D�����d�i�(�X�)��J�
�M�M�*�%��I�z�2�I����e���!�9����C��J��N�l�2�S�8�8�C�
�A�Y�#�
��C��J��N�l�2�2�C�"�5�)�I�C���a�5�D�(�6�#�;�6���a�y�C���(�3�.�.�����c�!��(�(�������(�"��(�3�.�.���'�!��(�(��A�� ��o�%��I�I��s������#�!�!�)�'�-�
�
�
�<��C�E*r4c���|j|�r
d}t|��|r|jdvr
d}t|��|�|j|�}|rdn|j}	|j||	|||�S)z@Get the length of a given string, in pixels with 1/64 precision.z&can't measure length of multiline textr�r�r)r�r%r$r<r-�	getlength)
r/r�rr�r�r�r�r;r1r$s
          r2rzImageDraw.textlengthsu��"� � ��&�:�C��S�/�!��d�i�i��>�G�C��S�/�!��<��=�=��+�D�'�v�T�]�]���~�~�d�D�)�X�x�H�Hr4c
�\�|r|jdvr
d}
t|
��|�|j|�}|j|�r|j	|||||||||	|
|�S|rdn|j
}|j
|||||	|
|�}|d|dz|d|dz|d|dz|d|dzfS)z2Get the bounding box of a given string, in pixels.r�r�rrrrarx)r$r%r<r��multiline_textbboxr-�getbbox)r/rHr�rr�r�r�r�r�r�r�r�r;r1r$�bboxs                r2r�zImageDraw.textbbox5s���,�d�i�i��>�G�C��S�/�!��<��=�=��+�D�� � ��&��*�*�������������
�(�v�T�]�]���|�|��$�	�8�X�|�V�
���A�w��A����Q��"�Q�%���a��2�a�5��$�q�'�B�q�E�/�Q�Qr4c���|dk(r
d}
t|
��|�d}n/t|�dk7r
d}
t|
��|ddvr
d}
t|
��|�|j|�}g}d	}|j|�}|j	|||
�}|D]6}|j|||||	|�
�}|j
|�t||�}�8|d}|ddk(r|t|�dz
|zdzz}n|dd
k(r|t|�dz
|zz}d}t|�D]�\}}|d	}|||z
}|d	dk(r	||dzz}n
|d	dk(r||z}|dk(rn&|dk(r	||dzz
}n|dk(r||z
}n
d}
t|
��|j||f||||||	|
|��	}|�|}nFt|d	|d	�t|d|d�t|d|d�t|d|d�f}||z
}��|�|d	|d|d	|dfS|S)Nr�r�r�rar�rr�r�r)r�r�r�r�r�rr�r�r�rr�r)r�r�r�r�r�rx)r%rr<r�r�rr�rr�r��min)r/rHr�rr�r�r�r�r�r�r�r�r;r1rrrrr�r	r�rr
r�r�	bbox_lines                          r2rzImageDraw.multiline_textbboxgs���*���C�C��S�/�!��>��F�
��[�A�
�7�C��S�/�!�
�A�Y�$�
�;�C��S�/�!��<��=�=��+�D����	��%�%�d�+���.�.�t�W�l�K���D������#�!�!�-�
)��J�
�M�M�*�%��I�z�2�I����e���!�9����C��J��N�l�2�S�8�8�C�
�A�Y�#�
��C��J��N�l�2�2�C�9=��"�5�)�I�C���a�5�D�(�6�#�;�6���a�y�C���(�3�.�.�����c�!��(�(�������(�"��(�3�.�.���'�!��(�(��A�� ��o�%��
�
��s�����#�!�!�)�-�&�
�I��|� ����Q���1��.���Q���1��.���Q���1��.���Q���1��.�	��
�<��C�U*�X�<��a�5�"�Q�%��A���1��-�-��r4r>)r(�Image.Imager$�
str | Noner{r�)r{�GImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont)r;�float | Noner{r)r,r�r.r�r{ztuple[int | None, int | None])Nr)rHrrIrzrJrzr.r�rKr�r{r�)rHz
Sequence[int]rOrr.r�r{r�)NNr)rHrrIrzrJrzr.r�rSr�rKr�r{r�)
rHrr.r�rSr�rKr�r{r�)rHryr[rzr.r�rSr�rKr�r{r�)NrN)
rHrr.r�rKr�r�rr{r��NN)r�zImage.core._Outliner.r�rSr�r{r�)rHrr.r�r{r�)rNNr)r��!Sequence[Sequence[float] | float]r�r�r�rzr.r�rSr�rKr�r{r�)rHrr[rzr.r�rSr�rKr�r�z$tuple[bool, bool, bool, bool] | Noner{r�)r�rr{r�)r�rr{zlist[AnyStr])rrr�rzr�rzr{rz)NNNr`r�NNNrNF) rH�tuple[float, float]r�rr.r�rrr�rr�rzr�r@r�rr��list[str] | Noner�rr�rzr�r�r�r�r�rr�rr{r�)rHrr�rr.r�rrr�rr�rzr�r@r�rr�rr�rr�rzr�r�r�r�r;rr{r�)NNNNF)r�rrrr�rr�rr�rr�r�r;rr{rz)	NNr`r�NNNrF)rHrr�rrrr�rr�rzr�r@r�rr�rr�rr�rzr�r�r;rr{z!tuple[float, float, float, float])�__name__�
__module__�__qualname__r�__annotations__r3r9r<rErLrOrUrYr]r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rr�r4r2rr@s���	
�	�V�
�(�T�	P��6"�%�"�	P�"�59�'��'�&1�'�	&�'�<!��
;��;��;��	;�
�;��
;�
�;�KO�	6��	6�)4�	6�<G�	6�	
�	6� !�#��@��@��@��	@�
�@��
@��@�
�@�&!�#��6��6��6��	6�
�6�
�
6�$!�#��
7��
7��
7��	
7�
�
7��
7�
�
7�!�� �K=��K=��K=��	K=�
�K=�
�
K=�`!�#�	2�"�2��2��	2�

�2�&!�#��C��C��C��	C�
�C��
C��C�
�C� +�!�#��"@��"@��"@��	"@�
�"@�
�
"@�P� �#��/�:�/��/��	/�
�/��
/��/�
�/� !�#��8��8��8��	8�
�8�
�
8�"� �#��
J8�9=�J8��J8��J8��	J8�
�J8��
J8�6�J8�
�J8�X'�
D�

�U�

��

��	

�

�

� !�
�!��� $�%)�#��#'�$�'{��{��{��	{�
�
{��{��{��{��{�#�{� �!{�"�#{�$!�%{�&�'{�(�){�*�+{�,
�-{�B!�
�!��� $�%)�#��#'�$�'Z �*#'�+Z ��Z ��Z ��	Z �
�
Z ��Z ��Z ��Z ��Z �#�Z � �!Z �"�#Z �$!�%Z �&�'Z �* �+Z �,
�-Z �H
� $�%)�#�$�I�#'�I��I�
�	I��I�#�I��I��I� �I�
�I�L
�!��� $�%)�#��$�#0R�&#'�'0R��0R��0R�

�0R��0R��0R��0R��0R�#�0R��0R� �!0R�"�#0R�& �'0R�(
+�)0R�v
�!��� $�%)�#��$�#k�&#'�'k��k��k�

�k��k��k��k��k�#�k��k� �!k�"�#k�& �'k�(
+�)kr4rc�^�	t|d�|�S#t$rt||�cYSwxYw)a�
    A simple 2D drawing interface for PIL images.

    :param im: The image to draw in.
    :param mode: Optional mode to use for color values.  For RGB
       images, this argument can be RGB or RGBA (to blend the
       drawing into the image).  For all other modes, this argument
       must be the same as the image mode.  If omitted, the mode
       defaults to the mode of the image.
    �getdraw)�getattrr�r)r(r$s  r2r�r��s7��#�%�w�r�9�%�d�+�+���#���T�"�"�#�s��,�,c�^�|�tdd�ddlm}|�|j|�nd}||fS)z�
    :param im: The image to draw in.
    :param hints: An optional list of hints. Deprecated.
    :returns: A (drawing context, drawing resource factory) tuple.
    Nz'hints' parameter�r)r)rr7rr�)r(�hintsrr*s    r2r"r"�s9��
���%�r�*��"$�.�?�:�?�?�2��d�D����r4c�(�|j�}|�J�|\}}	|||f}t||�|kry||||f<||fh}	t	�}
|	r�t	�}|	D]�\}}|dz|f|dz
|f||dzf||dz
ffD]f\}}
||
f|
vs
|dks|
dkr�	|||
f}|
j||
f�|�t||�|k}n|||fv}|s�M||||
f<|j||
f��h��|	}
|}	|	r��yy#ttf$rYywxYw#ttf$rY��wxYw)a�
    .. warning:: This method is experimental.

    Fills a bounded region with a given color.

    :param image: Target image.
    :param xy: Seed position (a 2-item coordinate tuple). See
        :ref:`coordinate-system`.
    :param value: Fill color.
    :param border: Optional border value.  If given, the region consists of
        pixels with a color different from the border color.  If not given,
        the region consists of pixels having the same color as the seed
        pixel.
    :param thresh: Optional threshold value which specifies a maximum
        tolerable difference of a pixel value from the 'background' in
        order for it to be replaced. Useful for filling regions of
        non-homogeneous, but similar, colors.
    Nrr)r!�_color_diffr%�
IndexError�set�add)�imagerH�value�border�thresh�pixelrrrs�
background�edge�	full_edge�new_edge�s�trjr.s                r2�	floodfillr7�s���6
�J�J�L�E�����
�D�A�q���1�a�4�[�
��u�j�)�V�3����a��d����F�8�D���I�
��5���D�A�q��a�%���a�!�e�Q�Z�!�Q��U��a��Q��Z�H���1��q�6�Y�&�!�a�%�1�q�5��-��a��d��A��M�M�1�a�&�)��~�*�1�j�9�V�C�� ����7���&+��a��d�� ���a��V�,�!I��$�	���+��

�
�#�����#�J�/����s(�C*�C*�C?�*C<�;C<�?D�Dc���	�
�t|t�s
d}t|��|dkr
d}t|��t|tt
f�s
d}t|��t
|�dk(rCtd�|D��s
d}t|��tttt	|���^�	�
n�t
|�dk(r�t|dtt
f�r�td	�|dD��rt|d
ttf�s
d}t|��t
|d�dk7r
d}t|��tttt	|d���	tt|d
��
n
d}t|���
dkr
d
}t|��t|ttf�s
d}t|��d�	fd��d��
fd�}dd�}|||�}|D�cgc]
}||���c}Scc}w)u�
    Generate a list of vertices for a 2D regular polygon.

    :param bounding_circle: The bounding circle is a sequence defined
        by a point and radius. The polygon is inscribed in this circle.
        (e.g. ``bounding_circle=(x, y, r)`` or ``((x, y), r)``)
    :param n_sides: Number of sides
        (e.g. ``n_sides=3`` for a triangle, ``6`` for a hexagon)
    :param rotation: Apply an arbitrary rotation to the polygon
        (e.g. ``rotation=90``, applies a 90 degree rotation)
    :return: List of regular polygon vertices
        (e.g. ``[(25, 50), (50, 50), (50, 25), (25, 25)]``)

    How are the vertices computed?
    1. Compute the following variables
        - theta: Angle between the apothem & the nearest polygon vertex
        - side_length: Length of each polygon edge
        - centroid: Center of bounding circle (1st, 2nd elements of bounding_circle)
        - polygon_radius: Polygon radius (last element of bounding_circle)
        - angles: Location of each polygon vertex in polar grid
            (e.g. A square with 0 degree rotation => [225.0, 315.0, 45.0, 135.0])

    2. For each angle in angles, get the polygon vertex at that angle
        The vertex is computed using the equation below.
            X= xcos(φ) + ysin(φ)
            Y= −xsin(φ) + ycos(φ)

        Note:
            φ = angle in degrees
            x = 0
            y = polygon_radius

        The formula above assumes rotation around the origin.
        In our case, we are rotating around the centroid.
        To account for this, we use the formula below
            X = xcos(φ) + ysin(φ) + centroid_x
            Y = −xsin(φ) + ycos(φ) + centroid_y
    zn_sides should be an intrxzn_sides should be an int > 2z$bounding_circle should be a sequencec3�HK�|]}t|ttf����y�wr>�r?r�rz�rir�s  r2rlz4_compute_regular_polygon_vertices.<locals>.<genexpr>os����H��1�:�a�#�u��.���� "z0bounding_circle should only contain numeric datararc3�HK�|]}t|ttf����y�wr>r:r;s  r2rlz4_compute_regular_polygon_vertices.<locals>.<genexpr>us ����
�1C�A�J�q�3��,�'�1C�r<rzBbounding_circle centre should contain 2D coordinates (e.g. (x, y))z[bounding_circle should contain 2D coordinates and a radius (e.g. (x, y, r) or ((x, y), r) )z$bounding_circle radius should be > 0z"rotation should be an int or floatc����t|dtjtjd|z
��z|dtjtjd|z
��zz
�dzd�t|dtjtjd|z
��z|dtjtjd|z
��zz�dzd�fS)Nrrbrra)r�rfrmrnro)r�r��centroids  �r2�_apply_rotationz:_compute_regular_polygon_vertices.<locals>._apply_rotation�s������a��4�8�8�D�L�L��w��$?�@�@���(�T�X�X�d�l�l�3��=�&A�B�B�C��1�+���	
�
��a��4�8�8�D�L�L��w��$?�@�@���(�T�X�X�d�l�l�3��=�&A�B�B�C��1�+���	
�

�
	
r4c����dg}�||�S�Nrr�)rq�start_pointr@�polygon_radiuss  ��r2�_compute_polygon_vertexzB_compute_regular_polygon_vertices.<locals>._compute_polygon_vertex�s���%�q�)���{�E�2�2r4c��g}d|z}dd|zz
|z}td|�D]#}|j|�||z
}|dkDs�|dz}�%|S)Nrbr�g�?r)r~r�)r�r�r�r��
current_angle�_s      r2�_get_anglesz6_compute_regular_polygon_vertices.<locals>._get_angles�sc������-���s�W�}�,��8�
��q�'�"�A��M�M�-�(��W�$�M��s�"���$�
�	#�
�
r4)r��list[float]r�rzr{r)rqrzr{r)r�r�r�rzr{rJ)
r?r�r�r%r}rBrr�rrz)r�r�r�r1rErIr�rqr@r?rDs        @@@r2r�r�7s����V�g�s�#�(����n����{�,����o���o��e�}�5�4����n��
�?��q� ��H��H�H�D�C��S�/�!�$(��e��d�?�6K�$L�!��>�	�_�	��	"�z�/�!�2D�t�U�m�'T��
�1@��1C�
�
��O�A�.��e��=�D�C��S�/�!���q�!�"�a�'�V�C��S�/�!���U��T�/�!�*<�%=�>���e�_�Q�%7�8��
<�	���o�����4����o���h��e��-�2����o��
� 3�
���(�
+�F�9?�?��u�#�E�*��?�?��?s�>Gc	����t|t�r|n|f�t|t�r|n|f�t��fd�tdt	���D��S)zJ
    Uses 1-norm distance to calculate difference between two values.
    c3�F�K�|]}t�|�|z
����y�wr>)�abs)rir��first�seconds  ��r2rlz_color_diff.<locals>.<genexpr>�s&�����H�2G�Q�s�5��8�f�Q�i�'�(�2G�s�!r)r?rB�sumr~r)�color1�color2rNrOs  @@r2r(r(�sE���!���/�F�f�Y�E�!�&�%�0�V�v�i�F��H�%��3�v�;�2G�H�H�Hr4r>)r(rr$rr{rr)r(zImage.Image | Noner&rr{z)tuple[ImageDraw2.Draw | None, ModuleType]rB)r,rrHztuple[int, int]r-�float | tuple[int, ...]r.zfloat | tuple[int, ...] | Noner/rzr{r�)r�rr�r�r�rzr{zlist[tuple[float, float]])rQrSrRrSr{rz)(�
__future__rrfr��collections.abcr�typesr�typingrrrr	r
rr7r
r�
_deprecater�_typingrr r)rSrr�rrrzrBr�r@�_Inkrr�r"r7r�r(r�r4r2�<module>r[sK��@#��
�$��D�D��!��
2�1���j�j� � �G��'��U�E�#�s�(�O�S�
(�)���R�R�j#�$>B�
��
�*:�
�.�
�(.2��>��>��>�#�>�
+�	>�

�>�
�
>�B@�6�@�AD�@�PU�@��@�D	I�#�	I�-D�	I�
�	I��S$���G��s�B7�7C�C

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists