o
    h                     @   s   d dl mZmZ ddgZG dd deZG dd deZedkrEd dlmZ eedd	Z	e	
d
 e	d e	dddd
 e	  dS dS )    )	FilterPenFilterPointPenTransformPenTransformPointPenc                       s`   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Z  ZS )r   zkPen that transforms all coordinates using a Affine transformation,
    and passes them to another pen.
    c                    sF   t t| | t|dsddlm} || }|| _|j| _g | _	dS )zThe 'outPen' argument is another pen object. It will receive the
        transformed coordinates. The 'transformation' argument can either
        be a six-tuple, or a fontTools.misc.transform.Transform object.
        transformPointr   	TransformN)
superr   __init__hasattrfontTools.misc.transformr   _transformationr   _transformPoint_stack)selfoutPentransformationr   	__class__ ]/var/www/html/optinet_system/venv/lib/python3.10/site-packages/fontTools/pens/transformPen.pyr
      s   

zTransformPen.__init__c                 C      | j | | d S N)_outPenmoveTor   r   ptr   r   r   r         zTransformPen.moveToc                 C   r   r   )r   lineTor   r   r   r   r   r      r   zTransformPen.lineToc                 G   s   | j j| |  d S r   )r   curveTo_transformPointsr   pointsr   r   r   r       r   zTransformPen.curveToc                 G   s@   |d d u r|  |d d d g }n|  |}| jj|  d S )N)r    r   qCurveTor!   r   r   r   r$   #   s   
zTransformPen.qCurveToc                    s   | j   fdd|D S )Nc                    s   g | ]} |qS r   r   ).0r   r   r   r   
<listcomp>,   s    z1TransformPen._transformPoints.<locals>.<listcomp>)r   r!   r   r&   r   r    *   s   zTransformPen._transformPointsc                 C      | j   d S r   )r   	closePathr   r   r   r   r)   .      zTransformPen.closePathc                 C   r(   r   )r   endPathr*   r   r   r   r,   1   r+   zTransformPen.endPathc                 C   s   | j |}| j|| d S r   r   	transformr   addComponent)r   	glyphNamer   r   r   r   r/   4   s   zTransformPen.addComponent)__name__
__module____qualname____doc__r
   r   r   r   r$   r    r)   r,   r/   __classcell__r   r   r   r   r      s    c                       s2   e Zd ZdZ fddZd
ddZdd	 Z  ZS )r   a^  PointPen that transforms all coordinates using a Affine transformation,
    and passes them to another PointPen.

    For example::

        >>> from fontTools.pens.recordingPen import RecordingPointPen
        >>> rec = RecordingPointPen()
        >>> pen = TransformPointPen(rec, (2, 0, 0, 2, -10, 5))
        >>> v = iter(rec.value)
        >>> pen.beginPath(identifier="contour-0")
        >>> next(v)
        ('beginPath', (), {'identifier': 'contour-0'})

        >>> pen.addPoint((100, 100), "line")
        >>> next(v)
        ('addPoint', ((190, 205), 'line', False, None), {})

        >>> pen.endPath()
        >>> next(v)
        ('endPath', (), {})

        >>> pen.addComponent("a", (1, 0, 0, 1, -10, 5), identifier="component-0")
        >>> next(v)
        ('addComponent', ('a', <Transform [2 0 0 2 -30 15]>), {'identifier': 'component-0'})
    c                    s<   t  | t|dsddlm} || }|| _|j| _dS )zThe 'outPointPen' argument is another point pen object.
        It will receive the transformed coordinates.
        The 'transformation' argument can either be a six-tuple, or a
        fontTools.misc.transform.Transform object.
        r   r   r   N)r	   r
   r   r   r   r   r   r   )r   outPointPenr   r   r   r   r   r
   T   s   
zTransformPointPen.__init__NFc                 K   s$   | j j| ||||fi | d S r   )r   addPointr   )r   r   segmentTypesmoothnamekwargsr   r   r   r7   b   s
   
zTransformPointPen.addPointc                 K   s&   | j |}| jj||fi | d S r   r-   )r   baseGlyphNamer   r;   r   r   r   r/   g   s   zTransformPointPen.addComponent)NFN)r1   r2   r3   r4   r
   r7   r/   r5   r   r   r   r   r   9   s
    
__main__)_TestPenN)   r   g      ?r?   ir   )r   r   )r   d   )2   K   )<   rA   )rA      )fontTools.pens.filterPenr   r   __all__r   r   r1   fontTools.pens.basePenr>   penr   r   r   r)   r   r   r   r   <module>   s    23

