Ë
    D<Tf|&  ã                   óö   — d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 erd dl
mZ d dlmZ dZ G d„ d	e	«      Z G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)é    )Úabsolute_import)ÚTYPE_CHECKINGÚList)ÚImageÚ	ImageDraw)ÚQRModuleDrawer)ÚStyledPilImage)ÚActiveWithNeighborsé   c                   ó   — e Zd ZU dZded<   y)ÚStyledPilQRModuleDrawerzù
    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	   ÚimgN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    údC:\Users\user\Documents\project_loop\venv\Lib\site-packages\qrcode/image/styles/moduledrawers/pil.pyr   r      s   … ñð 
Ôr   r   c                   ó.   ‡ — e Zd ZdZˆ fd„Zdefd„Zˆ xZS )ÚSquareModuleDrawerz-
    Draws the modules as simple squares
    c                 ó€   •— t        ‰| �  |i |¤Ž t        j                  | j                  j
                  «      | _        y ©N)ÚsuperÚ
initializer   ÚDrawr   Ú_imgÚimgDraw©ÚselfÚargsÚkwargsÚ	__class__s      €r   r   zSquareModuleDrawer.initialize#   s-   ø€ Ü‰Ñ˜DÐ+ FÒ+Ü —~‘~ d§h¡h§m¡mÓ4ˆ�r   Ú	is_activec                 ól   — |r2| j                   j                  || j                  j                  ¬«       y y )N©Úfill)r   Ú	rectangler   Úpaint_color©r!   Úboxr%   s      r   ÚdrawrectzSquareModuleDrawer.drawrect'   s+   € ÙØ�L‰L×"Ñ" 3¨T¯X©X×-AÑ-AÐ"ÕBð r   )r   r   r   r   r   Úboolr-   Ú__classcell__©r$   s   @r   r   r      s   ø„ ñô5ðC t÷ Cr   r   c                   ó6   ‡ — e Zd ZdZdd„Zˆ fd„Zdefd„Zˆ xZS )ÚGappedSquareModuleDrawerz¹
    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                 ó   — || _         y r   )Ú
size_ratio)r!   r4   s     r   Ú__init__z!GappedSquareModuleDrawer.__init__4   s	   € Ø$ˆ�r   c                 óÜ   •— t        ‰| �  |i |¤Ž t        j                  | j                  j
                  «      | _        d| j                  z
  | j                  j                  z  dz  | _	        y )Né   é   )
r   r   r   r   r   r   r   r4   Úbox_sizeÚdeltar    s      €r   r   z#GappedSquareModuleDrawer.initialize7   sQ   ø€ Ü‰Ñ˜DÐ+ FÒ+Ü —~‘~ d§h¡h§m¡mÓ4ˆŒØ˜$Ÿ/™/Ñ)¨T¯X©X×->Ñ->Ñ>ÀÑBˆ�
r   r%   c                 ó  — |r„|d   d   | j                   z   |d   d   | j                   z   |d   d   | j                   z
  |d   d   | j                   z
  f}| j                  j                  || j                  j                  ¬«       y y )Nr   r7   r'   )r:   r   r)   r   r*   )r!   r,   r%   Úsmaller_boxs       r   r-   z!GappedSquareModuleDrawer.drawrect<   s„   € Ùà�A‘�q‘	˜DŸJ™JÑ&Ø�A‘�q‘	˜DŸJ™JÑ&Ø�A‘�q‘	˜DŸJ™JÑ&Ø�A‘�q‘	˜DŸJ™JÑ&ð	ˆKð �L‰L×"Ñ" ;°T·X±X×5IÑ5IÐ"ÕJð r   ©gš™™™™™é?)	r   r   r   r   r5   r   r.   r-   r/   r0   s   @r   r2   r2   ,   s!   ø„ ñó%ôCð
K t÷ Kr   r2   c                   ó2   ‡ — e Zd ZdZdZˆ fd„Zdefd„Zˆ xZS )ÚCircleModuleDrawerz&
    Draws the modules as circles
    Nc                 ó  •— t        ‰| �  |i |¤Ž | j                  j                  }|t        z  }t        j                  | j                  j                  ||f| j                  j                  j                  «      | _
        t        j                  | j                  «      j                  dd||f| j                  j                  ¬«       | j                  j                  ||ft
        j                   j"                  «      | _
        y )Nr   r'   )r   r   r   r9   ÚANTIALIASING_FACTORr   ÚnewÚmodeÚ
color_maskÚ
back_colorÚcircler   r   Úellipser*   ÚresizeÚ
ResamplingÚLANCZOS)r!   r"   r#   r9   Ú	fake_sizer$   s        €r   r   zCircleModuleDrawer.initializeN   sÊ   ø€ Ü‰Ñ˜DÐ+ FÒ+Ø—8‘8×$Ñ$ˆØÔ2Ñ2ˆ	Ü—i‘iØ�H‰H�M‰MØ˜	Ð"Ø�H‰H×Ñ×*Ñ*ó
ˆŒô
 	�‰�t—{‘{Ó#×+Ñ+Ø��9˜iÐ(¨t¯x©x×/CÑ/Cð 	,ô 	
ð —k‘k×(Ñ(¨(°HÐ)=¼u×?OÑ?O×?WÑ?WÓXˆ�r   r%   c                 ó†   — |r?| j                   j                  j                  | j                  |d   d   |d   d   f«       y y ©Nr   r7   )r   r   ÚpasterF   r+   s      r   r-   zCircleModuleDrawer.drawrect\   s;   € ÙØ�H‰H�M‰M×Ñ §¡¨c°!©f°Q©i¸¸Q¹À¹Ð-CÕDð r   )	r   r   r   r   rF   r   r.   r-   r/   r0   s   @r   r?   r?   G   s#   ø„ ñð €FôYðE t÷ Er   r?   c                   óP   ‡ — e Zd ZdZdZd
d„Zˆ fd„Zd„ Zdeee	      ddfd	„Z
ˆ xZS )ÚRoundedModuleDraweraP  
    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                 ó   — || _         y r   )Úradius_ratio)r!   rR   s     r   r5   zRoundedModuleDrawer.__init__m   s
   € Ø(ˆÕr   c                 ó’   •— t        ‰| �  |i |¤Ž t        | j                  j                  dz  «      | _        | j                  «        y )Nr8   )r   r   Úintr   r9   Úcorner_widthÚsetup_cornersr    s      €r   r   zRoundedModuleDrawer.initializep   s=   ø€ Ü‰Ñ˜DÐ+ FÒ+Ü §¡× 1Ñ 1°AÑ 5Ó6ˆÔØ×ÑÕr   c                 ó  — | j                   j                  }| j                   j                  j                  }| j                   j                  }t        j                  || j                  | j                  f|«      | _        | j                  t        z  }| j                  |z  }|dz  }t        j                  |||f|«      }t        j                  |«      }|j                  dd||f|¬«       |j                  |d||f|¬«       |j                  d|||f|¬«       |j                  | j                  | j                  ft
        j                   j"                  «      | _        | j$                  j'                  t
        j(                  j*                  «      | _        | j$                  j'                  t
        j(                  j.                  «      | _        | j$                  j'                  t
        j(                  j2                  «      | _        y ©Nr8   r   r'   )r   rC   rD   rE   r*   r   rB   rU   ÚSQUARErA   rR   r   r   rG   r)   rH   rI   rJ   ÚNW_ROUNDÚ	transposeÚ	TransposeÚFLIP_TOP_BOTTOMÚSW_ROUNDÚ
ROTATE_180ÚSE_ROUNDÚFLIP_LEFT_RIGHTÚNE_ROUND)	r!   rC   rE   Úfront_colorÚ
fake_widthÚradiusÚdiameterÚbaseÚ	base_draws	            r   rV   z!RoundedModuleDrawer.setup_cornersu   s™  € Ø�x‰x�}‰}ˆØ—X‘X×(Ñ(×3Ñ3ˆ
Ø—h‘h×*Ñ*ˆÜ—i‘iØ�4×$Ñ$ d×&7Ñ&7Ð8¸+ó
ˆŒð ×&Ñ&Ô)<Ñ<ˆ
Ø×"Ñ" ZÑ/ˆØ˜A‘:ˆÜ�y‰yØ�:˜zÐ*¨Jó
ˆô —N‘N 4Ó(ˆ	Ø×Ñ˜1˜a ¨8Ð4¸;ÐÔGØ×Ñ˜V Q¨
°JÐ?ÀkÐÔRØ×Ñ˜Q ¨
°JÐ?ÀkÐÔRØŸ™Ø×Ñ × 1Ñ 1Ð2´E×4DÑ4D×4LÑ4Ló
ˆŒð Ÿ™×/Ñ/´·±×0OÑ0OÓPˆŒØŸ™×/Ñ/´·±×0JÑ0JÓKˆŒØŸ™×/Ñ/´·±×0OÑ0OÓPˆ�r   r,   r%   r
   c                 óÂ  — |sy |j                    xr |j                   }|j                   xr |j                   }|j                   xr |j                   }|j                   xr |j                    }|r| j                  n| j
                  }|r| j                  n| j
                  }|r| j                  n| j
                  }	|r| j                  n| j
                  }
| j                  j                  j                  ||d   d   |d   d   f«       | j                  j                  j                  ||d   d   | j                  z   |d   d   f«       | j                  j                  j                  |	|d   d   | j                  z   |d   d   | j                  z   f«       | j                  j                  j                  |
|d   d   |d   d   | j                  z   f«       y rM   )ÚWÚNÚEÚSrZ   rY   rb   r`   r^   r   r   rN   rU   )r!   r,   r%   Ú
nw_roundedÚ
ne_roundedÚ
se_roundedÚ
sw_roundedÚnwÚneÚseÚsws              r   r-   zRoundedModuleDrawer.drawrectŽ   s‰  € ÙØà"Ÿ™�_Ò8¨Y¯[©[¨ˆ
Ø"Ÿ™�_Ò8¨Y¯[©[¨ˆ
Ø"Ÿ™�_Ò8¨Y¯[©[¨ˆ
Ø"Ÿ™�_Ò8¨Y¯[©[¨ˆ
á(ˆT�]Š]¨d¯k©kˆÙ(ˆT�]Š]¨d¯k©kˆÙ(ˆT�]Š]¨d¯k©kˆÙ(ˆT�]Š]¨d¯k©kˆØ�‰�‰×Ñ˜B  Q¡¨¡¨C°©F°1©IÐ 6Ô7Ø�‰�‰×Ñ˜B  Q¡¨¡¨T×->Ñ->Ñ!>ÀÀAÁÀqÁ	Ð JÔKØ�‰�‰×ÑØ��Q‘˜‘˜T×.Ñ.Ñ.°°A±°q±	¸D×<MÑ<MÑ0MÐNô	
ð 	�‰�‰×Ñ˜B  Q¡¨¡¨C°©F°1©I¸×8IÑ8IÑ,IÐ JÕKr   )r7   )r   r   r   r   Úneeds_neighborsr5   r   rV   r   rT   r-   r/   r0   s   @r   rP   rP   a   s>   ø„ ñð €Oó)ôò
Qð2L˜D  c¡™Oð LÐ8M÷ Lr   rP   c                   ó<   ‡ — e Zd ZdZdZdd„Zˆ fd„Zd„ Zdd„Zˆ xZ	S )	ÚVerticalBarsDrawerzÌ
    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                 ó   — || _         y r   )Úhorizontal_shrink)r!   rz   s     r   r5   zVerticalBarsDrawer.__init__¬   s
   € Ø!2ˆÕr   c                 óæ   •— t        ‰| �  |i |¤Ž t        | j                  j                  dz  «      | _        t        d| j                  z
  | j
                  z  «      | _        | j                  «        y ©Nr8   r7   )	r   r   rT   r   r9   Úhalf_heightrz   r:   Úsetup_edgesr    s      €r   r   zVerticalBarsDrawer.initialize¯   s_   ø€ Ü‰Ñ˜DÐ+ FÒ+Ü˜tŸx™x×0Ñ0°1Ñ4Ó5ˆÔÜ˜!˜d×4Ñ4Ñ4¸×8HÑ8HÑHÓIˆŒ
Ø×ÑÕr   c                 ó°  — | j                   j                  }| j                   j                  j                  }| j                   j                  }| j
                  }|dz  }t        || j                  z  «      }t        j                  |||f|«      | _
        |t        z  }|t        z  }t        j                  |||f|«      }	t        j                  |	«      }
|
j                  dd||dz  f|¬«       |	j                  ||ft        j                   j"                  «      | _        | j$                  j'                  t        j(                  j*                  «      | _        y rX   )r   rC   rD   rE   r*   r}   rT   rz   r   rB   rY   rA   r   r   rG   rH   rI   rJ   Ú	ROUND_TOPr[   r\   r]   ÚROUND_BOTTOM)r!   rC   rE   rc   ÚheightÚwidthÚshrunken_widthrd   Úfake_heightrg   rh   s              r   r~   zVerticalBarsDrawer.setup_edgesµ   s  € Ø�x‰x�}‰}ˆØ—X‘X×(Ñ(×3Ñ3ˆ
Ø—h‘h×*Ñ*ˆà×!Ñ!ˆØ˜‘
ˆÜ˜U T×%;Ñ%;Ñ;Ó<ˆÜ—i‘i  ~°vÐ&>ÀÓLˆŒàÔ0Ñ0ˆ
ØÔ2Ñ2ˆÜ�y‰yØ�:˜{Ð+¨Zó
ˆô —N‘N 4Ó(ˆ	Ø×Ñ˜1˜a ¨[¸1©_Ð=ÀKÐÔPàŸ™ n°fÐ%=¼u×?OÑ?O×?WÑ?WÓXˆŒØ ŸN™N×4Ñ4´U·_±_×5TÑ5TÓUˆÕr   c                 óÄ  — |rÞ|j                    }|j                   }|r| j                  n| j                  }|r| j                  n| j                  }| j
                  j                  j                  ||d   d   | j                  z   |d   d   f«       | j
                  j                  j                  ||d   d   | j                  z   |d   d   | j                  z   f«       y y rM   )
rk   rm   r€   rY   r�   r   r   rN   r:   r}   )r!   r,   r%   Útop_roundedÚbottom_roundedÚtopÚbottoms          r   r-   zVerticalBarsDrawer.drawrectÊ   s¾   € Ùà'Ÿk™k˜/ˆKØ!*§¡˜_ˆNá$/�$—.’.°T·[±[ˆCÙ*8�T×&Ò&¸d¿k¹kˆFØ�H‰H�M‰M×Ñ  c¨!¡f¨Q¡i°$·*±*Ñ&<¸cÀ!¹fÀQ¹iÐ%HÔIØ�H‰H�M‰M×ÑØ˜˜Q™ ™ T§Z¡ZÑ/°°Q±¸±¸T×=MÑ=MÑ1MÐNõð r   r=   ©r%   r
   ©
r   r   r   r   rv   r5   r   r~   r-   r/   r0   s   @r   rx   rx   £   s$   ø„ ñð €Oó3ôòV÷*r   rx   c                   ó<   ‡ — e Zd ZdZdZdd„Zˆ fd„Zd„ Zdd„Zˆ xZ	S )	ÚHorizontalBarsDrawerzÌ
    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                 ó   — || _         y r   )Úvertical_shrink)r!   r�   s     r   r5   zHorizontalBarsDrawer.__init__á   s
   € Ø.ˆÕr   c                 óæ   •— t        ‰| �  |i |¤Ž t        | j                  j                  dz  «      | _        t        d| j                  z
  | j
                  z  «      | _        | j                  «        y r|   )	r   r   rT   r   r9   Ú
half_widthr�   r:   r~   r    s      €r   r   zHorizontalBarsDrawer.initializeä   s\   ø€ Ü‰Ñ˜DÐ+ FÒ+Ü˜dŸh™h×/Ñ/°!Ñ3Ó4ˆŒÜ˜!˜d×2Ñ2Ñ2°d·o±oÑEÓFˆŒ
Ø×ÑÕr   c                 ó°  — | j                   j                  }| j                   j                  j                  }| j                   j                  }| j
                  }|dz  }t        || j                  z  «      }t        j                  |||f|«      | _
        |t        z  }|t        z  }t        j                  |||f|«      }	t        j                  |	«      }
|
j                  dd|dz  |f|¬«       |	j                  ||ft        j                   j"                  «      | _        | j$                  j'                  t        j(                  j*                  «      | _        y rX   )r   rC   rD   rE   r*   r’   rT   r�   r   rB   rY   rA   r   r   rG   rH   rI   rJ   Ú
ROUND_LEFTr[   r\   ra   ÚROUND_RIGHT)r!   rC   rE   rc   rƒ   r‚   Úshrunken_heightrd   r…   rg   rh   s              r   r~   z HorizontalBarsDrawer.setup_edgesê   s  € Ø�x‰x�}‰}ˆØ—X‘X×(Ñ(×3Ñ3ˆ
Ø—h‘h×*Ñ*ˆà—‘ˆØ˜‘ˆÜ˜f t×';Ñ';Ñ;Ó<ˆÜ—i‘i  u¨oÐ&>ÀÓLˆŒàÔ0Ñ0ˆ
ØÔ2Ñ2ˆÜ�y‰yØ�:˜{Ð+¨Zó
ˆô —N‘N 4Ó(ˆ	Ø×Ñ˜1˜a ¨a¡°Ð=ÀKÐÔPàŸ+™+ u¨oÐ&>Ä×@PÑ@P×@XÑ@XÓYˆŒØŸ?™?×4Ñ4´U·_±_×5TÑ5TÓUˆÕr   c                 óÄ  — |rÞ|j                    }|j                   }|r| j                  n| j                  }|r| j                  n| j                  }| j
                  j                  j                  ||d   d   |d   d   | j                  z   f«       | j
                  j                  j                  ||d   d   | j                  z   |d   d   | j                  z   f«       y y rM   )
rj   rl   r”   rY   r•   r   r   rN   r:   r’   )r!   r,   r%   Úleft_roundedÚright_roundedÚleftÚrights          r   r-   zHorizontalBarsDrawer.drawrectÿ   s¼   € Ùà(Ÿ{™{˜?ˆLØ )§¡˜OˆMá&2�4—?’?¸¿¹ˆDÙ(5�D×$Ò$¸4¿;¹;ˆEØ�H‰H�M‰M×Ñ  s¨1¡v¨a¡y°#°a±&¸±)¸d¿j¹jÑ2HÐ&IÔJØ�H‰H�M‰M×ÑØ˜˜A™˜q™	 D§O¡OÑ3°S¸±V¸A±YÀÇÁÑ5KÐLõð r   r=   r‹   rŒ   r0   s   @r   rŽ   rŽ   Ø   s$   ø„ ñð €Oó/ôòV÷*r   rŽ   N)Ú
__future__r   Útypingr   r   Úqrcode.compat.pilr   r   Ú&qrcode.image.styles.moduledrawers.baser   Úqrcode.image.styledpilr	   Úqrcode.mainr
   rA   r   r   r2   r?   rP   rx   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2Ð2õ 2r   