
     h|&                     "   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dS )    )absolute_import)TYPE_CHECKINGList)Image	ImageDraw)QRModuleDrawer)StyledPilImage)ActiveWithNeighbors   c                       e Zd ZU dZded<   dS )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__     a/var/www/html/Sam_Eipo/venv/lib/python3.11/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                      j        |i | t          j        | j        j                  | _        d S N)super
initializer   Drawr   _imgimgDrawselfargskwargs	__class__s      r   r   zSquareModuleDrawer.initialize#   s8    D+F+++ ~dhm44r   	is_activec                 Z    |r(| j                             || j        j                   d S d S )Nfill)r   	rectangler   paint_colorr!   boxr%   s      r   drawrectzSquareModuleDrawer.drawrect'   s=     	CL""3TX-A"BBBBB	C 	Cr   )r   r   r   r   r   boolr-   __classcell__r$   s   @r   r   r      sf         5 5 5 5 5Ct C C C C C C C 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                     || _         d S r   )
size_ratio)r!   r5   s     r   __init__z!GappedSquareModuleDrawer.__init__4   s    $r   c                      t                      j        |i | t          j        | j        j                  | _        d| j        z
  | j        j        z  dz  | _	        d S )N      )
r   r   r   r   r   r   r   r5   box_sizedeltar    s      r   r   z#GappedSquareModuleDrawer.initialize7   sU    D+F+++ ~dhm44$/)TX->>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                   d S d S )Nr   r8   r'   )r;   r   r)   r   r*   )r!   r,   r%   smaller_boxs       r   r-   z!GappedSquareModuleDrawer.drawrect<   s     	KAq	DJ&Aq	DJ&Aq	DJ&Aq	DJ&	K L"";TX5I"JJJJJ	K 	Kr   r3   )	r   r   r   r   r6   r   r.   r-   r/   r0   s   @r   r2   r2   ,   s         % % % %C C C C C
Kt K K K K K K K 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                      j        |i | | j        j        }|t          z  }t          j        | j        j        ||f| j        j        j	                  | _
        t          j        | j
                                      dd||f| j        j                   | j
                            ||ft
          j        j                  | _
        d S )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   zCircleModuleDrawer.initializeN   s    D+F+++8$22	iHM	"H*
 

 	t{##++9i(tx/C 	, 	
 	
 	
 k(((H)=u?O?WXXr   r%   c                     |rA| j         j                            | j        |d         d         |d         d         f           d S d S Nr   r8   )r   r   pasterG   r+   s      r   r-   zCircleModuleDrawer.drawrect\   sN     	EHMc!fQiQ-CDDDDD	E 	Er   )	r   r   r   r   rG   r   r.   r-   r/   r0   s   @r   r@   r@   G   sr          FY Y Y Y YEt E E E E E E E Er   r@   c                   \     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).
    Tr8   c                     || _         d S r   )radius_ratio)r!   rS   s     r   r6   zRoundedModuleDrawer.__init__m   s    (r   c                      t                      j        |i | t          | j        j        dz            | _        |                                  d S )Nr9   )r   r   intr   r:   corner_widthsetup_cornersr    s      r   r   zRoundedModuleDrawer.initializep   sQ    D+F+++ 1A 56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        |          }|                    dd||f|           |                    |d||f|           |                    d|||f|           |                    | j        | j        ft
          j        j                  | _        | j                            t
          j        j                  | _        | j                            t
          j        j                  | _        | j                            t
          j        j                  | _        d S Nr9   r   r'   )r   rD   rE   rF   r*   r   rC   rV   SQUARErB   rS   r   r   rH   r)   rI   rJ   rK   NW_ROUND	transpose	TransposeFLIP_TOP_BOTTOMSW_ROUND
ROTATE_180SE_ROUNDFLIP_LEFT_RIGHTNE_ROUND)	r!   rD   rF   front_color
fake_widthradiusdiameterbase	base_draws	            r   rW   z!RoundedModuleDrawer.setup_cornersu   s   x}X(3
h*i4$d&78+
 
 &)<<
"Z/A:y:z*J
 
 N4((	1a84;GGGVQ
J?kRRRQ
J?kRRR 12E4D4L
 
 //0OPP//0JKK//0OPPr   r,   r%   r
   c                    |sd S |j          o|j         }|j         o|j         }|j         o|j         }|j         o|j          }|r| j        n| j        }|r| j        n| j        }|r| j        n| j        }	|r| j        n| j        }
| j	        j
                            ||d         d         |d         d         f           | j	        j
                            ||d         d         | j        z   |d         d         f           | j	        j
                            |	|d         d         | j        z   |d         d         | j        z   f           | j	        j
                            |
|d         d         |d         d         | j        z   f           d S rN   )WNESr[   rZ   rc   ra   r_   r   r   rO   rV   )r!   r,   r%   
nw_rounded
ne_rounded
se_rounded
sw_roundednwnesesws              r   r-   zRoundedModuleDrawer.drawrect   s    	F"_8Y[
"_8Y[
"_8Y[
"_8Y[
(9T]]dk(9T]]dk(9T]]dk(9T]]dkBQCF1I 6777BQT->!>Aq	 JKKKQT..Aq	D<M0MN	
 	
 	
 	BQCF1I8I,I JKKKKKr   )r8   )r   r   r   r   needs_neighborsr6   r   rW   r   rU   r-   r/   r0   s   @r   rQ   rQ   a   s          O) ) ) )    
Q Q Q2LDcO L8M L L L L L L L Lr   rQ   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).
    Tr3   c                     || _         d S r   )horizontal_shrink)r!   r{   s     r   r6   zVerticalBarsDrawer.__init__   s    !2r   c                      t                      j        |i | t          | j        j        dz            | _        t          d| j        z
  | j        z            | _        |                                  d S Nr9   r8   )	r   r   rU   r   r:   half_heightr{   r;   setup_edgesr    s      r   r   zVerticalBarsDrawer.initialize   sp    D+F+++tx01455!d448HHII
r   c                 H   | 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        |	          }
|
                    dd||dz  f|           |	                    ||ft          j        j                  | _        | j                            t          j        j                  | _        d S rY   )r   rD   rE   rF   r*   r~   rU   r{   r   rC   rZ   rB   r   r   rH   rI   rJ   rK   	ROUND_TOPr\   r]   r^   ROUND_BOTTOM)r!   rD   rF   rd   heightwidthshrunken_widthre   fake_heightrh   ri   s              r   r   zVerticalBarsDrawer.setup_edges   s   x}X(3
h*!
UT%;;<<i~v&>LL00
22y:{+Z
 
 N4((	1a[1_=KPPPnf%=u?O?WXX N44U_5TUUr   r%   r
   c                    |r|j          }|j         }|r| j        n| j        }|r| j        n| j        }| j        j                            ||d         d         | j        z   |d         d         f           | j        j                            ||d         d         | j        z   |d         d         | j	        z   f           d S d S rN   )
rl   rn   r   rZ   r   r   r   rO   r;   r~   )r!   r,   r%   top_roundedbottom_roundedtopbottoms          r   r-   zVerticalBarsDrawer.drawrect   s     
	'k/K!*_N$/@$..T[C*8IT&&dkFHMc!fQi$*&<c!fQi%HIIIHMQTZ/QT=M1MN    
	 
	r   r>   r%   r
   
r   r   r   r   rw   r6   r   r   r-   r/   r0   s   @r   ry   ry      s          O3 3 3 3    V V V*       r   ry   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).
    Tr3   c                     || _         d S r   )vertical_shrink)r!   r   s     r   r6   zHorizontalBarsDrawer.__init__   s    .r   c                      t                      j        |i | t          | j        j        dz            | _        t          d| j        z
  | j        z            | _        |                                  d S r}   )	r   r   rU   r   r:   
half_widthr   r;   r   r    s      r   r   zHorizontalBarsDrawer.initialize   sn    D+F+++dh/!344!d22doEFF
r   c                 H   | 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        |	          }
|
                    dd|dz  |f|           |	                    ||ft          j        j                  | _        | j                            t          j        j                  | _        d S rY   )r   rD   rE   rF   r*   r   rU   r   r   rC   rZ   rB   r   r   rH   rI   rJ   rK   
ROUND_LEFTr\   r]   rb   ROUND_RIGHT)r!   rD   rF   rd   r   r   shrunken_heightre   r   rh   ri   s              r   r   z HorizontalBarsDrawer.setup_edges   s   x}X(3
h*ft';;<<iuo&>LL00
22y:{+Z
 
 N4((	1aa=KPPP++uo&>@P@XYY?44U_5TUUr   r%   r
   c                    |r|j          }|j         }|r| j        n| j        }|r| j        n| j        }| j        j                            ||d         d         |d         d         | j        z   f           | j        j                            ||d         d         | j	        z   |d         d         | j        z   f           d S d S rN   )
rk   rm   r   rZ   r   r   r   rO   r;   r   )r!   r,   r%   left_roundedright_roundedleftrights          r   r-   zHorizontalBarsDrawer.drawrect   s     
	({?L )OM&2C4??D(5FD$$4;EHMs1vay#a&)dj2H&IJJJHMAq	DO3SVAY5KL    
	 
	r   r>   r   r   r0   s   @r   r   r      s          O/ / / /    V V V*       r   r   N)
__future__r   typingr   r   qrcode.compat.pilr   r   &qrcode.image.styles.moduledrawers.baser   qrcode.image.styledpilr	   qrcode.mainr
   rB   r   r   r2   r@   rQ   ry   r   r   r   r   <module>r      s   & & & & & & & & & & & & & & . . . . . . . . A A A A A A 0555555//////  	 	 	 	 	n 	 	 	C C C C C0 C C CK K K K K6 K K K6E E E E E0 E E E4?L ?L ?L ?L ?L1 ?L ?L ?LD2 2 2 2 20 2 2 2j2 2 2 2 22 2 2 2 2 2r   