o
    ¼Çh9  ã                   @   s\   d dl mZmZmZ d dlmZmZ d dlmZ ddgZ	G dd„ deƒZ
G dd„ de
ƒZdS )	é    )ÚupdateBoundsÚpointInRectÚ	unionRect)ÚcalcCubicBoundsÚcalcQuadraticBounds)ÚBasePenÚ	BoundsPenÚControlBoundsPenc                   @   sJ   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )r	   aÉ  Pen to calculate the "control bounds" of a shape. This is the
    bounding box of all control points, so may be larger than the
    actual bounding box if there are curves that don't have points
    on their extremes.

    When the shape has been drawn, the bounds are available as the
    ``bounds`` attribute of the pen object. It's a 4-tuple::

            (xMin, yMin, xMax, yMax).

    If ``ignoreSinglePoints`` is True, single points are ignored.
    Fc                 C   s   t  | |¡ || _|  ¡  d S ©N)r   Ú__init__ÚignoreSinglePointsÚinit)ÚselfÚglyphSetr   © r   úl/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/pens/boundsPen.pyr      s   zControlBoundsPen.__init__c                 C   s   d | _ d | _d S r
   )ÚboundsÚ_start)r   r   r   r   r      s   
zControlBoundsPen.initc                 C   s   || _ | js|  ¡  d S d S r
   )r   r   Ú
_addMoveTo©r   Úptr   r   r   Ú_moveTo    s   ÿzControlBoundsPen._moveToc                 C   sJ   | j d u rd S | j}|rt|| j ƒ| _n| j \}}||||f| _d | _ d S r
   )r   r   r   )r   r   ÚxÚyr   r   r   r   %   s   


zControlBoundsPen._addMoveToc                 C   s   |   ¡  t| j|ƒ| _d S r
   )r   r   r   r   r   r   r   Ú_lineTo0   s   zControlBoundsPen._lineToc                 C   s6   |   ¡  | j}t||ƒ}t||ƒ}t||ƒ}|| _d S r
   ©r   r   r   ©r   Úbcp1Úbcp2r   r   r   r   r   Ú_curveToOne4   s   



zControlBoundsPen._curveToOnec                 C   s,   |   ¡  | j}t||ƒ}t||ƒ}|| _d S r
   r   ©r   Úbcpr   r   r   r   r   Ú_qCurveToOne<   s
   


zControlBoundsPen._qCurveToOneN)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r"   r   r   r   r   r	   	   s    
c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r   aŒ  Pen to calculate the bounds of a shape. It calculates the
    correct bounds even when the shape contains curves that don't
    have points on their extremes. This is somewhat slower to compute
    than the "control bounds".

    When the shape has been drawn, the bounds are available as the
    ``bounds`` attribute of the pen object. It's a 4-tuple::

            (xMin, yMin, xMax, yMax)
    c                 C   sN   |   ¡  | j}t||ƒ}t||ƒrt||ƒs"t|t|  ¡ |||ƒƒ}|| _d S r
   )r   r   r   r   r   r   Ú_getCurrentPointr   r   r   r   r   P   s   
ÿ
zBoundsPen._curveToOnec                 C   sB   |   ¡  | j}t||ƒ}t||ƒst|t|  ¡ ||ƒƒ}|| _d S r
   )r   r   r   r   r   r   r'   r    r   r   r   r"   Z   s   

ÿ
zBoundsPen._qCurveToOneN)r#   r$   r%   r&   r   r"   r   r   r   r   r   D   s    
N)ÚfontTools.misc.arrayToolsr   r   r   ÚfontTools.misc.bezierToolsr   r   ÚfontTools.pens.basePenr   Ú__all__r	   r   r   r   r   r   Ú<module>   s    ;