
    h                     @    S r SSKJr  SSKJrJr  S/r " S S\5      rg)zUfontTools.pens.pointInsidePen -- Pen implementing "point inside" testing
for shapes.
    )BasePen)solveQuadratic
solveCubicPointInsidePenc                   b    \ rS rSrSrSS jrSS jrS rS rS r	S r
S	 rS
 rS rS rS rSrg)r      aR  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.

:Example:
    .. code-block::

        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.
c                 R    [         R                  " X5        U R                  X#5        g N)r   __init__setTestPoint)selfglyphSet	testPointevenOdds       O/var/www/html/env/lib/python3.13/site-packages/fontTools/pens/pointInsidePen.pyr   PointInsidePen.__init__)   s    ()-    c                 8    Xl         X l        SU l        SU l        g)zASet the point to test. Call this _before_ the outline gets drawn.Nr   )r   r   
firstPointintersectionCount)r   r   r   s      r   r   PointInsidePen.setTestPoint-   s    "!"r   c                 T    U R                   b  U R                  5         U R                  $ r
   )r   	closePathr   r   s    r   
getWindingPointInsidePen.getWinding4   s$    ??& NN%%%r   c                 z    U R                  5       nU R                  (       a  US-  nOU R                  S:g  nU(       $ )zAfter 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   windingresults      r   	getResultPointInsidePen.getResult;   s8     //#<<q[F++q0F:r   c                     U R                   (       d  U(       a  U =R                  S-  sl        g U =R                  S-  sl        g )N   )r   r   )r   goingUps     r   _addIntersectionPointInsidePen._addIntersectionF   s-    <<7""a'"""a'"r   c                 J    U R                   b  U R                  5         Xl         g r
   )r   r   )r   points     r   _moveToPointInsidePen._moveToL   s    ??& NNr   c                     U R                   u  p#U R                  5       u  pEUu  pgXB:  a  Xb:  a  g XS:  a  Xs:  a  g XS:  a  Xs:  a  g Xd-
  nXu-
  n	X5-
  U	-  n
X-  U-   nX:  a  g U R                  Xu:  5        g r
   )r   _getCurrentPointr&   )r   r)   xyx1y1x2y2dxdytixs               r   _lineToPointInsidePen._lineToS   s    ~~&&(6bf6bf7rwWWVrMVb[6bg&r   c           	         U R                   u  pEU R                  5       u  pgUu  pUu  pUu  pXd:  a  X:  a  X:  a  X:  a  g Xu:  a  X:  a  X:  a  X:  a  g Xu:  a  X:  a  X:  a  X:  a  g UnX-
  S-  nX-
  S-  U-
  nX-
  U-
  U-
  n[        [        UUXU-
  5      5      nU Vs/ s H  nSUs=::  a  S::  d  M  O  M  UPM     nnU(       d  g UnUU-
  S-  nX-
  S-  U-
  nUU-
  U-
  U-
  nXu:  nS nU H  nUU:X  a  M  UnUU-  nUU-  nSU-  U-  SU-  U-  -   U-   nUS:  =nnUS:X  a)  SU-  U-  SU-  -   nUS:  nU(       + nUS:X  a	  UnUS:  =nnUU-  UU-  -   UU-  -   U-   nUU:  a  M}  US;   a  U(       d  U R	                  U5        M  M  US:X  a  U(       a  U R	                  U5        M  M  UU:X  d  M  U R	                  U5        M     g s  snf )	Ng      @       g      ?   r              )r=   r;   )r   r-   sortedr   r&   ) r   bcp1bcp2r)   r.   r/   r0   r1   r2   r3   x3y3x4y4r5   cybyay	solutionsr6   r4   cxbxaxabovelastTt2t3	directionincomingGoingUpoutgoingGoingUpxts                                    r   _curveToOnePointInsidePen._curveToOneg   sD   ~~&&(6bfBF6bfBF7rw27rwg_g_r!Wr\B:b"bq&9:	 )>	1TQ-=#-=Q-=Q		>2g_g_r!"Wr\BAEzEQBaBBa"fqj025I09C?OoCFQJR/	"+c/&5"5# "I8ACGOob27"R!V+b0BAvK&))/: 'c"))/: # #o5))/:;  ?s   &G;G?Gc                    U R                   u  p4U R                  5       u  pVUu  pxUu  pUnX-
  S-  nX-
  U-
  n[        [        XX-
  5      5      nU Vs/ s H   n[        Us=::  a  [
        ::  d  M  O  M  UPM"     nnU(       d  g g s  snf )Ng       @)r   r-   r?   r   ZERO_MINUS_EPSILONONE_PLUS_EPSILON)r   bcpr)   r.   r/   r0   r1   r2   r3   rB   rC   cbarI   r6   s                   r   _qCurveToOne_unfinished&PointInsidePen._qCurveToOne_unfinished   s     ~~&&(VsNFQJ>!67	 
 !$6!$O?O$OA$OAy 	 
  
s   B1B5Bc                     U R                  5       U R                  :w  a  U R                  U R                  5        S U l        g r
   )r-   r   lineTor   s    r   
_closePathPointInsidePen._closePath   s.      "doo5KK(r   c                     [         e)z,Insideness is not defined for open contours.)NotImplementedErrorr   s    r   _endPathPointInsidePen._endPath   s    !!r   )r   r   r   r   N)F)__name__
__module____qualname____firstlineno____doc__r   r   r   r!   r&   r*   r8   rU   r^   rb   rf   __static_attributes__ r   r   r   r      s?    8.#&	( '(;;~&
"r   N)rl   fontTools.pens.basePenr   fontTools.misc.bezierToolsr   r   __all__r   rn   r   r   <module>rr      s*    + A 
t"W t"r   