Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3
2øªj| ã @ s: d Z ddlmZ ddlmZmZ dgZG dd„ deƒZdS )zUfontTools.pens.pointInsidePen -- Pen implementing "point inside" testing
for shapes.
é )ÚBasePen)ÚsolveQuadraticÚ
solveCubicÚPointInsidePenc @ sl e Zd ZdZddd„Zddd„Zdd„ Zd d
„ Zdd„ Zd
d„ Z dd„ Z
dd„ Zdd„ Zdd„ Z
dd„ ZdS )r a: This pen implements "point inside" testing: to test whether
a given point lies inside the shape (black) or outside (white).
Instances of this class can be recycled, as long as the
setTestPoint() method is used to set the new point to test.
Typical usage:
pen = PointInsidePen(glyphSet, (100, 200))
outline.draw(pen)
isInside = pen.getResult()
Both the even-odd algorithm and the non-zero-winding-rule
algorithm are implemented. The latter is the default, specify
True for the evenOdd argument of __init__ or setTestPoint
to use the even-odd algorithm.
Fc C s t j| |ƒ | j||ƒ d S )N)r Ú__init__ÚsetTestPoint)ÚselfZglyphSetÚ testPointÚevenOdd© r úB/tmp/pip-build-_d5lkt3n/fonttools/fontTools/pens/pointInsidePen.pyr ) s zPointInsidePen.__init__c C s || _ || _d| _d| _dS )zASet the point to test. Call this _before_ the outline gets drawn.Nr )r r
Ú
firstPointÚintersectionCount)r r r
r r r r - s zPointInsidePen.setTestPointc C s | j d k r| jƒ | jS )N)r
Ú closePathr )r r r r Ú
getWinding4 s
zPointInsidePen.getWindingc C s* | j ƒ }| jr|d }n
| jdk}| S )z‡After the shape has been drawn, getResult() returns True if the test
point lies within the (black) shape, and False if it doesn't.
é r )r r
r )r ZwindingÚresultr r r Ú getResult; s
zPointInsidePen.getResultc C s, | j s
|r| jd7 _n| jd8 _d S )Né )r
r )r ZgoingUpr r r Ú_addIntersectionF s
zPointInsidePen._addIntersectionc C s | j d k r| jƒ || _ d S )N)r
r )r Úpointr r r Ú_moveToL s
zPointInsidePen._moveToc C s | j \}}| jƒ \}}|\}}||k r2||k r2d S ||k rF||k rFd S ||krZ||krZd S || }|| } || | }
||
| }||k rŽd S | j||kƒ d S )N)r Ú_getCurrentPointr )r r ÚxÚyÚx1Úy1Úx2Úy2ÚdxÚdyÚtÚixr r r Ú_lineToS s
zPointInsidePen._lineToc C sP | j \}}| jƒ \}}|\}} |\}
}|\}}
||k rR||k rR|
|k rR||k rRd S ||k rv| |k rv||k rv|
|k rvd S ||krš| |krš||krš|
|kršd S |}| | d }|| d | }|
| | | }tt||||| ƒƒ}dd„ |D ƒ}|söd S |}|| d }|
| d | }|| | | }||k}d }�x|D �]}||k�rN�q:|}|| }|| }d| | d| | | }|dk }}|dk�rÐd| | d| }|dk}| }|dk�rÐ|}|dk }}|| || || | }||k �rú�q:|d
k�r|�sF| j|ƒ n0|dk�r2|�rF| j|ƒ n||k�r:| j|ƒ �q:W d S )Ng @c S s( g | ] }d| kodkn r|‘qS )g g ð?g €r )Ú.0r! r r r ú
z s z.PointInsidePen._curveToOne..é r ç é g ð?ç €)r' r) )r r Úsortedr r ) r Zbcp1Zbcp2r r r r r r r Úx3Úy3Zx4Zy4r ÚcyZbyZayÚ solutionsr ZcxZbxZaxZaboveZlastTr! Út2Út3Ú directionZincomingGoingUpZoutgoingGoingUpZxtr r r Ú_curveToOneg sf
zPointInsidePen._curveToOnec C sp | j \}}| jƒ \}}|\}}|\} }
|}|| d }|
| | }
tt|
||| ƒƒ}dd„ |D ƒ}|sld S d S )Ng @c S s( g | ] }t | kotkn r|‘qS r )ZZERO_MINUS_EPSILONZONE_PLUS_EPSILON)r$ r! r r r r% ² s z:PointInsidePen._qCurveToOne_unfinished..)r r r* r )r Zbcpr r r r r r r r+ r, ÚcÚbÚar. r r r Ú_qCurveToOne_unfinished¦ s
z&PointInsidePen._qCurveToOne_unfinishedc C s$ | j ƒ | jkr| j| jƒ d | _d S )N)r r
ZlineTo)r r r r Ú
_closePath· s zPointInsidePen._closePathc C s t ‚dS )z,Insideness is not defined for open contours.N)ÚNotImplementedError)r r r r Ú_endPath¼ s zPointInsidePen._endPathN)F)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r r r r r r# r2 r6 r7 r9 r r r r r s
?N)r= ZfontTools.pens.basePenr ZfontTools.misc.bezierToolsr r Ú__all__r r r r r Ú s