o
    h                     @   s>   d dl mZ d dlmZ ddgZG dd deZd	ddZdS )
    )pairwise)ContourFilterPenreversedContourReverseContourPenc                       s*   e Zd ZdZd fdd	Zdd Z  Z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.
    Fc                    s   t  | || _d S N)super__init__outputImpliedClosingLine)selfoutPenr	   	__class__ t/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/pens/reverseContourPen.pyr      s   
zReverseContourPen.__init__c                 C   s   t || jS r   )r   r	   )r
   contourr   r   r   filterContour   s   zReverseContourPen.filterContourF)__name__
__module____qualname____doc__r   r   __classcell__r   r   r   r   r      s    Fc                 c   s   | sdS t | dksJ d|  d }|dv sJ |dk}| d\}}|dv s0J d| |d	 }|d
krW|du s@J d| rFJ d|d ftt|dd	  d }| sh|dkr`d}nd}||fV  n| d	 \}}|d	 }	|r||fV  ||	krd|	ffV  |t|dd	 |f f| d	< t | dkr| d \}
}n||}
}|s|
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 ]\\}}\}}|tt|dd	 |d	 f fV  q|rd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: %rr   z)off-curve only paths must end with 'None'z,only one qCurveTo allowed per off-curve pathr   r   FTlineTo)reverser   r   )lenpoptuplereversedr   )r   r	   contourTypeclosed	firstTypefirstPtsfirstOnCurvelastTypelastPtslastOnCurve
secondType	secondPtscurTypecurPts_nextPtsr   r   r   r      sT   
"

&Nr   )fontTools.misc.arrayToolsr   fontTools.pens.filterPenr   __all__r   r   r   r   r   r   <module>   s
    