
    h-&                         S SK Jr  S SKJrJr  S SKJr  \(       a  S SKJr  S SK	J
r
  Sr " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)    )TYPE_CHECKING)Image	ImageDraw)QRModuleDrawer)StyledPilImage)ActiveWithNeighbors   c                   $    \ rS rSr% SrS\S'   Srg)StyledPilQRModuleDrawer   z
A base class for StyledPilImage module drawers.

NOTE: the color that this draws in should be whatever is equivalent to
black in the color space, and the specified QRColorMask will handle adding
colors as necessary to the image
r   img N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       m/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/qrcode/image/styles/moduledrawers/pil.pyr   r      s     
r   r   c                   :   ^  \ rS rSrSrU 4S jrS\4S jrSrU =r	$ )SquareModuleDrawer   z%
Draws the modules as simple squares
c                    > [         TU ]  " U0 UD6  [        R                  " U R                  R
                  5      U l        g N)super
initializer   Drawr   _imgimgDrawselfargskwargs	__class__s      r   r   SquareModuleDrawer.initialize    s-    D+F+ ~~dhhmm4r   	is_activec                 n    U(       a.  U R                   R                  XR                  R                  S9  g g )Nfill)r!   	rectangler   paint_colorr#   boxr(   s      r   drawrectSquareModuleDrawer.drawrect$   s)    LL""3XX-A-A"B r   )r!   )
r   r   r   r   r   r   boolr0   r   __classcell__r&   s   @r   r   r      s!    5Ct C Cr   r   c                   D   ^  \ rS rSrSrSS jrU 4S jrS\4S jrSr	U =r
$ )	GappedSquareModuleDrawer)   z
Draws the modules as simple squares that are not contiguous.

The size_ratio determines how wide the squares are relative to the width of
the space they are printed in
c                     Xl         g r   )
size_ratio)r#   r9   s     r   __init__!GappedSquareModuleDrawer.__init__1   s    $r   c                    > [         TU ]  " U0 UD6  [        R                  " U R                  R
                  5      U l        SU R                  -
  U R                  R                  -  S-  U l	        g )N      )
r   r   r   r   r   r    r!   r9   box_sizedeltar"   s      r   r   #GappedSquareModuleDrawer.initialize4   sQ    D+F+ ~~dhhmm4$//)TXX->->>B
r   r(   c                    U(       a  US   S   U R                   -   US   S   U R                   -   US   S   U R                   -
  US   S   U R                   -
  4nU R                  R                  X0R                  R                  S9  g g )Nr   r=   r*   )r@   r!   r,   r   r-   )r#   r/   r(   smaller_boxs       r   r0   !GappedSquareModuleDrawer.drawrect9   s    Aq	DJJ&Aq	DJJ&Aq	DJJ&Aq	DJJ&	K LL"";XX5I5I"J r   )r@   r!   r9   g?)r   r   r   r   r   r:   r   r2   r0   r   r3   r4   s   @r   r6   r6   )   s'    %C
Kt K Kr   r6   c                   >   ^  \ rS rSrSrSrU 4S jrS\4S jrSr	U =r
$ )CircleModuleDrawerD   z
Draws the modules as circles
Nc                   > [         TU ]  " U0 UD6  U R                  R                  nU[        -  n[
        R                  " U R                  R                  XD4U R                  R                  R                  5      U l
        [        R                  " U R                  5      R                  SSXD4U R                  R                  S9  U R                  R                  X34[
        R                   R"                  5      U l
        g )Nr   r*   )r   r   r   r?   ANTIALIASING_FACTORr   newmode
color_mask
back_colorcircler   r   ellipser-   resize
ResamplingLANCZOS)r#   r$   r%   r?   	fake_sizer&   s        r   r   CircleModuleDrawer.initializeK   s    D+F+88$$22	iiHHMM"HH**

 	t{{#++9(txx/C/C 	, 	
 kk((()=u?O?O?W?WXr   r(   c                     U(       a?  U R                   R                  R                  U R                  US   S   US   S   45        g g Nr   r=   )r   r    pasterO   r.   s      r   r0   CircleModuleDrawer.drawrectY   s;    HHMMc!fQiQ-CD r   )rO   )r   r   r   r   r   rO   r   r2   r0   r   r3   r4   s   @r   rG   rG   D   s)     FYEt E Er   rG   c                   ^   ^  \ rS rSrSrSrSS jrU 4S jrS rS\	\	\
      SS	4S
 jrSrU =r$ )RoundedModuleDrawer^   a8  
Draws the modules with all 90 degree corners replaced with rounded edges.

radius_ratio determines the radius of the rounded edges - a value of 1
means that an isolated module will be drawn as a circle, while a value of 0
means that the radius of the rounded edge will be 0 (and thus back to 90
degrees again).
Tc                     Xl         g r   )radius_ratio)r#   r^   s     r   r:   RoundedModuleDrawer.__init__j   s    (r   c                    > [         TU ]  " U0 UD6  [        U R                  R                  S-  5      U l        U R                  5         g )Nr>   )r   r   intr   r?   corner_widthsetup_cornersr"   s      r   r   RoundedModuleDrawer.initializem   s=    D+F+ 1 1A 56r   c                    U R                   R                  nU R                   R                  R                  nU R                   R                  n[
        R                  " XR                  U R                  4U5      U l        U R                  [        -  nU R                  U-  nUS-  n[
        R                  " XU4U5      n[        R                  " U5      nUR                  SSXf4US9  UR                  USXD4US9  UR                  SXTU4US9  UR                  U R                  U R                  4[
        R                   R"                  5      U l        U R$                  R'                  [
        R(                  R*                  5      U l        U R$                  R'                  [
        R(                  R.                  5      U l        U R$                  R'                  [
        R(                  R2                  5      U l        g Nr>   r   r*   )r   rL   rM   rN   r-   r   rK   rb   SQUARErJ   r^   r   r   rP   r,   rQ   rR   rS   NW_ROUND	transpose	TransposeFLIP_TOP_BOTTOMSW_ROUND
ROTATE_180SE_ROUNDFLIP_LEFT_RIGHTNE_ROUND)	r#   rL   rN   front_color
fake_widthradiusdiameterbase	base_draws	            r   rc   !RoundedModuleDrawer.setup_cornersr   s   xx}}XX((33
hh**ii$$d&7&78+
 &&)<<
""Z/A:yyz*J
 NN4(	1a4;GVQ
?kRQJ?kR 1 12E4D4D4L4L
 //0O0OP//0J0JK//0O0OPr   r/   r(   r   c                 T   U(       d  g UR                   (       + =(       a    UR                  (       + nUR                  (       + =(       a    UR                  (       + nUR                  (       + =(       a    UR                  (       + nUR                  (       + =(       a    UR                   (       + nU(       a  U R                  OU R
                  nU(       a  U R                  OU R
                  nU(       a  U R                  OU R
                  n	U(       a  U R                  OU R
                  n
U R                  R                  R                  XqS   S   US   S   45        U R                  R                  R                  XS   S   U R                  -   US   S   45        U R                  R                  R                  XS   S   U R                  -   US   S   U R                  -   45        U R                  R                  R                  XS   S   US   S   U R                  -   45        g rW   )WNESrh   rg   rp   rn   rl   r   r    rX   rb   )r#   r/   r(   
nw_rounded
ne_rounded
se_rounded
sw_roundednwnesesws              r   r0   RoundedModuleDrawer.drawrect   s   "_8Y[[
"_8Y[[
"_8Y[[
"_8Y[[
(T]]dkk(T]]dkk(T]]dkk(T]]dkkBQCF1I 67BQT->->!>Aq	 JKQT...Aq	D<M<M0MN	
 	BQCF1I8I8I,I JKr   )rp   rh   rn   rg   rl   rb   r^   )r=   )r   r   r   r   r   needs_neighborsr:   r   rc   listra   r0   r   r3   r4   s   @r   r[   r[   ^   sD     O)
Q2LDcO L8M L Lr   r[   c                   J   ^  \ rS rSrSrSrS	S jrU 4S jrS rS
S jr	Sr
U =r$ )VerticalBarsDrawer   z
Draws vertically contiguous groups of modules as long rounded rectangles,
with gaps between neighboring bands (the size of these gaps is inversely
proportional to the horizontal_shrink).
Tc                     Xl         g r   )horizontal_shrink)r#   r   s     r   r:   VerticalBarsDrawer.__init__   s    !2r   c                    > [         TU ]  " U0 UD6  [        U R                  R                  S-  5      U l        [        SU R                  -
  U R
                  -  5      U l        U R                  5         g Nr>   r=   )	r   r   ra   r   r?   half_heightr   r@   setup_edgesr"   s      r   r   VerticalBarsDrawer.initialize   s_    D+F+txx00145!d4448H8HHI
r   c                    U R                   R                  nU R                   R                  R                  nU R                   R                  nU R
                  nUS-  n[        XPR                  -  5      n[        R                  " XU4U5      U l
        U[        -  nU[        -  n[        R                  " XU4U5      n	[        R                  " U	5      n
U
R                  SSXxS-  4US9  U	R                  Xd4[        R                   R"                  5      U l        U R$                  R'                  [        R(                  R*                  5      U l        g rf   )r   rL   rM   rN   r-   r   ra   r   r   rK   rg   rJ   r   r   rP   rQ   rR   rS   	ROUND_TOPri   rj   rk   ROUND_BOTTOM)r#   rL   rN   rq   heightwidthshrunken_widthrr   fake_heightru   rv   s              r   r   VerticalBarsDrawer.setup_edges   s   xx}}XX((33
hh**!!
U%;%;;<iiv&>L00
22yy{+Z
 NN4(	1a1_=KPn%=u?O?O?W?WX NN44U__5T5TUr   c                    U(       a  UR                   (       + nUR                  (       + nU(       a  U R                  OU R                  nU(       a  U R                  OU R                  nU R
                  R                  R                  XQS   S   U R                  -   US   S   45        U R
                  R                  R                  XaS   S   U R                  -   US   S   U R                  -   45        g g rW   )
rz   r|   r   rg   r   r   r    rX   r@   r   )r#   r/   r(   top_roundedbottom_roundedtopbottoms          r   r0   VerticalBarsDrawer.drawrect   s    'kk/K!*_N$/$..T[[C*8T&&dkkFHHMM!fQi$**&<c!fQi%HIHHMMQTZZ/QT=M=M1MN r   )r   r   rg   r@   r   r   rE   r(   r   r   r   r   r   r   r   r:   r   r   r0   r   r3   r4   s   @r   r   r      s)     O3V* r   r   c                   J   ^  \ rS rSrSrSrS	S jrU 4S jrS rS
S jr	Sr
U =r$ )HorizontalBarsDrawer   z
Draws horizontally contiguous groups of modules as long rounded rectangles,
with gaps between neighboring bands (the size of these gaps is inversely
proportional to the vertical_shrink).
Tc                     Xl         g r   )vertical_shrink)r#   r   s     r   r:   HorizontalBarsDrawer.__init__   s    .r   c                    > [         TU ]  " U0 UD6  [        U R                  R                  S-  5      U l        [        SU R                  -
  U R
                  -  5      U l        U R                  5         g r   )	r   r   ra   r   r?   
half_widthr   r@   r   r"   s      r   r   HorizontalBarsDrawer.initialize   s\    D+F+dhh//!34!d222dooEF
r   c                    U R                   R                  nU R                   R                  R                  nU R                   R                  nU R
                  nUS-  n[        XPR                  -  5      n[        R                  " XU4U5      U l
        U[        -  nU[        -  n[        R                  " XU4U5      n	[        R                  " U	5      n
U
R                  SSUS-  U4US9  U	R                  XF4[        R                   R"                  5      U l        U R$                  R'                  [        R(                  R*                  5      U l        g rf   )r   rL   rM   rN   r-   r   ra   r   r   rK   rg   rJ   r   r   rP   rQ   rR   rS   
ROUND_LEFTri   rj   ro   ROUND_RIGHT)r#   rL   rN   rq   r   r   shrunken_heightrr   r   ru   rv   s              r   r    HorizontalBarsDrawer.setup_edges   s   xx}}XX((33
hh**f';';;<iio&>L00
22yy{+Z
 NN4(	1aa=KP++$e&6&6&>&>
  ??44U__5T5TUr   c                    U(       a  UR                   (       + nUR                  (       + nU(       a  U R                  OU R                  nU(       a  U R                  OU R                  nU R
                  R                  R                  XQS   S   US   S   U R                  -   45        U R
                  R                  R                  XaS   S   U R                  -   US   S   U R                  -   45        g g rW   )
ry   r{   r   rg   r   r   r    rX   r@   r   )r#   r/   r(   left_roundedright_roundedleftrights          r   r0   HorizontalBarsDrawer.drawrect   s    ({{?L )OM&24??D(5D$$4;;EHHMM1vay#a&)djj2H&IJHHMMAq	DOO3SVAY5KL r   )r   r   rg   r@   r   r   rE   r   r   r4   s   @r   r   r      s)     O/V. r   r   N)typingr   PILr   r   &qrcode.image.styles.moduledrawers.baser   qrcode.image.styledpilr   qrcode.mainr   rJ   r   r   r6   rG   r[   r   r   r   r   r   <module>r      s        A5/  	n 	C0 CK6 K6E0 E4?L1 ?LD20 2j42 4r   