B
    ¶ôJdý  ã               @   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r†d dlmZ eedƒd	ƒZ	e	 
d
¡ e	 d¡ e	 dddd
¡ e	 ¡  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   Ú_transformPointÚ_stack)ÚselfZoutPenÚtransformationr   )Ú	__class__© úM/var/www/html/venv/lib/python3.7/site-packages/fontTools/pens/transformPen.pyr	      s    
zTransformPen.__init__c             C   s   | j  |  |¡¡ d S )N)Ú_outPenÚmoveTor   )r   Úptr   r   r   r      s    zTransformPen.moveToc             C   s   | j  |  |¡¡ d S )N)r   ÚlineTor   )r   r   r   r   r   r      s    zTransformPen.lineToc             G   s   | j j|  |¡Ž  d S )N)r   ÚcurveToÚ_transformPoints)r   Úpointsr   r   r   r       s    zTransformPen.curveToc             G   s@   |d d kr&|   |d d… ¡d g }n
|   |¡}| jj|Ž  d S )Néÿÿÿÿ)r   r   ÚqCurveTo)r   r   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   r   *   s    zTransformPen._transformPointsc             C   s   | j  ¡  d S )N)r   Ú	closePath)r   r   r   r   r   .   s    zTransformPen.closePathc             C   s   | j  ¡  d S )N)r   ÚendPath)r   r   r   r   r    1   s    zTransformPen.endPathc             C   s   | j  |¡}| j ||¡ d S )N)r   Ú	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|Ž d S )N)r   ÚaddPointr   )r   r   ZsegmentTypeZsmoothÚnameÚkwargsr   r   r   r(   \   s    zTransformPointPen.addPointc             K   s"   | j  |¡}| jj||f|Ž d S )N)r   r!   r   r"   )r   ZbaseGlyphNamer   r*   r   r   r   r"   a   s    zTransformPointPen.addComponent)NFN)r#   r$   r%   r&   r	   r(   r"   r'   r   r   )r   r   r   9   s   
Ú__main__)Ú_TestPenN)é   r   g      à?r-   iöÿÿÿr   )r   r   )r   éd   )é2   éK   )é<   r/   )r/   é   )ZfontTools.pens.filterPenr   r   Ú__all__r   r   r#   ZfontTools.pens.basePenr,   Úpenr   r   r   r   r   r   r   r   Ú<module>   s   2-

