HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/cairocffi/__pycache__/matrix.cpython-310.pyc
o

*weY�@s,dZddlmZmZmZGdd�de�ZdS)z�
    cairocffi.matrix
    ~~~~~~~~~~~~~~~~

    Transformation matrices.

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

�)�
_check_status�cairo�ffic@s�eZdZdZd/dd�Zedd��Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZeZdd�Zd0dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zed)�Zed*�Zed+�Zed,�Zed-�Zed.�Z[dS)1�MatrixaA 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	Cs(t�d�|_t�|j||||||�dS)Nzcairo_matrix_t *)r�new�_pointerr�cairo_matrix_init)�self�xx�yx�xy�yy�x0�y0�r�I/home/arjun/projects/env/lib/python3.10/site-packages/cairocffi/matrix.py�__init__'szMatrix.__init__cCs|�}t�|j|�|S)a�Return a new :class:`Matrix` for a transformation
        that rotates by ``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�resultrrr�init_rotate+szMatrix.init_rotatecCs"|j}|j|j|j|j|j|jfS)uuReturn all of the matrix’s components.

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

        )rrrr
rrr)r
�ptrrrr�as_tuple>szMatrix.as_tuplecCst|�|���S)z!Return a new copy of this matrix.)�typer�r
rrr�copyGszMatrix.copycCst|jd|�S)N)rrr
rrr��getattrr)r
�indexrrr�__getitem__Ks
�zMatrix.__getitem__cCst|���S�N)�iterrrrrr�__iter__OszMatrix.__iter__cCs|��|��kSr"�r�r
�otherrrr�__eq__R�z
Matrix.__eq__cCs|��|��kSr"r%r&rrr�__ne__Ur)z
Matrix.__ne__cCst|�}d|jf|��S)Nz%s(%g, %g, %g, %g, %g, %g))r�__name__r)r
�class_rrr�__repr__Xs�zMatrix.__repr__cCst�}t�|j|j|j�|S)z�Multiply with another matrix
        and return the result as a new :class:`Matrix` object.
        Same as ``self * other``.

        )rr�cairo_matrix_multiplyr)r
r'�resrrr�multiply]s
�zMatrix.multiplycCst�|j||�dS)a�Applies a translation by ``tx``, ``ty``
        to the transformation in this matrix.

        The effect of the new transformation is to
        first translate the coordinates by ``tx`` and ``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�tyrrr�	translatejszMatrix.translateNcCs |dur|}t�|j||�dS)aMApplies scaling by ``sx``, ``sy``
        to the transformation in this matrix.

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

        If ``sy`` is omitted, it is the same as ``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�syrrr�scale}szMatrix.scalecCst�|j|�dS)a�Applies a rotation by ``radians``
        to the transformation in this matrix.

        The effect of the new transformation is to
        first rotate the coordinates by ``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
rrrr�rotate�sz
Matrix.rotatecCstt�|j��dS)auChanges 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)rr�cairo_matrix_invertrrrrr�invert�sz
Matrix.invertcCs|��}|��|S)z�Return the inverse of this matrix. See :meth:`invert`.

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

        )rr<)r
�matrixrrr�inverted�szMatrix.invertedcC�0t�d||g�}t�|j|d|d�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]rr)rrr�cairo_matrix_transform_pointr�tuple)r
�x�yr
rrr�transform_point�s
zMatrix.transform_pointcCr?)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.

        r@rr)rrr�cairo_matrix_transform_distancerrB)r
�dx�dyr
rrr�transform_distance�szMatrix.transform_distancecst�fdd��fdd�dd�S)Ncst|j��Sr"rr��namerr�<lambda>�sz,Matrix._component_property.<locals>.<lambda>cst|j�|�Sr")�setattrr)r
�valuerJrrrL�sz8Read-write attribute access to a single float component.)�doc)�propertyrJrrJr�_component_property�s


�zMatrix._component_propertyrrr
rrr)rrrrrrr")r+�
__module__�__qualname__�__doc__r�classmethodrrrr!r$r(r*r-r0�__mul__r4r8r:r<r>rErIrQrrr
rrrrrrrrs:

	
rN)rT�rrr�objectrrrrr�<module>s