Ë
    ul�j#  ã                   ó8   — d Z ddlZddlZddlmZ  G d„ d«      Zy))Ú	PdfMatrixé    Nc                   ó„   — e Zd ZdZdd„Zd„ Zd„ Zed„ «       Zd„ Z	e
d„ «       Zd„ Zd	„ Zd
„ Zd„ Zdd„Zd„ Zdd„Zd„ Zd„ Zy)r   a¯  
    PDF transformation matrix helper class.
    
    See the PDF 1.7 specification, Section 8.3.3 ("Common Transformations").
    
    Note:
        * The PDF format uses row vectors.
        * Transformations operate from the origin of the coordinate system
          (PDF coordinates: commonly bottom left, but can be any corner in principle. Device coordinates: top left).
        * Matrix calculations are implemented independently in Python.
        * Matrix objects are immutable, so transforming methods return a new matrix.
        * Matrix objects implement ctypes auto-conversion to ``FS_MATRIX`` for easy use as C function parameter.
    
    Attributes:
        a (float): Matrix value [0][0].
        b (float): Matrix value [0][1].
        c (float): Matrix value [1][0].
        d (float): Matrix value [1][1].
        e (float): Matrix value [2][0] (X translation).
        f (float): Matrix value [2][1] (Y translation).
    c                 ó^   — ||||||f\  | _         | _        | _        | _        | _        | _        y ©N©ÚaÚbÚcÚdÚeÚf)Úselfr   r	   r
   r   r   r   s          úO/var/www/html/pp/venv/lib/python3.12/site-packages/pypdfium2/_helpers/matrix.pyÚ__init__zPdfMatrix.__init__&   s-   € Ø9:¸A¸qÀ!ÀQÈÐ9IÑ6ˆŒ�”˜œ ¤¨¬°µó    c                 ó(   — d| j                  «       › �S )Nr   )Úget©r   s    r   Ú__repr__zPdfMatrix.__repr__)   s   € Ø˜4Ÿ8™8›:˜,Ð'Ð'r   c                 ór   — t        | «      t        |«      ury| j                  «       |j                  «       k(  S )NF)Útyper   ©r   Úothers     r   Ú__eq__zPdfMatrix.__eq__,   s,   € Ü�‹:œT %›[Ñ(ØØ�x‰x‹z˜UŸY™Y›[Ñ(Ð(r   c                 óH   — t        j                  | j                  «       «      S r   )ÚctypesÚbyrefÚto_rawr   s    r   Ú_as_parameter_zPdfMatrix._as_parameter_1   s   € ä�|‰|˜TŸ[™[›]Ó,Ð,r   c                 óŠ   — | j                   | j                  | j                  | j                  | j                  | j
                  fS )zI
        Get the matrix as tuple of the form (a, b, c, d, e, f).
        r   r   s    r   r   zPdfMatrix.get6   s/   € ð —‘˜Ÿ™ §¡¨¯©°·±¸¿¹Ð?Ð?r   c                 ó”   —  | |j                   |j                  |j                  |j                  |j                  |j
                  «      S )zR
        Load a :class:`.PdfMatrix` from a raw :class:`FS_MATRIX` object.
        r   )ÚclsÚraws     r   Úfrom_rawzPdfMatrix.from_raw=   s1   € ñ
 �3—5‘5˜#Ÿ%™% §¡¨¯©¨s¯u©u°c·e±eÓ<Ð<r   c                 óB   — t        j                  | j                  «       Ž S )zH
        Convert the matrix to a raw :class:`FS_MATRIX` object.
        )Úpdfium_cÚ	FS_MATRIXr   r   s    r   r   zPdfMatrix.to_rawE   s   € ô ×!Ñ! 4§8¡8£:Ð.Ð.r   c           
      ó¤  — t        | j                  |j                  z  | j                  |j                  z  z   | j                  |j                  z  | j                  |j                  z  z   | j                  |j                  z  | j                  |j                  z  z   | j                  |j                  z  | j                  |j                  z  z   | j
                  |j                  z  | j                  |j                  z  z   |j
                  z   | j
                  |j                  z  | j                  |j                  z  z   |j                  z   ¬«      S )zf
        Multiply this matrix by another :class:`.PdfMatrix`, to concatenate transformations.
        r   )r   r   r	   r
   r   r   r   r   s     r   ÚmultiplyzPdfMatrix.multiplyL   sã   € ô Ø—‘�u—w‘w‘ §¡¨¯©¡Ñ/Ø—‘�u—w‘w‘ §¡¨¯©¡Ñ/Ø—‘�u—w‘w‘ §¡¨¯©¡Ñ/Ø—‘�u—w‘w‘ §¡¨¯©¡Ñ/à—‘�u—w‘w‘ §¡¨¯©¡Ñ/°%·'±'Ñ9Ø—‘�u—w‘w‘ §¡¨¯©¡Ñ/°%·'±'Ñ9ô
ð 	
r   c           
      ó@   — | j                  t        dddd||«      «      S )zƒ
        Parameters:
            x (float): Horizontal shift (<0: left, >0: right).
            y (float): Vertical shift.
        é   r   ©r)   r   ©r   ÚxÚys      r   Ú	translatezPdfMatrix.translate_   s"   € ð �}‰}œi¨¨1¨a°°A°qÓ9Ó;Ð;r   c                 ó<   — | j                  t        |dd|«      «      S )z£
        Parameters:
            x (float): A factor to scale the X axis (<1: compress, >1: stretch).
            y (float): A factor to scale the Y axis.
        r   r,   r-   s      r   ÚscalezPdfMatrix.scalei   s   € ð �}‰}œi¨¨1¨a°Ó3Ó5Ð5r   c                 óê   — |st        j                  |«      }t        j                  |«      t        j                  |«      }}| j	                  |rt        ||| |«      «      S t        || ||«      «      S )zÙ
        Parameters:
            angle (float): Angle by which to rotate the matrix.
            ccw (bool): If True, rotate counter-clockwise.
            rad (bool): If True, interpret the angle as radians.
        )ÚmathÚradiansÚcosÚsinr)   r   )r   ÚangleÚccwÚradr
   Úss         r   ÚrotatezPdfMatrix.rotates   sc   € ñ Ü—L‘L Ó'ˆEÜ�x‰x˜‹¤§¡¨£ˆ1ˆØ�}‰}¹œi¨¨1¨q¨b°!Ó4ÓYÐYÄÈ1ÈqÈbÐRSÐUVÓAWÓYÐYr   c                 óB   — | j                  |rdnd|rd¬«      S d¬«      S )a‚  
        Parameters:
            invert_x (bool): If True, invert X coordinates (horizontal transform). Corresponds to flipping around the Y axis.
            invert_y (bool): If True, invert Y coordinates (vertical transform). Corresponds to flipping around the X axis.
        Note:
            Flipping around a vertical axis leads to a horizontal transform, and vice versa.
        éÿÿÿÿr+   )r.   r/   )r2   )r   Úinvert_xÚinvert_ys      r   ÚmirrorzPdfMatrix.mirror€   s'   € ð �z‰z¡8™R°¹h¸ˆzÓOÐOÈAˆzÓOÐOr   c           	      óà   — |s*t        j                  |«      }t        j                  |«      }| j                  t        dt        j                  |«      t        j                  |«      d«      «      S )zÙ
        Parameters:
            x_angle (float): Inner angle to skew the X axis.
            y_angle (float): Inner angle to skew the Y axis.
            rad (bool): If True, interpret the angles as radians.
        r+   )r4   r5   r)   r   Útan)r   Úx_angleÚy_angler:   s       r   ÚskewzPdfMatrix.skew‹   sP   € ñ Ü—l‘l 7Ó+ˆGÜ—l‘l 7Ó+ˆGØ�}‰}œi¨¬4¯8©8°GÓ+<¼d¿h¹hÀwÓ>OÐQRÓSÓUÐUr   c                 ó²   — | j                   |z  | j                  |z  z   | j                  z   | j                  |z  | j                  |z  z   | j
                  z   fS )zI
        Returns:
            (float, float): Transformed point.
        )r   r
   r   r	   r   r   r-   s      r   Úon_pointzPdfMatrix.on_point˜   sP   € ð �F‰F�1‰H�t—v‘v˜a‘xÑ $§&¡&Ñ(Ø�F‰F�1‰H�t—v‘v˜a‘xÑ $§&¡&Ñ(ð
ð 	
r   c                 ó  — | j                  ||«      | j                  ||«      | j                  ||«      | j                  ||«      f}t        d„ |D «       «      t        d„ |D «       «      t        d„ |D «       «      t        d„ |D «       «      fS )z[
        Returns:
            (float, float, float, float): Transformed rectangle.
        c              3   ó&   K  — | ]	  }|d    –— Œ y­w©r   N© ©Ú.0Úps     r   ú	<genexpr>z$PdfMatrix.on_rect.<locals>.<genexpr>°   ó   è ø€ Ò%˜��!•Ñ%ùó   ‚c              3   ó&   K  — | ]	  }|d    –— Œ y­w©r+   NrL   rM   s     r   rP   z$PdfMatrix.on_rect.<locals>.<genexpr>±   rQ   rR   c              3   ó&   K  — | ]	  }|d    –— Œ y­wrK   rL   rM   s     r   rP   z$PdfMatrix.on_rect.<locals>.<genexpr>²   rQ   rR   c              3   ó&   K  — | ]	  }|d    –— Œ y­wrT   rL   rM   s     r   rP   z$PdfMatrix.on_rect.<locals>.<genexpr>³   rQ   rR   )rH   ÚminÚmax)r   ÚleftÚbottomÚrightÚtopÚpointss         r   Úon_rectzPdfMatrix.on_rect¤   s‡   € ð �M‰M˜$ Ó$Ø�M‰M˜$ Ó'Ø�M‰M˜% Ó%Ø�M‰M˜% Ó(ð	
ˆô Ñ%˜fÔ%Ó%ÜÑ%˜fÔ%Ó%ÜÑ%˜fÔ%Ó%ÜÑ%˜fÔ%Ó%ð	
ð 	
r   N)r+   r   r   r+   r   r   )FF)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úpropertyr   r   Úclassmethodr$   r   r)   r0   r2   r<   rA   rF   rH   r^   rL   r   r   r   r      su   „ ñó0Jò(ò)ð
 ñ-ó ð-ò@ð ñ=ó ð=ò/ò
ò&<ò6ó
ZòPó
Vò	
ó
r   r   )Ú__all__r4   r   Úpypdfium2.rawr#   r&   r   rL   r   r   ú<module>rg      s!   ðð €ã Û Ý  ÷
g
ò g
r   