+
    UBi                    F  a  0 t $ ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^RI	H
t
HtHt Rt]'       d%   ^ RIHt ^ RIHt ^ R	IHtHt ^R
I	HtHt ^RIHtHt ]
P0                  P2                  tR]R&     ! R R4      tRR R lltRR R lltRR R lltR R lt R R lt!R# )    )annotationsN)Sequence)cast)Image
ImageColor	ImageTextF)Callable)
ModuleType)AnyAnyStr)
ImageDraw2	ImageFont)Coords_Inkz!Callable[[], Image.core._Outline]Outlinec                     ] tR t^=t$ RtR]R&   R3R R lltR R ltR R	 ltR3R
 R llt	R4R R llt
R3R R lltR5R R lltR5R R lltR5R R lltR6R R lltR7R R lltR5R R lltR3R R lltR5R R lltR8R  R! lltR5R" R# lltR8R$R/R% R& llltR9R' R( lltR9R)R/R* R+ llltR:R)R/R, R- llltR;R)R/R. R/ llltR;R)R/R0 R1 llltR2tR# )<	ImageDrawNNImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont | Nonefontc               $    V ^8  d   QhRRRRRR/# )   imImage.Imagemode
str | NonereturnNone )formats   "2/usr/lib/python3.14/site-packages/PIL/ImageDraw.py__annotate__ImageDraw.__annotate__B   s!     & &; &j &D &    c                \   VP                  4        ^ pVf   VP                  pW!P                  8w  d)   VR8X  d   VP                  R8X  d   ^pMRp\        V4      hVR8X  d   VP                  V n        MRV n        Wn        VP
                  V n        \        P                  P                  V P
                  V4      V n        W n        VR	9   d"   V P                  P                  ^4      V n
        M V P                  P                  R
4      V n
        VR9   d	   RV n        MRV n        RV n        R# )aX  
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.
NRGBARGBzmode mismatchP1LF)IF)r(   r'   r*   r+   )_ensure_mutabler   
ValueErrorpalette_imager   r   coredrawdraw_inkinkfontmodefill)selfr   r   blendmsgs   &&&  r    __init__ImageDraw.__init__B   s     	<77D77?v~"''U"2% o%3;::DLDL%%JJOODGGU3		:yy))!,DHyy))"-DH''DMDM	r#   c                   V ^8  d   QhRR/# )r   r   GImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFontr   )r   s   "r    r!   r"   j   s      	Pr#   c                v    V P                   '       g   ^RIHp VP                  ! 4       V n         V P                   # )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   load_default)r7   r   s   & r    getfontImageDraw.getfontj   s*    ( yyy#!..0DIyyr#   c                    V ^8  d   QhRRRR/# )r   	font_sizefloat | Noner   r=   r   )r   s   "r    r!   r"      s     " "%"	P"r#   c                	Z    Ve   ^RI Hp VP                  ! V4      # V P                  4       # )Nr?   )r@   r   rA   rB   )r7   rE   r   s   && r    _getfontImageDraw._getfont   s*      #)))44<<>!r#   c               $    V ^8  d   QhRRRRRR/# )r   r4   _Ink | Noner6   r   ztuple[int | None, int | None]r   )r   s   "r    r!   r"      s$     ' ''&1'	&'r#   c                	
   R pR pVf6   Vf2   V P                   '       d   V P                  pW43# V P                  p W43# Ve   \        V\        4      '       d!   \        P
                  ! WP                  4      pV P                  '       d<   \        V\        4      '       d&   V P                  P                  WP                  4      pV P                  P                  V4      pVe   \        V\        4      '       d!   \        P
                  ! W P                  4      pV P                  '       d<   \        V\        4      '       d&   V P                  P                  W P                  4      pV P                  P                  V4      pW43# N)r6   r4   
isinstancestrr   getcolorr   r/   tupler0   r2   r3   )r7   r4   r6   
result_inkresult_fills   &&&  r    _getinkImageDraw._getink   s$    
;4<yyy"hh  && "XX
 && c3''$--c99=C<<<JsE$:$:,,//[[AC!YY//4
dC((%..tYY?D<<<JtU$;$;<<00{{CD"ii006&&r#   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   xyr   startfloatendr6   rK   widthintr   r   r   )r   s   "r    r!   r"      sF     ; ;; ; 	;
 ; ; 
;r#   c                r    V P                  V4      w  rdVe    V P                  P                  WW6V4       R# R# )zDraw an arc.N)rT   r2   draw_arc)r7   rW   rX   rZ   r6   r[   r4   s   &&&&&& r    arcImageDraw.arc   s4     LL&	?IIr#E: r#   c               (    V ^8  d   QhRRRRRRRR/# )	r   rW   zSequence[int]bitmapr   r6   rK   r   r   r   )r   s   "r    r!   r"      s,     	6 	6	6)4	6<G	6		6r#   c                    VP                  4        V P                  V4      w  rCVf   TpVe)   V P                  P                  WP                  V4       R# R# )zDraw a bitmap.N)loadrT   r2   draw_bitmapr   )r7   rW   rb   r6   r4   s   &&&& r    rb   ImageDraw.bitmap   sI     	LL&	;C?II!!"ii5 r#   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# r   rW   r   rX   rY   rZ   r6   rK   outliner[   r\   r   r   r   )r   s   "r    r!   r"      sY     @ @@ @ 	@
 @ @ @ 
@r#   c                    V P                  WT4      w  rxVe   V P                  P                  WW8^4       Ve2   Wx8w  d*   V^ 8w  d!   V P                  P                  WW7^ V4       R# R# R# R# )zDraw a chord.N)rT   r2   
draw_chord	r7   rW   rX   rZ   r6   ri   r[   r4   fill_inks	   &&&&&&&  r    chordImageDraw.chord   s`     W3II  C1=?s5A:II  Ca? 4>?r#   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# 
r   rW   r   r6   rK   ri   r[   r\   r   r   r   )r   s   "r    r!   r"      s<     6 66 6 	6
 6 
6r#   c                    V P                  W24      w  rVVe   V P                  P                  W^4       Ve1   WV8w  d)   V^ 8w  d    V P                  P                  W^ V4       R# R# R# R# )zDraw an ellipse.N)rT   r2   draw_ellipser7   rW   r6   ri   r[   r4   rm   s   &&&&&  r    ellipseImageDraw.ellipse   s\     W3II""23?s5A:II""2Au5 4>?r#   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   rW   Sequence[float]radiusrY   r6   rK   ri   r[   r\   r   r   r   )r   s   "r    r!   r"      sF     
7 
7
7 
7 	
7
 
7 
7 

7r#   c                    V^ ,          V,
          V^,          V,
          V^ ,          V,           V^,          V,           3pV P                  WcWE4       R# )z4Draw a circle given center coordinates and a radius.N)ru   )r7   rW   ry   r6   ri   r[   
ellipse_xys   &&&&&& r    circleImageDraw.circle   s@     efnbefnbefnbefnU
Zw6r#   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   rW   r   r6   rK   r[   r\   jointr   r   r   r   )r   s   "r    r!   r"      sC     K= K=K= K= 	K=
 K= 
K=r#   c                L  a V P                  V4      ^ ,          pVEe{   V P                  P                  WS4       VR8X  EdU   S^8  EdK   \        V^ ,          \        \
        34      '       d(   \        \        \        \        ,          ,          V4      pMP\        ^ \        V4      ^4       Uu. uF0  p\        \        \        ,          \        WV^,            4      4      NK2  	  pp\        ^\        V4      ^,
          4       EF  pWg,          pWg^,
          ,          V3WV^,           ,          33 U	U
u. uFa  w  r\        P                  ! \        P                  ! V
^ ,          V	^ ,          ,
          V	^,          V
^,          ,
          4      4      R,          NKc  	  pp	p
V^ ,          V^,          8X  d   K  R V3R llpV^,          V^ ,          8  ;'       d#    V^,          ^,
          V^ ,          8  ;'       g6    V^,          V^ ,          8  ;'       d    V^,          ^,           V^ ,          8  pV^ ,          S^,          ,
          ^,           V^,          S^,          ,
          ^,           3V^ ,          S^,          ,           ^,
          V^,          S^,          ,           ^,
          3.pV'       d!   V^,          ^Z,           V^ ,          ^Z,           rMV^ ,          ^Z,
          V^,          ^Z,
          rV P                  W^Z,
          V
^Z,
          V4       S^8  g   EK  V'       d/   V! W^ ,          ^Z,           4      VV! W^,          ^Z,           4      .pM-V! W^ ,          ^Z,
          4      VV! W^,          ^Z,
          4      .pV P                  W^R7       EK  	  R# R# R# R# u upi u up
p	i )z6Draw a line, or a connected sequence of line segments.Ncurveh  c               $    V ^8  d   QhRRRRRR/# )r   coordrx   anglerY   r   ztuple[float, ...]r   )r   s   "r    r!   $ImageDraw.line.<locals>.__annotate__  s$      .7<*r#   c                  < V w  r#V^Z,          pS^,          ^,
          p\         ;QJ dv    . R W$\        P                  ! \        P                  ! V4      4      ,          3W4\        P                  ! \        P                  ! V4      4      ,          33 4       F  NK  	  5# ! R W$\        P                  ! \        P                  ! V4      4      ,          3W4\        P                  ! \        P                  ! V4      4      ,          33 4       4      # )Z   c              3     "   T F@  w  rY^ 8  d   \         P                  ! V4      M\         P                  ! V4      ,           x  KB  	  R# 5i)r   N)mathfloorceil).0pp_ds   &  r    	<genexpr>9ImageDraw.line.<locals>.coord_at_angle.<locals>.<genexpr>  s;      %+ !GC3PP+s   AA
)rQ   r   cosradianssin)r   r   xydistancer[   s   &&   r    coord_at_angle&ImageDraw.line.<locals>.coord_at_angle  s      %#(19q=$u % "#txxU8K/L$L M!"txxU8K/L$L M+%u u % "#txxU8K/L$L M!"txxU8K/L$L M+%   r#   )r[   )rT   r2   
draw_linesrN   listrQ   r   r   rY   rangelenr   degreesatan2piesliceline)r7   rW   r6   r[   r   r4   pointsipointrX   rZ   anglesr   flippedcoords
gap_coordss   &&&f&           r    r   ImageDraw.line   s    ll4 #?II  %0EAIbedE]33!(8E?";R@F "'q#b'1!5!5A Xe_eB1q5M.BC!5   q#f+/2A"IE
 $E]E2"1q5M2++JE TZZAq0A58cRSfCT%UV +   ayF1I-   q	F1I-MM&)c/F1I2MQ Q )fQi/OOF1IOfQi4O  qEAI-158eai3G!3KLqEAI-158eai3G!3KLF &,Qi"nfQi"ns&,Qi"nfQi"nsMM&"*cBhEqy" .uQi"n E % .uQi"n E*J !/uQi"n E % .uQi"n E*J
 		*!	<o 3 %. s   -6N2A'N c               (    V ^8  d   QhRRRRRRRR/# )r   shapezImage.core._Outliner6   rK   ri   r   r   r   )r   s   "r    r!   r"   7  s2     2 2"2 2 	2
 
2r#   c                    VP                  4        V P                  W24      w  rEVe   V P                  P                  W^4       Ve'   WE8w  d   V P                  P                  W^ 4       R# R# R# )z(Experimental) Draw a shape.N)closerT   r2   draw_outline)r7   r   r6   ri   r4   rm   s   &&&&  r    r   ImageDraw.shape7  s[     	W3II""5A6?sII""5q1  /?r#   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# rh   r   )r   s   "r    r!   r"   E  sY     C CC C 	C
 C C C 
Cr#   c                    V P                  WT4      w  rxVe   V P                  P                  WW8^4       Ve2   Wx8w  d*   V^ 8w  d!   V P                  P                  WW7^ V4       R# R# R# R# )zDraw a pieslice.N)rT   r2   draw_pieslicerl   s	   &&&&&&&  r    r   ImageDraw.piesliceE  s`     W3II##Bsa@?s5A:II##BsEB 4>?r#   c               $    V ^8  d   QhRRRRRR/# )r   rW   r   r6   rK   r   r   r   )r   s   "r    r!   r"   U  s!     + + +k +T +r#   c                n    V P                  V4      w  r2Ve   V P                  P                  W4       R# R# )z#Draw one or more individual pixels.N)rT   r2   draw_points)r7   rW   r6   r4   s   &&& r    r   ImageDraw.pointU  s.    LL&	?II!!"* r#   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# rq   r   )r   s   "r    r!   r"   [  sC     K KK K 	K
 K 
Kr#   c                F   V P                  W24      w  rVVe   V P                  P                  W^4       Ve   WV8w  d   V^ 8w  d   V^8X  d    V P                  P                  W^ V4       R# V P                  e   \        P
                  ! RV P                  P                  4      pV P                  ^4      ^ ,          p\        V4      p	V	P                  P                  W^4       V P                  P                  W^ V^,          ^,
          VP                  4       R# R# R# R# R# )zDraw a polygon.Nr(   )rT   r2   draw_polygonr   r   newsizeDraw)
r7   rW   r6   ri   r[   r4   rm   maskmask_inkr2   s
   &&&&&     r    polygonImageDraw.polygon[  s     W3II""23?s5A:z		&&r59$ yydggll3<<?1-Dz		&&rQ7		&&r519q=$''J % 4>?r#   c               4    V ^8  d   QhRRRRRRRRR	RR
RRR/# )r   bounding_circle!Sequence[Sequence[float] | float]n_sidesr\   rotationrY   r6   rK   ri   r[   r   r   r   )r   s   "r    r!   r"   s  sP     / /:/ / 	/
 / / / 
/r#   c                B    \        WV4      pV P                  WtWV4       R# )zDraw a regular polygon.N)!_compute_regular_polygon_verticesr   )r7   r   r   r   r6   ri   r[   rW   s   &&&&&&& r    regular_polygonImageDraw.regular_polygons  s     /RRw.r#   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# rq   r   )r   s   "r    r!   r"     s<     8 88 8 	8
 8 
8r#   c                    V P                  W24      w  rVVe   V P                  P                  W^4       Ve1   WV8w  d)   V^ 8w  d    V P                  P                  W^ V4       R# R# R# R# )zDraw a rectangle.N)rT   r2   draw_rectanglert   s   &&&&&  r    	rectangleImageDraw.rectangle  s\     W3II$$R15?s5A:II$$Ra7 4>?r#   cornersc               4    V ^8  d   QhRRRRRRRRRR	R
RRR/# )r   rW   r   ry   rY   r6   rK   ri   r[   r\   r   z$tuple[bool, bool, bool, bool] | Noner   r   r   )r   s   "r    r!   r"     sY     J8 J8J8 J8 	J8
 J8 J8 6J8 
J8r#   c                 a aaaaaaaaaaa \        V^ ,          \        \        34      '       d1   \        \        \        \
        ,          ,          V4      w  w  oow  ooM \        \        \
        ,          V4      w  ooooSS8  d   Rp\        V4      hSS8  d   Rp\        V4      hSf   RoV^,          o\        S4      o\        S4      o\        S4      o\        S4      oRRuoo\        S4      '       dl   SSS,
          ^,
          8  oS'       d
   SS,
          oSSS,
          ^,
          8  oS'       d
   SS,
          oS'       d   S'       d   S P                  WVS4      # S^ 8X  g   \        S4      '       g   S P                  WVS4      # \        S^,          4      pS P                  WC4      w  ooR VVVVVVV VVVVV3R llp	SEe   V	! R4       S'       d?   S P                  P                  SSV,           ^,           SSV,
          ^,
          3S^4       M`SV,
          ^,
          SV,           ^,           8  d>   S P                  P                  SV,           ^,           SSV,
          ^,
          S3S^4       S'       Eg
   S'       Eg   SSSV,           S.p
S^ ,          '       d   V
^;;,          V^,           ,          uu&   S^,          '       d   V
^;;,          V^,           ,          uu&   S P                  P                  V
S^4       SV,
          SSS.pS^,          '       d   V^;;,          V^,           ,          uu&   S^,          '       d   V^;;,          V^,           ,          uu&   S P                  P                  VS^4       SEeO   SS8w  EdE   S^ 8w  Ed;   V	! R4       S'       Eg   SSSSS,           ^,
          .pS^ ,          '       d   V^ ;;,          V^,           ,          uu&   S^,          '       d   V^;;,          V^,           ,          uu&   S P                  P                  VS^4       SSS,
          ^,           SS.pS^,          '       d   V^ ;;,          V^,           ,          uu&   S^,          '       d   V^;;,          V^,           ,          uu&   S P                  P                  VS^4       S'       Eg   SSSS,           ^,
          S.p
S^ ,          '       d   V
^;;,          V^,           ,          uu&   S^,          '       d   V
^;;,          V^,           ,          uu&   S P                  P                  V
S^4       SS,
          ^,           SSS.pS^,          '       d   V^;;,          V^,           ,          uu&   S^,          '       d   V^;;,          V^,           ,          uu&   S P                  P                  VS^4       R# R# R# R# R# )	zDraw a rounded rectangle.z&x1 must be greater than or equal to x0z&y1 must be greater than or equal to y0NTFc                    V ^8  d   QhRRRR/# )r   r   boolr   r   r   )r   s   "r    r!   1ImageDraw.rounded_rectangle.<locals>.__annotate__  s      	?  	?4  	?D  	?r#   c                  < S'       d1   SSSS,           SS,           3^R3SSS,
          SS,           S3^ ^33pEM+S'       d0   SSSS,           SS,           3^ZR3SS,
          SSSS,           3R^Z33pM\         ;QJ dx    . V3R l\        SSSS,           SS,           3^R3SS,
          SSSS,           3RR3SS,
          SS,
          SS3^ ^Z3SSS,
          SS,           S3^Z^334       4       F  NK  	  5Mq! V3R l\        SSSS,           SS,           3^R3SS,
          SSSS,           3RR3SS,
          SS,
          SS3^ ^Z3SSS,
          SS,           S3^Z^334       4       4      pV FS  pV '       d&   S	P                  P                  ! VS^3,           !   K0  S	P                  P                  ! VSS
3,           !   KU  	  R# )   r     c              3  N   <"   T F  w  rSV,          '       g   K  Vx  K  	  R # 5irM   r   )r   r   partr   s   &  r    r   DImageDraw.rounded_rectangle.<locals>.draw_corners.<locals>.<genexpr>  s+      $ qzz D$s   %
%N)rQ   	enumerater2   r   r^   )r   partsr   r   drm   full_xfull_yr4   r7   r[   x0x1y0y1s   &  r    draw_corners1ImageDraw.rounded_rectangle.<locals>.draw_corners  s    "b1fb1f-sC8"q&"q&"-q#6  "b1fb1f-r371fb"b1f-sB7  #, "b1fb1f5sC@ 1fb"b1f5sC@ 1fb1fb"5q"= "q&"q&"5r3?	$ #, "b1fb1f5sC@ 1fb"b1f5sC@ 1fb1fb"5q"= "q&"q&"5r3?	$  II++dh].BDII&&e)<>	 r#   )TTTT)rN   r   rQ   r   r   rY   r.   roundallru   anyr   r\   rT   r2   r   )r7   rW   ry   r6   ri   r[   r   r9   rr   leftrighttopbottomr   rm   r   r   r4   r   r   r   r   s   f&&&&fd       @@@@@@@@@r    rounded_rectangleImageDraw.rounded_rectangle  sz    bedE]++!%hx&?!DHRhr2!(5/26NBB7:CS/!7:CS/!?.GQJ2Y2Y2Y2Yw<<"r'A+%FG"r'A+%FG&||Bgu==6W >>"GU;;QKW3X 	?  	?  	?D 		(("b1fqj"b1fqj)I8UVWa!b1fqj(		(("q&1*b"q&1*b)I8UVW6&&BQ+1::Gq1u$G1::Gq1u$G		((x;aR,1::!HA%H1::!HA%H		((!<?sh5A:62r2:>21::Fa!eOF1::Fa!eOF		((c15b5j1nb"51::1IQ&I1::1IQ&I		((a86BU
Q31::Gq1u$G1::Gq1u$G		((sA6eaR41::!HA%H1::!HA%H		((Q7 # 4>?r#   c                X    V ^8  d   QhRRRRRRRRR	R
RRRRRR
RRRR
RRRRRRRRRRRR/# )r   rW   tuple[float, float]textzAnyStr | ImageText.Textr6   rK   r   r   anchorr   spacingrY   alignrO   	directionfeatureslist[str] | Nonelanguagestroke_widthstroke_fillembedded_colorr   argsr   kwargsr   r   r   )r   s   "r    r!   r"     s     { {{ &{ 	{{ { { { { #{  !{" #{$ !%{& '{( ){* +{, 
-{r#   c                  a aaaa	a
aaaaa \        V\        P                  4      '       d   VoMzVf!   S P                  SP	                  R4      4      p\        P                  ! W$S P
                  VSS	S
4      oS'       d   SP                  4        V'       d   SP                  W4       R V 3R llpV! V4      pVf   R# RpSP                  '       d#   SP                  e   V! SP                  4      MTpSP                  SSV4       FN  w  oooRR VVVVV	VVV
VV V3R lllpVe'   V! VSP                  4       VV8w  d   V! V4       KD  KF  V! V4       KP  	  R# )z
Draw text.NrE   c                    V ^8  d   QhRRRR/# )r   r6   rK   r   r\   r   )r   s   "r    r!   $ImageDraw.text.<locals>.__annotate__?  s     	 	 	 	r#   c                F   < SP                  V 4      w  rVf	   Vf   Q hV# V# rM   )rT   )r6   r4   rm   r7   s   &  r    getinkImageDraw.text.<locals>.getink?  s.     LL.MC{+++Jr#   c               $    V ^8  d   QhRRRRRR/# )r   r4   r\   r   rY   r   r   r   )r   s   "r    r!   r  T  s!     6< 6<s 6<% 6< 6<r#   c                d  < SP                   pV^ 8X  d   S'       d   Rp. p\        ^4       F$  pVP                  \        SV,          4      4       K&  	  \        P
                  ! S^ ,          4      ^ ,          \        P
                  ! S^,          4      ^ ,          3p SP                  P                  ! SV.SO5RSRSRSRVRRRSR	V R
V/SB w  rgV^ ,          V^ ,          ,           V^,          V^,          ,           .pTR8X  d   YfP                  ^4      rh\        P                  ! RT 4      ^,          p	TP                  ^T	4       Tw  rSP                  eQ   SP                  P!                  YYTP"                  ^ ,          ,           YP"                  ^,          ,           3T4       R# R# SP$                  P'                  Y6T 4       R#   \         d]     SP                  P                  ! STSSSTST .SO5R
T/SB p EL  \         d!    SP                  P                  S4      p  EL,i ; ii ; i)r   r%   r   r   r   r   stroke_filledTr   r4   rX   r   N)r5   r   appendr\   r   modfr   getmask2AttributeErrorgetmask	TypeErrorgetbandstructpackfillbandr   paster   r2   re   )r4   r   r   r   r   rX   r   offsetcolor	ink_alphar   r   r   r   r   r   r   
image_textr   r   r   r7   rW   s   &&          r    	draw_text!ImageDraw.text.<locals>.draw_textT  s;   }}1$!DqALLRU, "2a5)!,dii1.>q.AB =#-??#;#;$ $ #,$ "*	$
 "*$ &2$ '+$  &$  $ $$ !$LD #1Xq	158fQi3GHE$ 6> #'Q4 &C 5a 8INN1i0 DAww*!qdiil*:A		!<L#Mt +
 II))%s;= & ==)66  %$$("  "  #(  %  % =)66t<==s+   A!G H/)H  &H+&H/*H++H/r   )rN   r   TextrH   getr   embed_colorstroker   r   _split)r7   rW   r   r6   r   r   r   r   r   r   r   r   r   r   r   r   r  r4   
stroke_inkr  r  r   s   ff&&&f&&fff&&fjl    @@r    r   ImageDraw.text  s8   0 dINN++J|}}VZZ%<="DIIw	8XJ &&(!!,<	 	 Tl;
""" ))5 z--.  !+ 1 1"fe DB6< 6< 6<p %*j&=&=> *$cN % #G !Er#   rE   c               T    V ^8  d   QhRRRRRRRRR	R
RRRRRR
RRRR
RRRRRRRRRR/# )r   rW   r   r   r   r6   rK   r   r   r   r   r   rY   r   rO   r   r   r   r   r   r   r   r   rE   rF   r   r   r   )r   s   "r    r!   r"     s     &
 &
&
 &
 	&
&
 &
 &
 &
 &
 #&
  !&
" #&
$ !%&
& '&
*  +&
, 
-&
r#   c               	@    V P                  VVVVVVVVV	V
VVVVR 7      # )rE   )r   )r7   rW   r   r6   r   r   r   r   r   r   r   r   r   r   rE   s   &&&&&&&&&&&&&&$r    multiline_textImageDraw.multiline_text  sD    . yy  
 	
r#   c               8    V ^8  d   QhRRRRRRRRR	RR
RRRRR/# )r   r   r   r   r   r   r   r   r   r   r   r   rE   rF   r   rY   r   )r   s   "r    r!   r"     sZ     ' ''	' ' #' ' '  ' 
'r#   c          	         Vf   V P                  V4      p\        P                  ! VVV P                  VVVR7      pV'       d   VP	                  4        VP                  4       # )z@Get the length of a given string, in pixels with 1/64 precision.)r   r   r   )rH   r   r  r   r  
get_length)	r7   r   r   r   r   r   r   rE   r  s	   &&&&&&&$ r    
textlengthImageDraw.textlength  s[    " <==+D^^II

 ""$$$&&r#   c               L    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRR
RRRRRR/# r   rW   r   r   r   r   r   r   r   r   rY   r   rO   r   r   r   r   r   r   r   rE   rF   r   z!tuple[float, float, float, float]r   )r   s   "r    r!   r"     s     6 66 6
6 6 6 6 6 #6 6  !6" #6&  '6( 
+)6r#   c          	         Vf   V P                  V4      p\        P                  ! W#V P                  WWW4      pV'       d   VP	                  4        V
'       d   VP                  V
4       VP                  WV4      # )z2Get the bounding box of a given string, in pixels.)rH   r   r  r   r  r  get_bbox)r7   rW   r   r   r   r   r   r   r   r   r   r   rE   r  s   &&&&&&&&&&&&$ r    textbboxImageDraw.textbbox  sg    , <==+D^^		7x

 ""$l+""2u55r#   c               L    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRR
RRRRRR/# r-  r   )r   s   "r    r!   r"     s     "
 "
"
 "

"
 "
 "
 "
 "
 #"
 "
  !"
" #"
&  '"
( 
+)"
r#   c               	<    V P                  VVVVVVVVV	V
VVR 7      # r$  )r0  )r7   rW   r   r   r   r   r   r   r   r   r   r   rE   s   &&&&&&&&&&&&$r    multiline_textbboxImageDraw.multiline_textbbox  s>    * }}  
 	
r#   )	r0   r2   r6   r   r5   r   r4   r   r/   rM   )N   )NNr6  )Nr   N)NN)r   NNr6  )NNN   r   NNNr   NF)NNNNF)	NNr7  r   NNNr   F)__name__
__module____qualname____firstlineno__r   __annotations__r:   rB   rH   rT   r_   rb   rn   ru   r|   r   r   r   r   r   r   r   r   r   r%  r*  r0  r4  __static_attributes__r   r#   r    r   r   =   s     	 	V&P6"'2;	6@ 6
7K=Z2C +K0/8J8 9=J8 J8X{z&
* #'+&
 &
P' #'' '>6& #''6 6B"
& #''"
 "
r#   r   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   r   r   )r   s   "r    r!   r!   $  s!     # #[ #
 #i #r#   c                `     \        V R4      ! V4      #   \         d    \        Y4      u # i ; i)ak  
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   &&r    r   r   $  s3    #r9%d++ #""#s    --c                    V ^8  d   QhRRRR/# )r   r   zImage.Image | Noner   z)tuple[ImageDraw2.Draw | None, ModuleType]r   )r   s   "r    r!   r!   5  s      " .W r#   c                D    ^RI Hp V e   VP                  ! V 4      MRpW!3# )za
:param im: The image to draw in.
:returns: A (drawing context, drawing resource factory) tuple.
)r   N)r@   r   r   )r   r   r2   s   &  r    r@  r@  5  s$    
 "$.:??2dDr#   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r   imager   rW   ztuple[int, int]valuefloat | tuple[int, ...]borderzfloat | tuple[int, ...] | NonethreshrY   r   r   r   )r   s   "r    r!   r!   @  sD     > >>> #> +	>
 > 
>r#   c                   V P                  4       pVf   Q hVw  rg WVV3,          p\        W(4      V8:  d   R# W%Wg3&   Yg30p	\	        4       p
T	'       d   \	        4       pT	 F  w  rgT^,           T3T^,
          T3Yg^,           3Yg^,
          33 Ft  w  rY3T
9   g   T^ 8  g   T^ 8  d   K   Y\T3,          pT
P                  Y34       Tf   \        Y4      T8*  pMYT39  pT'       d   Y%Y3&   TP                  Y34       Kt  Kv  	  K  	  T	p
Tp	K  R#   \        \        3 d     R# i ; i  \        \        3 d     K  i ; i)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.
N)rd   _color_diffr.   
IndexErrorsetadd)rE  rW   rF  rH  rI  pixelr   r   
backgroundedge	full_edgenew_edgestr   r6   s   &&&&&           r    	floodfillrV  @  sa   6 JJLEDAa4[
u)V3ad F8D I
5DAa%a!eQZ!UaQZH6Y&!a%1q5-dA MM1&)~*19VC 7&+ad aV,  I $ 	+  
#  #J/ s(   D D *
D(D%$D%(D=<D=c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   r   r\   r   rY   r   zlist[tuple[float, float]]r   )r   s   "r    r!   r!     s8     @ @6@AD@PU@@r#   c                  aa	a
 \        V\        4      '       g   Rp\        V4      hV^8  d   Rp\        V4      h\        V \        \
        34      '       g   Rp\        V4      h\        V 4      ^8X  dq   \        ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      '       g   Rp\        V4      h\        \        \        ,          \	        V 4      4      Ev o	o
EM \        V 4      ^8X  Ed   \        V ^ ,          \        \
        34      '       d   \        ;QJ d#    R V ^ ,           4       F  '       d   K   RM	  RM! R V ^ ,           4       4      '       d$   \        V ^,          \        \        34      '       g   Rp\        V4      h\        V ^ ,          4      ^8w  d   R	p\        V4      h\        \        \        ,          \	        V ^ ,          4      4      o	\        \        V ^,          4      o
MR
p\        V4      hS
^ 8:  d   Rp\        V4      h\        V\        \        34      '       g   Rp\        V4      hR V	3R lloR VV
3R llpR R lpV! W4      pV Uu. uF
  qt! V4      NK  	  up# u upi )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
zn_sides should be an intzn_sides should be an int > 2z$bounding_circle should be a sequencec              3  N   "   T F  p\        V\        \        34      x  K  	  R # 5irM   rN   r\   rY   r   r   s   & r    r   4_compute_regular_polygon_vertices.<locals>.<genexpr>  s     H1:a#u..   #%FTz0bounding_circle should only contain numeric datac              3  N   "   T F  p\        V\        \        34      x  K  	  R # 5irM   rZ  r[  s   & r    r   r\    s"      
1CAJq3,''1Cr]  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               $    V ^8  d   QhRRRRRR/# )r   r   list[float]r   rY   r   r   r   )r   s   "r    r!   7_compute_regular_polygon_vertices.<locals>.__annotate__  s"     
 
{ 
U 
?R 
r#   c                p  < \        V ^ ,          \        P                  ! \        P                  ! RV,
          4      4      ,          V ^,          \        P                  ! \        P                  ! RV,
          4      4      ,          ,
          S^ ,          ,           ^4      \        V ^,          \        P                  ! \        P                  ! RV,
          4      4      ,          V ^ ,          \        P                  ! \        P                  ! RV,
          4      4      ,          ,           S^,          ,           ^4      3# )r   r   )r   r   r   r   r   )r   r   centroids   &&r    _apply_rotation:_compute_regular_polygon_vertices.<locals>._apply_rotation  s    a488DLLw$?@@(TXXdll3=&ABBC1+ 	 a488DLLw$?@@(TXXdll3=&ABBC1+ 	
 	
r#   c                    V ^8  d   QhRRRR/# )r   r   rY   r   r   r   )r   s   "r    r!   ra    s     3 3u 31D 3r#   c                   < S^ .pS! W4      # r  r   )r   start_pointrd  polygon_radiuss   & r    _compute_polygon_vertexB_compute_regular_polygon_vertices.<locals>._compute_polygon_vertex  s    %q){22r#   c               $    V ^8  d   QhRRRRRR/# )r   r   r\   r   rY   r   r`  r   )r   s   "r    r!   ra    s!     
 
S 
E 
k 
r#   c                    . pR V ,          pRRV,          ,
          V,           p\        V 4       F.  pVP                  V4       WC,          pVR 8  g   K%  VR ,          pK0  	  V# )r   r   g      ?)r   r	  )r   r   r   r   current_angle_s   &&    r    _get_angles6_compute_regular_polygon_vertices.<locals>._get_angles  s^    -sW},8wAMM-($Ms"$	  
 r#   )
rN   r\   r  r.   r   rQ   r   r   r   rY   )r   r   r   r9   rj  rp  r   r   rd  rc  ri  s   &&&     @@@r    r   r     s   V gs##(n{,o oe}554n
?q sHHsssHHHHDCS/!$(ed?6K$L!>	_		"z/!2DtUm'T'Ts 
1@1C
sss 
1@1C
 
 
OA.e==DCS/!q!"a'VCS/!UT/!*<%=>e_Q%78< 	 o4o he--2o
 
 3 3
 +F 9??u#E*???s   &I9c               $    V ^8  d   QhRRRRRR/# )r   color1rG  color2r   rY   r   )r   s   "r    r!   r!     s)     	F 	F#	F-D	F
	Fr#   c                   aa \        V \        4      '       d   T MV 3o\        V\        4      '       d   TMV3o\        VV3R l\        \	        S4      4       4       4      # )zB
Uses 1-norm distance to calculate difference between two values.
c              3  d   <"   T F%  p\        SV,          SV,          ,
          4      x  K'  	  R # 5irM   )abs)r   r   firstseconds   & r    r   _color_diff.<locals>.<genexpr>  s(     E2DQs58fQi'((2Ds   -0)rN   rQ   sumr   r   )rs  rt  rx  ry  s   &&@@r    rK  rK    sI     !//FfYE!&%00VviFE%F2DEEEr#   rM   )Nr   )"__conditional_annotations__
__future__r   r   r  collections.abcr   typingr   r@   r   r   r   TYPE_CHECKINGr	   typesr
   r   r   r   r   _typingr   r   r1   ri   r   r<  r   r   r@  rV  r   rK  )r|  s   @r    <module>r     s   @ # "   $  * *( "'% .3ZZ-?-?	* ?d
 d
N#">B@D	Fr#   