§
    jÄ-c€  ã                   ó:   — d Z ddlmZmZmZ  G d„ de¦  «        ZdS )zª
    cairocffi.matrix
    ~~~~~~~~~~~~~~~~

    Transformation matrices.

    :copyright: Copyright 2013-2019 by Simon Sapin
    :license: BSD, see LICENSE for details.

é   )Ú_check_statusÚcairoÚffic                   ó  — e Zd ZdZdd„Zed„ ¦   «         Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ ZeZd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z ed¦  «        Z ed¦  «        Z ed¦  «        Z ed¦  «        Z ed¦  «        Z ed¦  «        Z[dS )ÚMatrixa  A 2D transformation matrix.

    Matrices are used throughout cairo to convert between
    different coordinate spaces.
    A :class:`Matrix` holds an affine transformation,
    such as a scale, rotation, shear, or a combination of these.
    The transformation of a point (x,y) is given by::

        x_new = xx * x + xy * y + x0
        y_new = yx * x + yy * y + y0

    The current transformation matrix of a :class:`Context`,
    represented as a :class:`Matrix`,
    defines the transformation from user-space coordinates
    to device-space coordinates.
    See :meth:`Context.get_matrix` and :meth:`Context.set_matrix`.

    The default values produce an identity matrix.

    Matrices can be compared with ``m1 == m2`` and ``m2 != m2``
    as well as multiplied with ``m3 = m1 * m2``.

    r   é    c           	      óv   — t          j        d¦  «        | _        t          j        | j        ||||||¦  «         d S )Nzcairo_matrix_t *)r   ÚnewÚ_pointerr   Úcairo_matrix_init)ÚselfÚxxÚyxÚxyÚyyÚx0Úy0s          ú2/usr/lib/python3/dist-packages/cairocffi/matrix.pyÚ__init__zMatrix.__init__'   s9   € ÝœÐ 2Ñ3Ô3ˆŒÝÔ ¤¨r°2°r¸2¸rÀ2ÑFÔFÐFÐFÐFó    c                 óN   —  | ¦   «         }t          j        |j        |¦  «         |S )aé  Return a new :class:`Matrix` for a transformation
        that rotates by :obj:`radians`.

        :type radians: float
        :param radians:
            Angle of rotation, in radians.
            The direction of rotation is defined such that
            positive angles rotate in the direction
            from the positive X axis toward the positive Y axis.
            With the default axis orientation of cairo,
            positive angles rotate in a clockwise direction.

        )r   Úcairo_matrix_init_rotater   )ÚclsÚradiansÚresults      r   Úinit_rotatezMatrix.init_rotate+   s)   € ð �‘”ˆÝÔ& v¤¸Ñ@Ô@Ð@Øˆr   c                 ó\   — | j         }|j        |j        |j        |j        |j        |j        fS )uu   Return all of the matrixâ€™s components.

        :returns: A ``(xx, yx, xy, yy, x0, y0)`` tuple of floats.

        )r   r   r   r   r   r   r   )r   Úptrs     r   Úas_tuplezMatrix.as_tuple>   s*   € ð ŒmˆØ”˜œ ¤¨¬°´¸¼Ð?Ð?r   c                 óJ   —  t          | ¦  «        |                      ¦   «         Ž S )z!Return a new copy of this matrix.)Útyper   ©r   s    r   ÚcopyzMatrix.copyG   s   € à�t�D‰zŒz˜4Ÿ=š=™?œ?Ð+Ð+r   c                 ó8   — t          | j        d|         ¦  «        S )N)r   r   r   r   r   r   ©Úgetattrr   )r   Úindexs     r   Ú__getitem__zMatrix.__getitem__K   s$   € ÝØŒMÐ?ÀÔFñHô Hð 	Hr   c                 óD   — t          |                      ¦   «         ¦  «        S ©N)Úiterr   r"   s    r   Ú__iter__zMatrix.__iter__O   s   € Ý�D—M’M‘O”OÑ$Ô$Ð$r   c                 óV   — |                       ¦   «         |                      ¦   «         k    S r*   ©r   ©r   Úothers     r   Ú__eq__zMatrix.__eq__R   ó   € Ø�}Š}‰Œ %§.¢.Ñ"2Ô"2Ò2Ð2r   c                 óV   — |                       ¦   «         |                      ¦   «         k    S r*   r.   r/   s     r   Ú__ne__zMatrix.__ne__U   r2   r   c                 ó`   — t          | ¦  «        }d|j        f|                      ¦   «         z   z  S )Nz%s(%g, %g, %g, %g, %g, %g))r!   Ú__name__r   )r   Úclass_s     r   Ú__repr__zMatrix.__repr__X   s/   € Ý�d‘”ˆØ+ØŒ_Ð §¢¡¤Ñ0ñ2ð 	2r   c                 ól   — t          ¦   «         }t          j        |j        | j        |j        ¦  «         |S )z‡Multiply with another matrix
        and return the result as a new :class:`Matrix` object.
        Same as ``self * other``.

        )r   r   Úcairo_matrix_multiplyr   )r   r0   Úress      r   ÚmultiplyzMatrix.multiply]   s4   € õ ‰hŒhˆÝÔ#ØŒL˜$œ-¨¬ñ	9ô 	9ð 	9àˆ
r   c                 ó<   — t          j        | j        ||¦  «         dS )a  Applies a translation by :obj:`tx`, :obj:`ty`
        to the transformation in this matrix.

        The effect of the new transformation is to
        first translate the coordinates by :obj:`tx` and :obj:`ty`,
        then apply the original transformation to the coordinates.

        .. note::
            This changes the matrix in-place.

        :param tx: Amount to translate in the X direction.
        :param ty: Amount to translate in the Y direction.
        :type tx: float
        :type ty: float

        N)r   Úcairo_matrix_translater   )r   ÚtxÚtys      r   Ú	translatezMatrix.translatej   s!   € õ" 	Ô$ T¤]°B¸Ñ;Ô;Ð;Ð;Ð;r   Nc                 óD   — |€|}t          j        | j        ||¦  «         dS )a_  Applies scaling by :obj:`sx`, :obj:`sy`
        to the transformation in this matrix.

        The effect of the new transformation is to
        first scale the coordinates by :obj:`sx` and :obj:`sy`,
        then apply the original transformation to the coordinates.

        If :obj:`sy` is omitted, it is the same as :obj:`sx`
        so that scaling preserves aspect ratios.

        .. note::
            This changes the matrix in-place.

        :param sx: Scale factor in the X direction.
        :param sy: Scale factor in the Y direction.
        :type sx: float
        :type sy: float

        N)r   Úcairo_matrix_scaler   )r   ÚsxÚsys      r   ÚscalezMatrix.scale}   s+   € ð( ˆ:ØˆBÝÔ  ¤°°BÑ7Ô7Ð7Ð7Ð7r   c                 ó:   — t          j        | j        |¦  «         dS )aÒ  Applies a rotation by :obj:`radians`
        to the transformation in this matrix.

        The effect of the new transformation is to
        first rotate the coordinates by :obj:`radians`,
        then apply the original transformation to the coordinates.

        .. note::
            This changes the matrix in-place.

        :type radians: float
        :param radians:
            Angle of rotation, in radians.
            The direction of rotation is defined such that positive angles
            rotate in the direction from the positive X axis
            toward the positive Y axis.
            With the default axis orientation of cairo,
            positive angles rotate in a clockwise direction.

        N)r   Úcairo_matrix_rotater   )r   r   s     r   ÚrotatezMatrix.rotate•   s   € õ* 	Ô! $¤-°Ñ9Ô9Ð9Ð9Ð9r   c                 óR   — t          t          j        | j        ¦  «        ¦  «         dS )au  Changes matrix to be the inverse of its original value.
        Not all transformation matrices have inverses;
        if the matrix collapses points together (it is degenerate),
        then it has no inverse and this function will fail.

        .. note::
            This changes the matrix in-place.

        :raises: :exc:`CairoError` on degenerate matrices.

        N)r   r   Úcairo_matrix_invertr   r"   s    r   ÚinvertzMatrix.invert¬   s%   € õ 	•eÔ/°´Ñ>Ô>Ñ?Ô?Ð?Ð?Ð?r   c                 óV   — |                       ¦   «         }|                     ¦   «          |S )z¬Return the inverse of this matrix. See :meth:`invert`.

        :raises: :exc:`CairoError` on degenerate matrices.
        :returns: A new :class:`Matrix` object.

        )r#   rL   )r   Úmatrixs     r   ÚinvertedzMatrix.invertedº   s#   € ð —’‘”ˆØ�Š‰ŒˆØˆr   c                 ó�   — t          j        d||g¦  «        }t          j        | j        |dz   |dz   ¦  «         t          |¦  «        S )zÜTransforms the point ``(x, y)`` by this matrix.

        :param x: X position.
        :param y: Y position.
        :type x: float
        :type y: float
        :returns: A ``(new_x, new_y)`` tuple of floats.

        ú	double[2]r   r   )r   r
   r   Úcairo_matrix_transform_pointr   Útuple)r   ÚxÚyr   s       r   Útransform_pointzMatrix.transform_pointÅ   sD   € õ ŒW�[ 1 a &Ñ)Ô)ˆÝÔ*¨4¬=¸"¸q¹&À"ÀqÁ&ÑIÔIÐIÝ�R‰yŒyÐr   c                 ó�   — t          j        d||g¦  «        }t          j        | j        |dz   |dz   ¦  «         t          |¦  «        S )a]  Transforms the distance vector ``(dx, dy)`` by this matrix.
        This is similar to :meth:`transform_point`
        except that the translation components of the transformation
        are ignored.
        The calculation of the returned vector is as follows::

            dx2 = dx1 * xx + dy1 * xy
            dy2 = dx1 * yx + dy1 * yy

        Affine transformations are position invariant,
        so the same vector always transforms to the same vector.
        If ``(x1, y1)`` transforms to ``(x2, y2)``
        then ``(x1 + dx1, y1 + dy1)`` will transform
        to ``(x1 + dx2, y1 + dy2)`` for all values of ``x1`` and ``x2``.

        :param dx: X component of a distance vector.
        :param dy: Y component of a distance vector.
        :type dx: float
        :type dy: float
        :returns: A ``(new_dx, new_dy)`` tuple of floats.

        rQ   r   r   )r   r
   r   Úcairo_matrix_transform_distancer   rS   )r   ÚdxÚdyr   s       r   Útransform_distancezMatrix.transform_distanceÓ   sD   € õ. ŒW�[ 2 r (Ñ+Ô+ˆÝÔ-¨d¬m¸RÀ!¹VÀRÈ!ÁVÑLÔLÐLÝ�R‰yŒyÐr   c                 ó4   ‡ — t          ˆ fd„ˆ fd„d¬¦  «        S )Nc                 ó.   •— t          | j        ‰¦  «        S r*   r%   )r   Únames    €r   ú<lambda>z,Matrix._component_property.<locals>.<lambda>ð   s   ø€ � ¤°Ñ5Ô5€ r   c                 ó0   •— t          | j        ‰|¦  «        S r*   )Úsetattrr   )r   Úvaluer^   s     €r   r_   z,Matrix._component_property.<locals>.<lambda>ñ   s   ø€ ¥¨¬°t¸UÑ CÔ C€ r   z8Read-write attribute access to a single float component.)Údoc)Úproperty)r^   s   `r   Ú_component_propertyzMatrix._component_propertyî   s9   ø€ ÝØ5Ð5Ð5Ð5ØCÐCÐCÐCØJðLñ Lô Lð 	Lr   r   r   r   r   r   r   )r   r   r   r   r   r   r*   )r6   Ú
__module__Ú__qualname__Ú__doc__r   Úclassmethodr   r   r#   r(   r,   r1   r4   r8   r<   Ú__mul__rA   rF   rI   rL   rO   rV   r[   re   r   r   r   r   r   r   © r   r   r   r      sº  € € € € € ðð ð.Gð Gð Gð Gð ðð ñ „[ðð$@ð @ð @ð,ð ,ð ,ðHð Hð Hð%ð %ð %ð3ð 3ð 3ð3ð 3ð 3ð2ð 2ð 2ð
	ð 	ð 	ð €Gð<ð <ð <ð&8ð 8ð 8ð 8ð0:ð :ð :ð.@ð @ð @ð	ð 	ð 	ðð ð ðð ð ð6Lð Lð Lð 
Ð	˜TÑ	"Ô	"€BØ	Ð	˜TÑ	"Ô	"€BØ	Ð	˜TÑ	"Ô	"€BØ	Ð	˜TÑ	"Ô	"€BØ	Ð	˜TÑ	"Ô	"€BØ	Ð	˜TÑ	"Ô	"€BØÐÐr   r   N)rh   Ú r   r   r   Úobjectr   rk   r   r   ú<module>rn      sm   ðð	ð 	ð (Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'ðkð kð kð kð kˆVñ kô kð kð kð kr   