
    w;3h	                     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: bottom left corner, Device coordinates: top left corner).
        * 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          Y/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/pypdfium2/_helpers/matrix.py__init__zPdfMatrix.__init__(   s-    9:Aq!Q9I6    c                 (    d| j                          S )Nr   )getr   s    r   __repr__zPdfMatrix.__repr__,   s    488:,''r   c                 r    t        |       t        |      ury| j                         |j                         k(  S )NF)typer   r   others     r   __eq__zPdfMatrix.__eq__0   s,    :T%[(
eiik)*r   c                 H    t        j                  | j                               S r   )ctypesbyrefto_rawr   s    r   _as_parameter_zPdfMatrix._as_parameter_6   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.get;   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_rawB   s1    
 355#%%suucee<<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_rawJ   s     !!488:..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.multiplyQ   s     uww/uww/uww/uww/uww/%''9uww/%''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.translatec   s"     }}i1aAq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.scalem   s     }}i1a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.rotatew   sc     LL'Exx1}}i1qb!4YY1qbRSUVAWYYr   c                 B    | j                  |rdnd|rd      S d      S )z
        Parameters:
            v (bool): Whether to mirror vertically (at the Y axis).
            h (bool): Whether to mirror horizontall (at the X axis).
        r+   )r.   r/   )r2   )r   vhs      r   mirrorzPdfMatrix.mirror   s'     zz1R!qzAAazAAr   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     ll7+Gll7+G}}i488G+<dhhw>OQR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     FF1Htvvax$&&(FF1Htvvax$&&(
 	
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     MM$$MM$'MM%%MM%(	
 %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B
V	

r   r   )__all__r4   r   pypdfium2.rawr#   r&   r   rL   r   r   <module>rg      s!        h
 h
r   