403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/ImageDraw.cpython-39.opt-1.pyc
a

h�a���@s�ddlZddlZddlmZmZmZGdd�d�Zddd�Zzejj	Z
Wney^dZ
Yn0ddd	�Zdd
d�Z
dd
�Zdd�ZdS)�N�)�Image�
ImageColor�	ImageFontc@s�eZdZd7dd�Zdd�Zd8dd�Zd9d	d
�Zd:dd�Zd;d
d�Zd<dd�Z	d=dd�Z
d>dd�Zd?dd�Zd@dd�Z
dAdd�ZdBdd�ZdCdd�ZdDd d!�Zd"d#�Zd$d%�ZdEd)d*�ZdFd+d,�ZdGd-d.�ZdHd/d0�ZdId1d2�ZdJd3d4�ZdKd5d6�ZdS)L�	ImageDrawNcCs�|��|jr|��d}|dur(|j}||jkrR|dkrJ|jdkrJd}ntd��|dkrd|j|_nd|_||_|j|_tj	�
|j|�|_
||_|dvr�|j
�d�|_n|j
�d	�|_|d
vr�d|_
nd|_
d|_d|_dS)
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�RGBrz
mode mismatch�P)�I�F���)�1r	r
rr
�L)�load�readonlyZ_copy�mode�
ValueError�palette�_image�imr�core�draw�draw_ink�ink�fontmode�fill�font)�selfrrZblend�r�1/usr/lib/python3.9/site-packages/PIL/ImageDraw.py�__init__/s2

zImageDraw.__init__cCs"|jsddlm}|��|_|jS)zH
        Get the current default font.

        :returns: An image font.r)r)r�rZload_default)rrrrr�getfontYs
zImageDraw.getfontcCs�|dur&|dur&|jr|j}q�|j}n�|durtt|t�rFt�||j�}|jrht|tj	�sh|j�||j
�}|j�|�}|dur�t|t�r�t�||j�}|jr�t|tj	�s�|j�||j
�}|j�|�}||fS�N)
rr�
isinstance�strrZgetcolorrr�numbers�Numberrrr)rrrrrr�_getinkes"

zImageDraw._getinkrcCs.|�|�\}}|dur*|j�|||||�dS)zDraw an arc.N)r(r�draw_arc)r�xy�start�endr�widthrrrr�arczsz
ImageDraw.arccCs@|��|�|�\}}|dur"|}|dur<|j�||j|�dS)zDraw a bitmap.N)rr(r�draw_bitmapr)rr*�bitmaprrrrrr0�szImageDraw.bitmapcCs^|�||�\}}|dur,|j�||||d�|durZ||krZ|dkrZ|j�||||d|�dS)z
Draw a chord.Nrr)r(rZ
draw_chord�rr*r+r,r�outliner-rrrr�chord�s
zImageDraw.chordcCsV|�||�\}}|dur(|j�||d�|durR||krR|dkrR|j�||d|�dS)zDraw an ellipse.Nrr)r(rZdraw_ellipse�rr*rr2r-rrrr�ellipse�s
zImageDraw.ellipsercs6|�|�d}|du�r2|j��|��|dk�r2�dk�r2t�dttf�sl�fdd�tdt��d�D��tdt��d�D�]�}�|}d	d��|d|f|�|dffD�}|d|dkr�q~�fd
d�}	|d|dkr�|dd|dk�p|d|dk�o|dd|dk}
|d�dd|d�ddf|d�dd|d�ddfg}|
�r�|dd
|dd
}}
n|dd
|dd
}}
|�||d
|
d
|��dkr~|
�r�|	||dd
�||	||dd
�g}n&|	||dd
�||	||dd
�g}|j	||dd�q~dS)z6Draw a line, or a connected sequence of line segments.rNZcurve�cs g|]}t�||d���qS)�)�tuple��.0�i)r*rr�
<listcomp>��z"ImageDraw.line.<locals>.<listcomp>r7rc
Ss>g|]6\}}t�t�|d|d|d|d��d�qS)rr�h)�math�degreesZatan2)r:r+r,rrrr<�s�(�c
sZ|\}}|d8}�dd}tdd�||t�t�|��f||t�t�|��ffD��S)N�Zr7rcSs0g|](\}}||dkr t�|�nt�|��qS)r)r?ZfloorZceil)r:�pZp_drrrr<�s�z:ImageDraw.line.<locals>.coord_at_angle.<locals>.<listcomp>)r8r?�cos�radians�sin)�coord�angle�x�yZdistance�r-rr�coord_at_angle�s���z&ImageDraw.line.<locals>.coord_at_angle�rA��rJ)
r(rZ
draw_linesr$�listr8�range�len�pieslice�line)rr*rr-Zjointrr;�point�anglesrKZflippedZcoordsr+r,Z	gapCoordsr)r-r*rrS�sH
�"�$�&&���zImageDraw.linecCsT|��|�||�\}}|dur0|j�||d�|durP||krP|j�||d�dS)z(Experimental) Draw a shape.Nrr)�closer(rZdraw_outline)r�shaperr2rrrrrW�szImageDraw.shapecCs^|�||�\}}|dur,|j�||||d�|durZ||krZ|dkrZ|j�||||d|�dS)zDraw a pieslice.Nrr)r(r�
draw_pieslicer1rrrrR�s
zImageDraw.pieslicecCs(|�|�\}}|dur$|j�||�dS)z#Draw one or more individual pixels.N)r(rZdraw_points)rr*rrrrrrT�szImageDraw.pointcCsL|�||�\}}|dur(|j�||d�|durH||krH|j�||d�dS)zDraw a polygon.Nrr)r(rZdraw_polygon)rr*rr2rrrr�polygon�s
zImageDraw.polygoncCst|||�}|�|||�dS)zDraw a regular polygon.N)�!_compute_regular_polygon_verticesrY)r�bounding_circle�n_sides�rotationrr2r*rrr�regular_polygon�szImageDraw.regular_polygoncCsV|�||�\}}|dur(|j�||d�|durR||krR|dkrR|j�||d|�dS)zDraw a rectangle.Nrr)r(r�draw_rectangler4rrr�	rectangle�s
zImageDraw.rectanglecs�t|dttf�r$|\\��	\��
n|\��	��
|d����k��rP�����
�	k��rh�
�	��r��r���|�|��S�dkr���|�|��S�d}��|��\������������	�
fdd�}�du�r�|d���r�j���	|d��
|df�d�n(�j��|d�	�|d�
f�d���s���s��j���	|d�|�
|df�d��j��|�	|d��
|df�d��du�r���k�r��dk�r�|d���s*�j��|d�	�|d�	�df�d��j��|d�
�d�|d�
f�d���s��j���	|d��d�
|df�d��j���d�	|d��
|df�d�dS)	zDraw a rounded rectangle.rr7cs�r:��	���	�fddf��
����
fddff}n��rt��	���	�fddf���	��	�fddff}nd���	��	�fddf���
���
fddf��
����
fddf��	���	�fddff}|D]2}|r��jj|�df�q܈jj|��f�q�dS)NrLr>rrA�r)rrXr))rR�parts�part��drZfull_xZfull_yrrr-Zx0Zx1Zy0Zy1rr�draw_corners!s"���z1ImageDraw.rounded_rectangle.<locals>.draw_cornersNTrF)r$rOr8r5r`r(rr_)rr*Zradiusrr2r-�rrfrrdr�rounded_rectanglesR 
*(,,&�&�&�&�zImageDraw.rounded_rectanglecCst|t�rdnd}||vS)z
Draw text.�
�
)r$r%�r�textZsplit_characterrrr�_multiline_checkXszImageDraw._multiline_checkcCst|t�rdnd}|�|�S)Nrirj)r$r%�splitrkrrr�_multiline_split^szImageDraw._multiline_splitr6�leftFcs����	�r,���
�	|��||���||��
S�rB�jdvrBtd���durR�����fdd�}d����������	�
fdd�	}||�}|dur�d}|r�|dur�||�n|}|dur�|||�||d�n||�dS)	N�rr�3Embedded color supported only in RGB and RGBA modescs��|�\}}|dur|S|Sr#)r()rr)rrr�getink�szImageDraw.text.<locals>.getinkrc	sf�j}|dkr�rd}�
}zP�j�	|g��R���|�|d����\}}|d|d|d|df}WnZty�z*�j�	|���|�|g��Ri���}Wnty����	�}Yn0Yn0|r�|d|d|d|df}|dk�rR||�d�}}|�d|d?d@�|d|jd|d|jdf}�j�	||||�n�j
�|||�dS)Nrr)�	direction�features�language�stroke_width�anchorrrrN��)rZgetmask2�AttributeErrorZgetmask�	TypeErrorZgetbandZfillband�sizerZpasterr/)	rrwZ
stroke_offsetrrF�mask�offsetZcolorZcoord2�rx�argsrt�embedded_colorrur�kwargsrvrrlr*rr�	draw_text�s^�	��
�
$�	�
�
 
$z!ImageDraw.text.<locals>.draw_text)rN)rm�multiline_textrrr")rr*rlrrrx�spacing�alignrtrurvrw�stroke_fillr�r�r�rsr�rZ
stroke_inkrr�rrlcs>
�"/
zImageDraw.textcCs�|dkrtd��|durd}n*t|�dkr4td��n|ddvrHtd��g}d	}|�|�}|jd
||d�d|}|D],}|j||||	|
d�}|�|�t||�}qv|d}|dd
kr�|t|�d|d8}n |ddkr�|t|�d|8}t|�D]�\}}|d	}|||}|d	d
k�r2||d8}n|d	dk�rH||8}|dk�rTn4|dk�rl||d7}n|dk�r�||7}ntd��|j||f||||||	|
|||
d�||7}q�dS)N�ttb�/ttb direction is unsupported for multiline text�lar7�#anchor must be a 2 character stringr�tb�'anchor not supported for multiline textr�A�rrw�rtrurv�m�@rergrp�center�right�)align must be "left", "center" or "right")rtrurvrwr�r�)	rrQro�textsize�
textlength�append�max�	enumeraterl)rr*rlrrrxr�r�rtrurvrwr�r��widths�	max_width�lines�line_spacingrS�
line_width�top�idxrp�width_differencerrrr��sh

�
�




�
zImageDraw.multiline_textc	CsB|�|�r |�|||||||�S|dur0|��}|�|||||�S)z*Get the size of a given string, in pixels.N)rm�multiline_textsizer"�getsize)rrlrr�rtrurvrwrrrr�!s
�zImageDraw.textsizec
Cshd}|�|�}	|jd||d�d|}
|	D](}|�|||||||�\}}
t||�}q*|t|	�|
|fS)Nrr�r�r)ror�r�rQ)rrlrr�rtrurvrwr�r�r�rSr�Zline_heightrrrr�5s

��zImageDraw.multiline_textsizec	
Cs�|�|�rtd��|r(|jdvr(td��|dur8|��}|r@dn|j}z|�|||||�WSty�|j|||||d�}|dkr�|dYS|d	YS0dS)
z@Get the length of a given string, in pixels with 1/64 precision.z&can't measure length of multiline textrqrrNrr�r�rr)rmrrr"rZ	getlengthr{r�)	rrlrrtrurvr�rr}rrrr�Ks 


�zImageDraw.textlengthc
Cs�|r|jdvrtd��|�|�r>|�|||||||||	|
|�S|durN|��}t|tj�sbtd��|rjdn|j}|�	|||||	|
|�}
|
d|d|
d|d|
d|d|
d	|dfS)
z2Get the bounding box of a given string, in pixels.rqrrNz!Only supported for TrueType fontsrrrr7rN)
rrrm�multiline_textbboxr"r$rZFreeTypeFontrZgetbbox)rr*rlrrxr�r�rtrurvrwr�r�bboxrrr�textbboxgs2
��zImageDraw.textbboxcCs:|dkrtd��|durd}n*t|�dkr4td��n|ddvrHtd��g}d	}
|�|�}|jd
||
d�d|}|D].}|j|||||	|d�}|�|�t|
|�}
qv|d}|dd
kr�|t|�d|d8}n |ddkr�|t|�d|8}d}t|�D�]\}}|d	}|
||}|d	d
k�r:||d8}n|d	dk�rP||8}|dk�r\n4|dk�rt||d7}n|dk�r�||7}ntd��|j||f||||||	|
|d�	}|du�r�|}nDt	|d	|d	�t	|d|d�t|d|d�t|d|d�f}||7}�q|du�r6|d	|d|d	|dfS|S)Nr�r�r�r7r�rr�r�rr�r�)rtrurvr�r�r�rergrpr�r�r�)rtrurvrwr�rN)
rrQror�r�r�r�r�r��min)rr*rlrrxr�r�rtrurvrwr�r�r�r�r�rSr�r�r�r�rpr�Z	bbox_linerrrr��s�

��




�
�
zImageDraw.multiline_textbbox)N)N)Nr)N)NNr)NNr)NrN)NN)NNr)N)NN)rNN)NNr)rNNr)NNNr6rpNNNrNF)NNNr6rpNNNrNF)Nr6NNNr)Nr6NNNr)NNNNF)	NNr6rpNNNrF)	NNr6rpNNNrF)�__name__�
__module__�__qualname__r r"r(r.r0r3r5rSrWrRrTrYr^r`rhrmrorlr�r�r�r�r�r�rrrrr.s�
*


	


>
	


	�


S	�
r�
S�
�
�
 �
/�rcCs.z|�|�WSty(t||�YS0dS)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.
    N)�getdrawr{r)rrrrr�Draw�sr�cCs^d}|rd|vr4zddlm}Wnty2Yn0|durHddlm}|rV|�|�}||fS)a
    (Experimental) A more advanced 2D drawing interface for PIL images,
    based on the WCK interface.

    :param im: The image to draw in.
    :param hints: An optional list of hints.
    :returns: A (drawing context, drawing resource factory) tuple.
    NZnicestr)�_imagingagg)�
ImageDraw2)r!r��ImportErrorr�r�)r�hintsZhandlerrrrr�s
r�cCsf|��}|\}}z0|||f}t||�|kr2WdS||||f<WnttfyXYdS0||fh}	t�}
|	�rbt�}|	D]�\}}|d|f|d|f||df||dffD]�\}}
||
f|
vs�|dks�|
dkr�q�z|||
f}Wnttfy�Yq�0|
�||
f�|du�r$t||�|k}n||k�o4||k}|r�||||
f<|�||
f�q�qz|	}
|}	qjdS)a�
    (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.
    Nrr)r�_color_diffr�
IndexError�set�add)Zimager*�valueZborderZthreshZpixelrHrIZ
backgroundZedgeZ	full_edgeZnew_edge�s�trBrrrr�	floodfill$s<
4
r�cst|t�std��|dkr"td��t|ttf�s8td��t|�dkrP|�^��nt|�dkrf|\��ntd��tdd�g����RD��s�td	��t��dks�td
���dkr�td��t|ttf�s�td
��dd���fdd��dd�}|||�}���fdd�|D�S)u�
    Generate a list of vertices for a 2D regular polygon.

    :param bounding_circle: The bounding circle is a tuple 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 intrNzn_sides should be an int > 2z!bounding_circle should be a tupler7z[bounding_circle should contain 2D coordinates and a radius (e.g. (x, y, r) or ((x, y), r) )css|]}t|ttf�VqdSr#)r$�int�floatr9rrr�	<genexpr>�r=z4_compute_regular_polygon_vertices.<locals>.<genexpr>z0bounding_circle should only contain numeric datazBbounding_circle centre should contain 2D coordinates (e.g. (x, y))rz$bounding_circle radius should be > 0z"rotation should be an int or floatc
Ss�t|dt�t�d|��|dt�t�d|��|dd�t|dt�t�d|��|dt�t�d|��|dd�fS)Nrr>rr7)�roundr?rCrDrE)rTr@�centroidrrr�_apply_rotation�s"�������z:_compute_regular_polygon_vertices.<locals>._apply_rotationcs|dg}�|||�S)Nrr)r��polygon_radiusrGZstart_point)r�rr�_compute_polygon_vertex�szB_compute_regular_polygon_vertices.<locals>._compute_polygon_vertexcSsRg}d|}dd||}td|�D]&}|�|�||7}|dkr&|d8}q&|S)Nr>rag�?r)rPr�)r\r]rUr@Z
current_angle�_rrr�_get_angles�s

z6_compute_regular_polygon_vertices.<locals>._get_anglescsg|]}���|��qSrr)r:rG)r�r�r�rrr<�sz5_compute_regular_polygon_vertices.<locals>.<listcomp>)	r$r�r|rrOr8rQ�allr�)r[r\r]r�rUr)r�r�r�r�rrZ\s<)

��
�rZcs<t�t�r,t��fdd�tdt���D��St���SdS)zJ
    Uses 1-norm distance to calculate difference between two values.
    cs g|]}t�|�|��qSr)�absr9�Zcolor1Zcolor2rrr<�r=z_color_diff.<locals>.<listcomp>rN)r$r8�sumrPrQr�r�rr�rr��s
"r�)N)NN)Nr)r?r&r!rrrrr�rr2ZOutliner{r�r�rZr�rrrr�<module>!s"
K



8u

Youez - 2016 - github.com/yon3zu
LinuXploit