U
    6¦¡c	  ã                   @   s<   d dl mZ d dlmZ ddgZG dd„ deƒZdd„ ZdS )é    )Úpairwise)ÚContourFilterPenÚreversedContourÚReverseContourPenc                   @   s   e Zd ZdZdd„ ZdS )r   a  Filter pen that passes outline data to another pen, but reversing
    the winding direction of all contours. Components are simply passed
    through unchanged.

    Closed contours are reversed in such a way that the first point remains
    the first point.
    c                 C   s   t |ƒS ©N)r   )ÚselfÚcontour© r	   úD/tmp/pip-unpacked-wheel-n2hbwplv/fontTools/pens/reverseContourPen.pyÚfilterContour   s    zReverseContourPen.filterContourN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r	   r	   r
   r      s   c                 c   s  | sdS t | ƒdkstdƒ‚|  ¡ d }|dks4t‚|dk}|  d¡\}}|dks^td| ƒ‚|d	 }|d
kr¬|dks~tdƒ‚| rŠtdƒ‚|d ftt|dd	… ƒƒ d }| sÐ|dkr¾d}nd}||fV  n*| d	 \}}|d	 }|rŒ||fV  ||kr(d|ffV  |t|dd	… ƒ|f f| d	< t | ƒdkrD| d \}	}
n
|| }	}
|	dkr¶||
kr¶| d= | r¶|t|dd	… ƒ|
 f| d	< n*||ffV  |t|dd	… ƒ|f f| d	< t| ddD ]6\\}}\}}|tt|dd	… ƒƒ|d	 f fV  qÂ|rdnddfV  dS )z€ Generator that takes a list of pen's (operator, operands) tuples,
    and yields them with the winding direction reversed.
    Né   zinvalid contourr   )ÚendPathÚ	closePathr   )ÚmoveToÚqCurveToz invalid initial segment type: %réÿÿÿÿr   z)off-curve only paths must end with 'None'z,only one qCurveTo allowed per off-curve pathr   r   FTZlineTo)Úreverser   r	   )ÚlenÚAssertionErrorÚpopÚtupleÚreversedr   )r   ZcontourTypeÚclosedZ	firstTypeZfirstPtsZfirstOnCurveZlastTypeZlastPtsZlastOnCurveZ
secondTypeZ	secondPtsZcurTypeZcurPtsÚ_ZnextPtsr	   r	   r
   r      sh    
ÿ
ÿÿÿ

ÿ
ÿ
 ÿ(N)ZfontTools.misc.arrayToolsr   ZfontTools.pens.filterPenr   Ú__all__r   r   r	   r	   r	   r
   Ú<module>   s   