Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 iaš„ã @sŠddlZddlZddlmZmZmZGdd„dƒZddd„Zy ejj Z Wne k r`dZ YnXddd „Z dd d „Z d d „Zdd„ZdS)éNé)ÚImageÚ ImageColorÚ ImageFontc @söeZdZd7dd„Zdd„Zd8dd„Zd9d d „Zd:d d „Zd;d d„Zddd„Z d?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Ü|jƒ|jr|jƒd}|dkr(|j}||jkrR|dkrJ|jdkrJd}ntdƒ‚|dkrd|j|_nd|_||_|j|_tj j |j|ƒ|_ ||_|d kr¨|j j dƒ|_ n|j j d ƒ|_ |dkrÆ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Ú1ÚL)r r éÿÿÿÿ)r r r r )ÚloadÚreadonlyZ_copyÚmodeÚ ValueErrorÚpaletteÚ_imageÚimrÚcoreÚdrawÚdraw_inkÚinkÚfontmodeÚfillÚfont)ÚselfrrZblend©rú./tmp/tmp5hum_rxs/lib64/python/PIL/ImageDraw.pyÚ__init__/s2   zImageDraw.__init__cCs"|jsddlm}|jƒ|_|jS)zH Get the current default font. :returns: An image font.r)r)rÚrZ load_default)rrrrrÚgetfontYs  zImageDraw.getfontcCsÎ|dkr&|dkr&|jr|j}qÆ|j}n |dk rvt|tƒrFtj||jƒ}|jrjt|tj ƒ rj|jj||j ƒ}|j j |ƒ}|dk rÆt|tƒr–tj||jƒ}|jrºt|tj ƒ rº|jj||j ƒ}|j j |ƒ}||fS)N) rrÚ isinstanceÚstrrZgetcolorrrÚnumbersÚNumberrrr)rrrrrrÚ_getinkes"    zImageDraw._getinkrcCs.|j|ƒ\}}|dk r*|jj|||||ƒdS)z Draw an arc.N)r'rÚdraw_arc)rÚxyÚstartÚendrÚwidthrrrrÚarczsz ImageDraw.arccCs@|jƒ|j|ƒ\}}|dkr"|}|dk r<|jj||j|ƒdS)zDraw a bitmap.N)rr'rÚ draw_bitmapr)rr)Úbitmaprrrrrr/€s zImageDraw.bitmapcCs^|j||ƒ\}}|dk r,|jj||||dƒ|dk rZ||krZ|dkrZ|jj||||d|ƒdS)z Draw a chord.Nrr)r'rZ draw_chord)rr)r*r+rÚoutliner,rrrrÚchord‰s zImageDraw.chordcCsV|j||ƒ\}}|dk r(|jj||dƒ|dk rR||krR|dkrR|jj||d|ƒdS)zDraw an ellipse.Nrr)r'rZ draw_ellipse)rr)rr0r,rrrrÚellipse‘s zImageDraw.ellipsercs:|j|ƒd}|dk �r6|jjˆ|ˆƒ|dko6ˆdk�r6tˆdttfƒsj‡fdd„tdtˆƒdƒDƒ‰�xÈ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 } } |j| | d | d |ƒˆdkr€| �rü| ||dd ƒ|| ||dd ƒg}n&| ||dd ƒ|| ||dd ƒg}|j ||dd�q€WdS)z6Draw a line, or a connected sequence of line segments.rNZcurveécs g|]}tˆ||d…ƒ‘qS)é)Útuple)Ú.0Úi)r)rrú  sz"ImageDraw.line..r4rcSs>g|]6\}}tjtj|d|d|d|dƒƒd‘qS)rrih)ÚmathÚdegreesÚatan2)r6r*r+rrrr8¤scsZ|\}}|d8}ˆdd}tdd„||tjtj|ƒƒf||tjtj|ƒƒffDƒƒS)NéZr4rcSs0g|](\}}||dkr tj|ƒntj|ƒ‘qS)r)r9ÚfloorÚceil)r6ÚpZp_drrrr8²sz:ImageDraw.line..coord_at_angle..)r5r9ÚcosÚradiansÚsin)ÚcoordÚangleÚxÚyZdistance)r,rrÚcoord_at_angle¬s z&ImageDraw.line..coord_at_angleé´r<éé)r,) r'rZ draw_linesr#Úlistr5ÚrangeÚlenÚpiesliceÚline)rr)rr,Zjointrr7ÚpointÚanglesrGZflippedZcoordsr*r+Z gapCoordsr)r,r)rrO™s< $ &&&*zImageDraw.linecCsT|jƒ|j||ƒ\}}|dk r0|jj||dƒ|dk rP||krP|jj||dƒdS)z(Experimental) Draw a shape.Nrr)Úcloser'rZ draw_outline)rÚshaperr0rrrrrS×s zImageDraw.shapecCs^|j||ƒ\}}|dk r,|jj||||dƒ|dk rZ||krZ|dkrZ|jj||||d|ƒdS)zDraw a pieslice.Nrr)r'rÚ draw_pieslice)rr)r*r+rr0r,rrrrrNàs zImageDraw.pieslicecCs(|j|ƒ\}}|dk r$|jj||ƒdS)z#Draw one or more individual pixels.N)r'rZ draw_points)rr)rrrrrrPèszImageDraw.pointcCsL|j||ƒ\}}|dk r(|jj||dƒ|dk rH||krH|jj||dƒdS)zDraw a polygon.Nrr)r'rZ draw_polygon)rr)rr0rrrrÚpolygonîs zImageDraw.polygoncCst|||ƒ}|j|||ƒdS)zDraw a regular polygon.N)Ú!_compute_regular_polygon_verticesrU)rÚbounding_circleÚn_sidesÚrotationrr0r)rrrÚregular_polygonös zImageDraw.regular_polygoncCsV|j||ƒ\}}|dk r(|jj||dƒ|dk rR||krR|dkrR|jj||d|ƒdS)zDraw a rectangle.Nrr)r'rÚdraw_rectangle)rr)rr0r,rrrrÚ rectangleýs zImageDraw.rectanglec s˜t|dttfƒr$|\\‰‰ \‰‰ n |\‰‰ ‰‰ |d‰ˆˆˆk‰ˆrPˆˆ‰ˆˆ ˆ k‰ˆrhˆ ˆ ‰ˆr€ˆr€ˆj|ˆ|ˆƒSˆdkr˜ˆj|ˆ|ˆƒSˆd}ˆj|ˆƒ\‰‰‡‡‡‡‡‡‡‡‡‡ ‡ f dd„}ˆdk �r¢|dƒˆ�rˆjjˆˆ |dˆˆ |dfˆdƒn(ˆjjˆ|dˆ ˆ|dˆ fˆdƒˆ �r¢ˆ �r¢ˆjjˆˆ |dˆ|ˆ |dfˆdƒˆjjˆ|ˆ |dˆˆ |dfˆdƒˆdk �r”ˆˆk�r”ˆdk�r”|dƒˆ�s.ˆjjˆ|dˆ ˆ|dˆ ˆdfˆdƒˆjjˆ|dˆ ˆdˆ|dˆ fˆdƒˆ�s”ˆjjˆˆ |dˆˆdˆ |dfˆdƒˆjjˆˆdˆ |dˆˆ |dfˆdƒdS) zDraw a rounded rectangle.rr4csˆr:ˆˆ ˆˆˆ ˆfddfˆˆ ˆˆˆˆ fddff}nžˆrtˆˆ ˆˆˆ ˆfddfˆˆˆ ˆˆ ˆfddff}ndˆˆˆ ˆˆ ˆfddfˆˆˆ ˆˆˆ fddfˆˆ ˆˆˆˆ fddfˆˆ ˆˆˆ ˆfddff}x:|D]2}|rüˆjj|ˆdfŽqÞˆjj|ˆˆfŽqÞWdS)NrHihrr<ir)rrTr()rNÚpartsÚpart) ÚdrÚfull_xÚfull_yrrr,Úx0Úx1Úy0Úy1rrÚ draw_corners!s z1ImageDraw.rounded_rectangle..draw_cornersNTrF)r#rKr5r2r\r'rr[)rr)Zradiusrr0r,Úrrfr) r_rr`rarrr,rbrcrdrerÚrounded_rectanglesJ     *(,,***zImageDraw.rounded_rectanglecCst|tƒrdnd}||kS)z Draw text.Ú ó )r#r$)rÚtextÚsplit_characterrrrÚ_multiline_checkXszImageDraw._multiline_checkcCst|tƒrdnd}|j|ƒS)Nrirj)r#r$Úsplit)rrkrlrrrÚ_multiline_split^szImageDraw._multiline_splitr3ÚleftFcsÖˆjˆ ƒr,ˆjˆ ˆ |ˆˆ||ˆˆˆ| | ˆƒ SˆrBˆjd krBtdƒ‚ˆdkrRˆjƒ‰‡fdd„}d ‡‡‡‡‡‡‡‡‡‡ ‡ f dd„ }||ƒ}|dk rÒd}| r¬| dk r¨|| ƒn|}|dk rÊ||| ƒ||dƒn||ƒdS) Nrrz3Embedded color supported only in RGB and RGBA modescsˆj|ƒ\}}|dkr|S|S)N)r')rr)rrrÚgetinkŒszImageDraw.text..getinkrc sbˆj}|dkrˆrd}ˆ }yNˆjˆ |fˆžˆˆˆ|ˆ|dœˆ—Ž\}}|d|d|d|df}WnXtk rÀy$ˆjˆ |ˆˆˆ|ˆ|fˆžˆŽ}Wntk rºˆjˆ ƒ}YnXYnX|ræ|d|d|d|df}|dk�rN||jdƒ}}|jd|d?d@ƒ|d|jd|d|jdf}ˆjj ||||ƒnˆj j |||ƒdS)Nrr)Ú directionÚfeaturesÚlanguageÚ stroke_widthÚanchorrrrJééÿ) rZgetmask2ÚAttributeErrorZgetmaskÚ TypeErrorZgetbandZfillbandÚsizerZpasterr.) rruZ stroke_offsetrrCÚmaskÚoffsetZcolorZcoord2) rvÚargsrrÚembedded_colorrsrÚkwargsrtrrkr)rrÚ draw_text’sD  $   $z!ImageDraw.text..draw_text)rr)rN)rmÚmultiline_textrrr")rr)rkrrrvÚspacingÚalignrrrsrtruÚ stroke_fillrr~r€rqr�rZ stroke_inkr) rvr~rrrrsrr€rtrrkr)rrkcs<  "/  zImageDraw.textcCsÄ|dkrtdƒ‚|dkrd}n*t|ƒdkr4tdƒ‚n|ddkrHtdƒ‚g}d }|j|ƒ}|jd || d �d|}x4|D],}|j|||| | d �}|j|ƒt||ƒ}qxW|d}|dd krÖ|t|ƒd|d8}n |ddkrö|t|ƒd|8}xÈt|ƒD]¼\}}|d }|||}|d d k�r8||d8}n|d dk�rN||8}|dk�rZn4|dk�rr||d7}n|dk�r†||7}ntdƒ‚|j||f|||||| | | | | d� ||7}�qWdS)NÚttbz/ttb direction is unsupported for multiline textÚlar4z#anchor must be a 2 character stringrÚtbz'anchor not supported for multiline textrÚA)rru)rrrsrtÚmg@r_rgrpÚcenterÚrightz)align must be "left", "center" or "right")rrrsrtrur…r) rrMroÚtextsizeÚ textlengthÚappendÚmaxÚ enumeraterk)rr)rkrrrvrƒr„rrrsrtrur…rÚwidthsÚ max_widthÚlinesÚ line_spacingrOÚ line_widthÚtopÚidxrpÚwidth_differencerrrr‚Ñsb             zImageDraw.multiline_textcCsB|j|ƒr |j|||||||ƒS|dkr0|jƒ}|j|||||ƒS)z*Get the size of a given string, in pixels.N)rmÚmultiline_textsizer"Úgetsize)rrkrrƒrrrsrtrurrrr�!s zImageDraw.textsizec Csld}|j|ƒ} |jd||d�d|} x0| D](} |j| ||||||ƒ\} } t|| ƒ}q,W|t| ƒ| |fS)Nrr‰)rrur)ror�r�rM)rrkrrƒrrrsrtrur“r”r•rOr–Z line_heightrrrrš5s   zImageDraw.multiline_textsizec Csš|j|ƒrtdƒ‚|r(|jd kr(tdƒ‚|dkr8|jƒ}|r@dn|j}y|j|||||ƒStk r”|j|||||d�}|dkrŒ|dS|d SXdS) z@Get the length of a given string, in pixels with 1/64 precision.z&can't measure length of multiline textrrz3Embedded color supported only in RGB and RGBA modesN)rrrsrtr†rr)rr)rmrrr"rZ getlengthryr�) rrkrrrrsrtrrr{rrrrŽKs zImageDraw.textlengthc  CsÂ| r|jd krtdƒ‚|j|ƒr>|j||||||||| | | ƒ S|dkrN|jƒ}t|tjƒsbtdƒ‚| rjdn|j} |j || ||| | |ƒ} | d|d| d|d| d|d| d |dfS) z2Get the bounding box of a given string, in pixels.rrz3Embedded color supported only in RGB and RGBA modesNz!Only supported for TrueType fontsrrr4rJ)rr) rrrmÚmultiline_textbboxr"r#rZ FreeTypeFontrZgetbbox)rr)rkrrvrƒr„rrrsrtrurrÚbboxrrrÚtextbboxgs.  zImageDraw.textbboxc  CsD|dkrtdƒ‚|dkrd}n*t|ƒdkr4tdƒ‚n|ddkrHtdƒ‚g} d } |j|ƒ}|jd || d �d|}x6|D].}|j||||| | d �}| j|ƒt| |ƒ} qxW|d}|dd krØ|t|ƒd|d8}n |ddkrø|t|ƒd|8}d}�xt|ƒD�] \}}|d }| | |}|d d k�rB||d8}n|d dk�rX||8}|dk�rdn4|dk�r|||d7}n|dk�r�||7}ntdƒ‚|j||f|||||| | | d� }|dk�rÈ|}nDt |d |d ƒt |d|dƒt|d|dƒt|d|dƒf}||7}�qW|dk�r@|d |d|d |dfS|S)Nr†z/ttb direction is unsupported for multiline textr‡r4z#anchor must be a 2 character stringrrˆz'anchor not supported for multiline textrr‰)rru)rrrsrtrrŠg@r_rgrpr‹rŒz)align must be "left", "center" or "right")rrrsrtrurrJ) rrMror�rŽr�r�r‘ržÚmin)rr)rkrrvrƒr„rrrsrtrurr’r“r”r•rOr–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) NNNr3rpNNNrNF) NNNr3rpNNNrNF)Nr3NNNr)Nr3NNNr)NNNNF) NNr3rpNNNrF) NNr3rpNNNrF)Ú__name__Ú __module__Ú __qualname__r r"r'r-r/r1r2rOrSrNrPrUrZr\rhrmrorkr‚r�ršrŽržrœrrrrr.s” *     >     S  d E    #rc Cs*y |j|ƒStk r$t||ƒSXdS)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)Úgetdrawryr)rrrrrÚDrawôs  r¤c Csbd}| sd|kr8yddlm}Wntk r6YnX|dkrLddlm}|rZ|j|ƒ}||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¤)rZhintsÚhandlerrrrr£ s   r£cCsv|jƒ}|\}}y.|||f}t||ƒ|kr0dS||||f<Wnttfk rVdSX||fh} tƒ} �x| �rptƒ} xì| D]ä\}}xÚ|d|f|d|f||df||dffD]ª\} } | | f| ks´| dks´| dkrÚq´y|| | f}Wnttfk �rYq´X| j| | fƒ|dk�r.t||ƒ|k}n||k�o>||k}|r´||| | f<| j| | fƒq´Wq~W| } | } qlWdS)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)Úimager)ÚvalueZborderZthreshZpixelrErFZ backgroundZedgeZ full_edgeZnew_edgeÚsÚtr?rrrrÚ floodfill$s<   6  r±cst|tƒstdƒ‚|dkr"tdƒ‚t|ttfƒs8tdƒ‚t|ƒdkrP|�^‰‰nt|ƒdkrf|\‰‰ntdƒ‚tdd„ˆˆf˜DƒƒsŽtd ƒ‚tˆƒdks¢td ƒ‚ˆd kr²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 intrJzn_sides should be an int > 2z!bounding_circle should be a tupler4z[bounding_circle should contain 2D coordinates and a radius (e.g. (x, y, r) or ((x, y), r) )css|]}t|ttfƒVqdS)N)r#ÚintÚfloat)r6r7rrrú ˜sz4_compute_regular_polygon_vertices..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 floatcSsŒt|dtjtjd|ƒƒ|dtjtjd|ƒƒ|ddƒt|dtjtjd|ƒƒ|dtjtjd|ƒƒ|ddƒfS)Nrihrr4)Úroundr9r@rArB)rPr:ÚcentroidrrrÚ_apply_rotation¨s >>z:_compute_regular_polygon_vertices.._apply_rotationcs|dg}ˆ|||ƒS)Nrr)r¶Úpolygon_radiusrDZ start_point)r·rrÚ_compute_polygon_vertex¸szB_compute_regular_polygon_vertices.._compute_polygon_vertexcSsVg}d|}dd||}x4td|ƒD]&}|j|ƒ||7}|dkr(|d8}q(W|S)Nihigà?r)rLr�)rXrYrQr:Z current_angleÚ_rrrÚ _get_angles¼s  z6_compute_regular_polygon_vertices.._get_anglescsg|]}ˆˆˆ|ƒ‘qSrr)r6rD)r¹r¶r¸rrr8Ísz5_compute_regular_polygon_vertices..) r#r²rzrrKr5rMÚallr³)rWrXrYr»rQr)r·r¹r¶r¸rrV\s4)        rVcs<tˆtƒr,t‡‡fdd„tdtˆƒƒDƒƒStˆˆƒSdS)zJ Uses 1-norm distance to calculate difference between two values. cs g|]}tˆ|ˆ|ƒ‘qSr)Úabs)r6r7)Úcolor1Úcolor2rrr8Ösz_color_diff..rN)r#r5ÚsumrLrMr½)r¾r¿r)r¾r¿rr©Ñs "r©)N)NN)Nr)r9r%r!rrrrr¤rr0ZOutlineryr£r±rVr©rrrrÚ!s" K     8u