o
    Ðùaý  ã                   @   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   zePen 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   Ú_transformPointZ_stack)ÚselfZoutPenÚtransformationr   ©Ú	__class__© ú=/usr/lib/python3/dist-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   Z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   Z	transformr   ÚaddComponent)r   Z	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.

	>>> 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   ZoutPointPenr   r   r   r   r   r
   O   s   
zTransformPointPen.__init__NFc                 K   s$   | j j|  |¡|||fi |¤Ž d S r   )r   ÚaddPointr   )r   r   ZsegmentTypeZsmoothÚnameÚkwargsr   r   r   r1   \   s
   ÿ
ÿzTransformPointPen.addPointc                 K   s&   | j  |¡}| jj||fi |¤Ž d S r   r*   )r   ZbaseGlyphNamer   r3   r   r   r   r+   a   s   zTransformPointPen.addComponent)NFN)r,   r-   r.   r/   r
   r1   r+   r0   r   r   r   r   r   9   s
    
Ú__main__)Ú_TestPenN)é   r   g      à?r6   iöÿÿÿr   )r   r   )r   éd   )é2   éK   )é<   r8   )r8   é   )ZfontTools.pens.filterPenr   r   Ú__all__r   r   r,   ZfontTools.pens.basePenr5   Zpenr   r   r   r&   r   r   r   r   Ú<module>   s    2-

ú