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 )zÛThe '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__© úo/var/www/html/construction_image-detection-poc/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 )zîThe '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?   iöÿÿÿr   )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

ù