
    h                         S SK rS SKJr  S SKJrJr  S SKJr   " S S\R                  R                  R                  5      rg)    N)Image)QRColorMaskSolidFillColorMask)SquareModuleDrawerc                   r   ^  \ rS rSr% SrSrSr\\S'   \	r
U 4S jrS rU 4S jrS	 rS
 rSS jrS rSrU =r$ )StyledPilImage   a  
Styled PIL image builder, default format is PNG.

This differs from the PilImage in that there is a module_drawer, a
color_mask, and an optional image

The module_drawer should extend the QRModuleDrawer class and implement the
drawrect_context(self, box, active, context), and probably also the
initialize function. This will draw an individual "module" or square on
the QR code.

The color_mask will extend the QRColorMask class and will at very least
implement the get_fg_pixel(image, x, y) function, calculating a color to
put on the image at the pixel location (x,y) (more advanced functionality
can be gotten by instead overriding other functions defined in the
QRColorMask class)

The Image can be specified either by path or with a Pillow Image, and if it
is there will be placed in the middle of the QR code. No effort is done to
ensure that the QR code is still legible after the image has been placed
there; Q or H level error correction levels are recommended to maintain
data integrity A resampling filter can be specified (defaulting to
PIL.Image.Resampling.LANCZOS) for resizing; see PIL.Image.resize() for possible
options for this parameter.
The image size can be controlled by `embeded_image_ratio` which is a ratio
between 0 and 1 that's set in relation to the overall width of the QR code.
PNGT
color_maskc                   > UR                  S[        5       5      U l        UR                  SS 5      nUR                  SS 5      U l        UR                  SS5      U l        UR                  S[
        R                  R                  5      U l        U R                  (       d"  U(       a  [
        R                  " U5      U l        [        S U R                  R                   5       5      U l        U R                  R                  (       a+  [        / U R                  R                  S S QS	P5      U l        [        TU ]<  " U0 UD6  g )
Nr   embeded_image_pathembeded_imageembeded_image_ratiog      ?embeded_image_resamplec              3   &   #    U  H  nS v   M	     g7f)r   N ).0is     ^/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/qrcode/image/styledpil.py	<genexpr>*StyledPilImage.__init__.<locals>.<genexpr>8   s      G,Fq,Fs         )getr   r   r   r   r   
ResamplingLANCZOSr   opentuple
back_colorpaint_colorhas_transparencysuper__init__)selfargskwargsr   	__class__s       r   r#   StyledPilImage.__init__*   s     **\3E3GH#ZZ(<dC#ZZ>#)::.CT#J &,jj$e&6&6&>&>'
# !!&8!&,>!?D
 ! GDOO,F,F GG??++$%Kt'A'A"1'E%Ks%KLD$)&)    c                 $   U R                   R                  (       d/  U R                  (       a   SU R                  R                  5       ;   a  SOSnU R                   R                  n[
        R                  " X R                  U R                  4U5      $ )NARGBARGB)r   r!   r   getbandsr   r   new
pixel_size)r$   r&   moder   s       r   	new_imageStyledPilImage.new_image>   sn     00&&3$2D2D2M2M2O+O 
  	 __//
yyA:NNr)   c                 l   > U R                   R                  X R                  5        [        TU ]  5         g N)r   
initialize_imgr"   init_new_image)r$   r'   s    r   r8   StyledPilImage.init_new_imageL   s$    ""43 r)   c                     U R                   R                  U R                  5        U R                  (       a  U R	                  5         g g r5   )r   
apply_maskr7   r   draw_embeded_image)r$   s    r   processStyledPilImage.processP   s2    ""499-##% r)   c                    U R                   (       d  g U R                  R                  u  p[        U5      n[        XR                  -  5      n[        [        US-  5      [        US-  5      -
  U R
                  -  5      U R
                  -  nXD4nXS-  -
  nU R                   nUR                  Xf4U R                  5      nSUR                  5       ;   a  U R                  R                  Xu5        g U R                  R                  Xu5        g )N   r+   )r   r7   sizeintr   box_sizeresizer   r.   alpha_compositepaste)r$   total_width_logo_width_ishlogo_offsetlogo_position
logo_widthregions           r   r<   !StyledPilImage.draw_embeded_imageU   s    !!+&[+C+CCD[1_%NQ,>(??4==PQmm 	 %2 ?2
##
79T9TU&//##II%%f<IIOOF2r)   c                     Uc  UR                  SU R                  5      nSU;   a  US	 U R                  R                  " U4SU0UD6  g )Nkindformat)r   rP   r7   save)r$   streamrQ   r&   s       r   rR   StyledPilImage.saveh   sD    >ZZ		2FVv		v7f77r)   c                 .    [        U R                  U5      $ r5   )getattrr7   )r$   names     r   __getattr__StyledPilImage.__getattr__o   s    tyy$''r)   )r   r   r   r   r    r5   )__name__
__module____qualname____firstlineno____doc__rP   needs_processingr   __annotations__r   default_drawer_classr#   r2   r8   r=   r<   rR   rX   __static_attributes____classcell__)r'   s   @r   r   r      sJ    8 D-*(O!&
3&8( (r)   r   )qrcode.image.baseqrcodePILr   qrcode.image.styles.colormasksr   r   !qrcode.image.styles.moduledrawersr   imagebaseBaseImageWithDrawerr   r   r)   r   <module>rl      s/      J @i(V\\&&:: i(r)   