
    )i#                     8    S r SSKrSSKrSSKJr   " S S5      rg))	PdfMatrix    Nc                       \ rS rSrSrSS jrS rS r\S 5       r	S r
\S 5       rS	 rS
 rS rS rSS jrS rSS jrS rS rSrg)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                 X    XX4XV4u  U l         U l        U l        U l        U l        U l        g Nabcdef)selfr	   r
   r   r   r   r   s          Y/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/pypdfium2/_helpers/matrix.py__init__PdfMatrix.__init__&   s'    9:qQ9I6    c                 (    SU R                  5        3$ )Nr   )getr   s    r   __repr__PdfMatrix.__repr__)   s    488:,''r   c                 t    [        U 5      [        U5      La  gU R                  5       UR                  5       :H  $ )NF)typer   r   others     r   __eq__PdfMatrix.__eq__,   s,    :T%[(xxzUYY[((r   c                 J    [         R                  " U R                  5       5      $ r   )ctypesbyrefto_rawr   s    r   _as_parameter_PdfMatrix._as_parameter_1   s    ||T[[],,r   c                     U R                   U R                  U R                  U R                  U R                  U R
                  4$ )z9
Get the matrix as tuple of the form (a, b, c, d, e, f).
r   r   s    r   r   PdfMatrix.get6   s/     ??r   c                     U " UR                   UR                  UR                  UR                  UR                  UR
                  5      $ )zB
Load a :class:`.PdfMatrix` from a raw :class:`FS_MATRIX` object.
r   )clsraws     r   from_rawPdfMatrix.from_raw=   s1    
 355#%%suucee<<r   c                 D    [         R                  " U R                  5       6 $ )z8
Convert the matrix to a raw :class:`FS_MATRIX` object.
)pdfium_c	FS_MATRIXr   r   s    r   r"   PdfMatrix.to_rawE   s     !!488:..r   c           
         [        U R                  UR                  -  U R                  UR                  -  -   U R                  UR                  -  U R                  UR                  -  -   U R                  UR                  -  U R                  UR                  -  -   U R                  UR                  -  U R                  UR                  -  -   U R
                  UR                  -  U R                  UR                  -  -   UR
                  -   U R
                  UR                  -  U R                  UR                  -  -   UR                  -   S9$ )zV
Multiply this matrix by another :class:`.PdfMatrix`, to concatenate transformations.
r   )r   r	   r
   r   r   r   r   r   s     r   multiplyPdfMatrix.multiplyL   s     uww/uww/uww/uww/uww/%''9uww/%''9
 	
r   c           
      >    U R                  [        SSSSX5      5      $ )zc
Parameters:
    x (float): Horizontal shift (<0: left, >0: right).
    y (float): Vertical shift.
   r   r1   r   r   xys      r   	translatePdfMatrix.translate_   s      }}i1aA9;;r   c                 <    U R                  [        USSU5      5      $ )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   r5   r6   s      r   scalePdfMatrix.scalei   s     }}i1a355r   c                     U(       d  [         R                  " U5      n[         R                  " U5      [         R                  " U5      pTU R	                  U(       a  [        XEU* U5      5      $ [        XE* XT5      5      $ )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sinr1   r   )r   angleccwradr   ss         r   rotatePdfMatrix.rotates   sZ     LL'Exx1}}iqb!4YY1bRSAWYYr   c                 J    U R                  U(       a  SOSU(       a  SS9$ SS9$ )aR  
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.
r4   )r7   r8   )r<   )r   invert_xinvert_ys      r   mirrorPdfMatrix.mirror   s'     zz8RhzOOAzOOr   c           	          U(       d,  [         R                  " U5      n[         R                  " U5      nU R                  [        S[         R                  " U5      [         R                  " U5      S5      5      $ )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.
r4   )r?   r@   r1   r   tan)r   x_angley_anglerE   s       r   skewPdfMatrix.skew   sP     ll7+Gll7+G}}i488G+<dhhw>OQRSUUr   c                     U R                   U-  U R                  U-  -   U R                  -   U R                  U-  U R                  U-  -   U R
                  -   4$ )z1
Returns:
    (float, float): Transformed point.
)r	   r   r   r
   r   r   r6   s      r   on_pointPdfMatrix.on_point   sP     FF1Htvvax$&&(FF1Htvvax$&&(
 	
r   c                    U R                  X5      U R                  X5      U R                  X45      U R                  X25      4n[        S U 5       5      [        S U 5       5      [        S U 5       5      [        S U 5       5      4$ )zC
Returns:
    (float, float, float, float): Transformed rectangle.
c              3   *   #    U  H	  oS    v   M     g7fr   N .0ps     r   	<genexpr>$PdfMatrix.on_rect.<locals>.<genexpr>        %f!f   c              3   *   #    U  H	  oS    v   M     g7fr4   Nr[   r\   s     r   r_   r`      ra   rb   c              3   *   #    U  H	  oS    v   M     g7frZ   r[   r\   s     r   r_   r`      ra   rb   c              3   *   #    U  H	  oS    v   M     g7frd   r[   r\   s     r   r_   r`      ra   rb   )rV   minmax)r   leftbottomrighttoppointss         r   on_rectPdfMatrix.on_rect   s     MM$$MM$'MM%%MM%(	
 %f%%%f%%%f%%%f%%	
 	
r   r   N)r4   r   r   r4   r   r   )FF)F)__name__
__module____qualname____firstlineno____doc__r   r   r   propertyr#   r   classmethodr*   r"   r1   r9   r<   rG   rM   rS   rV   rn   __static_attributes__r[   r   r   r   r      su    0J()
 - -@ = =/
&<6
ZP
V	

r   r   )__all__r?   r    pypdfium2.rawr)   r-   r   r[   r   r   <module>rz      s!        
g
 g
r   