
    jke                     v   d Z ddlmZmZmZ ddlmZ ddlZddlm	Z	 	 ddl
Z
e
j                  Z e	dg d	      Zg d
ZdUdZd Z e
j(                  e
j*                         e
j,                  e
j.                  e
j.                  e
j.                  e
j.                         e
j,                  e
j*                  e
j*                  e
j*                        d                      Z e
j(                  e
j*                         e
j,                  e
j.                  e
j.                  e
j.                  e
j.                         e
j,                  e
j*                  e
j*                        dUd                     ZdZdZe
j8                  e
j:                   e
j(                  e
j*                         e
j,                  e
j.                  e
j.                        d                             Ze
j8                  e
j:                   e
j(                  e
j*                         e
j,                  e
j*                        d                             Zd Z  e
j(                  e
j*                         e
j,                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                         e
j,                  e
j*                  e
j*                  e
j*                  e
j*                  e
j*                  e
j*                  e
j*                        d                      Z!d Z" e
j(                  e
j*                         e
j,                  e
j.                  e
j.                  e
j.                         e
j,                  e
j*                  e
j*                  e
j*                        d                       Z#d! Z$d" Z% e
j(                  e
j*                         e
j,                  e
j.                  e
j.                  e
j.                  e
j.                         e
j,                  e
j*                  e
j*                  e
j*                  e
j*                  e
j*                  #      d$                      Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z, e
j,                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  +      d,        Z- e
j(                  e
j.                         e
j,                  e
j*                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  -       e
j,                  e
j*                  e
j*                  e
j*                  e
j*                  .      d/                      Z.d0 Z/d1 Z0 e
j,                  e
j.                  e
j.                  e
j.                  e
j.                  e
j*                  e
j*                  e
j*                  e
j*                  e
j*                  e
j.                  e
j.                  e
j.                  e
j.                  2      d3        Z1dd4lm2Z2m3Z3m4Z4m5Z5 e2fd5Z6d6 Z7d7 Z8d8 Z9e
j8                  e
j:                   e
j,                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  9      d:                      Z:d; Z;d< Z<e
j8                  e
j:                   e
j,                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  e
j.                  =      d>                      Z=d? Z>d@ Z?dA Z@ e
j(                  e
j.                         e
j,                  e
j*                  e
j.                  e
j.                  e
j.                  e
j.                  B       e
j,                  e
j*                  e
j*                  e
j*                  C      dD                      ZAdE ZBdF ZCdG ZDdH ZEdI ZFdJ ZGdK ZHdL ZIdM ZJ	 dVdNZKdO ZLdP ZMdQ ZNdR ZOdS ZPeQdTk(  r4ddlRZRddlSZS eRj                   eSj                         j                         yy# eef$ r ddlm
Z
 dZY w xY w)WzNfontTools.misc.bezierTools.py -- tools for working with Bezier path segments.
    )
calcBoundssectRectrectArea)IdentityN)
namedtuple)cythonFIntersectionptt1t2)approximateCubicArcLengthapproximateCubicArcLengthCapproximateQuadraticArcLengthapproximateQuadraticArcLengthCcalcCubicArcLengthcalcCubicArcLengthCcalcQuadraticArcLengthcalcQuadraticArcLengthCcalcCubicBoundscalcQuadraticBounds	splitLinesplitQuadratic
splitCubicsplitQuadraticAtTsplitCubicAtTsplitCubicAtTCsplitCubicIntoTwoAtTCsolveQuadratic
solveCubicquadraticPointAtTcubicPointAtTcubicPointAtTClinePointAtTsegmentPointAtTlineLineIntersectionscurveLineIntersectionscurveCurveIntersectionssegmentSegmentIntersectionsc                 P    t        t        |  t        | t        | t        | |      S )a  Calculates the arc length for a cubic Bezier segment.

    Whereas :func:`approximateCubicArcLength` approximates the length, this
    function calculates it by "measuring", recursively dividing the curve
    until the divided segments are shorter than ``tolerance``.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples.
        tolerance: Controls the precision of the calcuation.

    Returns:
        Arc length value.
    )r   complex)pt1pt2pt3pt4	tolerances        </usr/lib/python3/dist-packages/fontTools/misc/bezierTools.pyr   r   8   s,     w}gsmWc]I     c                 |    | d||z   z  z   |z   dz  }||z   |z
  | z
  dz  }| | |z   dz  ||z
  |f|||z   ||z   dz  |ffS )N   g      ?      ? )p0p1p2p3midderiv3s         r1   _split_cubic_into_twor=   K   so    R"W"e
+C2glR5(F	b2g_cFlC0	cFlR"WOR0 r2   )r7   r8   r9   r:   )multarchboxc                     t        ||z
        }t        ||z
        t        ||z
        z   t        ||z
        z   }|| z  |k\  r||z   dz  S t        ||||      \  }}t        | g| t        | g| z   S Nr5   )absr=   _calcCubicArcLengthCRecurse)	r>   r7   r8   r9   r:   r?   r@   onetwos	            r1   rD   rD   T   s     rBw<D
b2g,R"W
%BG
4Cd{cs
c!!(RR8S*46#69T:
:
 
 	
r2   r,   r-   r.   r/   )r0   r>   c                 0    dd|z  z   }t        || |||      S )zCalculates the arc length for a cubic Bezier segment.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as complex numbers.
        tolerance: Controls the precision of the calcuation.

    Returns:
        Arc length value.
          ?g      ?)rD   )r,   r-   r.   r/   r0   r>   s         r1   r   r   h   s%    * y D&tS#sC@@r2      g|=v1v2c                 <    | |j                         z  j                  S N)	conjugaterealrK   s     r1   _dotrR      s    
 %%%r2   xc                 v    | t        j                  | dz  dz         z  dz  t        j                  |       dz  z   S )N      )mathsqrtasinhrS   s    r1   _intSecAtanr[      s7     tyyA""Q&A):::r2   c                 @    t        t        |  t        | t        |       S )a  Calculates the arc length for a quadratic Bezier segment.

    Args:
        pt1: Start point of the Bezier as 2D tuple.
        pt2: Handle point of the Bezier as 2D tuple.
        pt3: End point of the Bezier as 2D tuple.

    Returns:
        Arc length value.

    Example::

        >>> calcQuadraticArcLength((0, 0), (0, 0), (0, 0)) # empty segment
        0.0
        >>> calcQuadraticArcLength((0, 0), (50, 0), (80, 0)) # collinear points
        80.0
        >>> calcQuadraticArcLength((0, 0), (0, 50), (0, 80)) # collinear points vertical
        80.0
        >>> calcQuadraticArcLength((0, 0), (50, 20), (100, 40)) # collinear points
        107.70329614269008
        >>> calcQuadraticArcLength((0, 0), (0, 100), (100, 0))
        154.02976155645263
        >>> calcQuadraticArcLength((0, 0), (0, 50), (100, 0))
        120.21581243984076
        >>> calcQuadraticArcLength((0, 0), (50, -10), (80, 50))
        102.53273816445825
        >>> calcQuadraticArcLength((0, 0), (40, 0), (-40, 0)) # collinear points, control point outside
        66.66666666666667
        >>> calcQuadraticArcLength((0, 0), (40, 0), (0, 0)) # collinear points, looping back
        40.0
    )r   r+   r,   r-   r.   s      r1   r   r      s     @ #7C='3-#OOr2   )r,   r-   r.   d0d1dn)scaleorigDistabx0x1Lenc                    || z
  }||z
  }||z
  }|dz  }t        |      }|dk(  rt        || z
        S t        ||      }t        |      t        k  rDt        ||      dk\  rt        || z
        S t        |      t        |      }
}	|	|	z  |
|
z  z   |	|
z   z  S t        ||      |z  }t        ||      |z  }t        dt        |      t        |      z
  z  |z  |||z
  z  z        }|S )a$  Calculates the arc length for a quadratic Bezier segment.

    Args:
        pt1: Start point of the Bezier as a complex number.
        pt2: Handle point of the Bezier as a complex number.
        pt3: End point of the Bezier as a complex number.

    Returns:
        Arc length value.
    y              ?        r   rV   )rC   rR   epsilonr[   )r,   r-   r.   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   s                 r1   r   r      s    @ 
sB	sB
RA	BAFE|39~Ar{H
8}wB<1sSy>!2wB1AA!a%((	ax	B	ax	B
a;r?[_45@ERRTWDUV
WCJr2   c                 @    t        t        |  t        | t        |       S )a  Calculates the arc length for a quadratic Bezier segment.

    Uses Gauss-Legendre quadrature for a branch-free approximation.
    See :func:`calcQuadraticArcLength` for a slower but more accurate result.

    Args:
        pt1: Start point of the Bezier as 2D tuple.
        pt2: Handle point of the Bezier as 2D tuple.
        pt3: End point of the Bezier as 2D tuple.

    Returns:
        Approximate arc length value.
    )r   r+   r]   s      r1   r   r      s      *'3-#QTVVr2   r]   )v0rL   rM   c                     t        d| z  d|z  z   d|z  z         }t        || z
        dz  }t        d| z  d|z  z
  d|z  z         }||z   |z   S )a  Calculates the arc length for a quadratic Bezier segment.

    Uses Gauss-Legendre quadrature for a branch-free approximation.
    See :func:`calcQuadraticArcLength` for a slower but more accurate result.

    Args:
        pt1: Start point of the Bezier as a complex number.
        pt2: Handle point of the Bezier as a complex number.
        pt3: End point of the Bezier as a complex number.

    Returns:
        Approximate arc length value.
    g̔xb߿gb?gFVW?gqq?gFVWg̔xb?rC   )r,   r-   r.   rm   rL   rM   s         r1   r   r      s|    B 
S #4s#::=ORU=UU
B 
S3Y,	,B	c!$5$;;>ORU>UU
B 7R<r2   c                 \   t        | ||      \  \  }}\  }}\  }}|dz  }	|dz  }
g }|	dk7  r|j                  | |	z         |
dk7  r|j                  | |
z         |D cg c]2  }d|cxk  rdk  r%n n"||z  |z  ||z  z   |z   ||z  |z  ||z  z   |z   f4 c}| |gz   }t        |      S c c}w )a  Calculates the bounding rectangle for a quadratic Bezier segment.

    Args:
        pt1: Start point of the Bezier as a 2D tuple.
        pt2: Handle point of the Bezier as a 2D tuple.
        pt3: End point of the Bezier as a 2D tuple.

    Returns:
        A four-item tuple representing the bounding rectangle ``(xMin, yMin, xMax, yMax)``.

    Example::

        >>> calcQuadraticBounds((0, 0), (50, 100), (100, 0))
        (0, 0, 100, 50.0)
        >>> calcQuadraticBounds((0, 0), (100, 0), (100, 100))
        (0.0, 0.0, 100, 100)
           @r   rW   )calcQuadraticParametersappendr   )r,   r-   r.   axaybxbycxcyax2ay2rootstpointss                 r1   r   r   *  s    $ $;3S#I HRhr2R
s(C
s(CE
axbS3Y
axbS3Y :A: 
a!b1f	r	!26A:Q#6#;< 
c
	F
 fs   7B)c                 N    t        t        |  t        | t        | t        |       S )a  Approximates the arc length for a cubic Bezier segment.

    Uses Gauss-Lobatto quadrature with n=5 points to approximate arc length.
    See :func:`calcCubicArcLength` for a slower but more accurate result.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples.

    Returns:
        Arc length value.

    Example::

        >>> approximateCubicArcLength((0, 0), (25, 100), (75, 100), (100, 0))
        190.04332968932817
        >>> approximateCubicArcLength((0, 0), (50, 0), (100, 50), (100, 100))
        154.8852074945903
        >>> approximateCubicArcLength((0, 0), (50, 0), (100, 0), (150, 0)) # line; exact result should be 150.
        149.99999999999991
        >>> approximateCubicArcLength((0, 0), (50, 0), (100, 0), (-50, 0)) # cusp; exact result should be 150.
        136.9267662156362
        >>> approximateCubicArcLength((0, 0), (50, 0), (100, -50), (-50, 0)) # cusp
        154.80848416537057
    )r   r+   rG   s       r1   r   r   L  s*    2 &w}gsmWc] r2   )rm   rL   rM   v3v4c                    t        || z
        dz  }t        d| z  d|z  z   d|z  z   d|z  z         }t        || z
  |z   |z
        dz  }t        d| z  d|z  z
  d|z  z
  d|z  z         }t        ||z
        dz  }||z   |z   |z   |z   S )	zApproximates the arc length for a cubic Bezier segment.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as complex numbers.

    Returns:
        Arc length value.
    g333333?gc1g85$t?gu|Y?g#$?g?g#$gc1?ro   )	r,   r-   r.   r/   rm   rL   rM   r   r   s	            r1   r   r   j  s    > 
S3Y$	B	S 
c
!	"
c
!	" c
!	"
B 
S3Y_s"	#&9	9B	S 
c
!	"
c
!	" c
!	"
B 
S3Y$	B7R<"r!!r2   c                    t        | |||      \  \  }}\  }}\  }}	\  }
}|dz  }|dz  }|dz  }|dz  }t        |||      D cg c]  }d|cxk  rdk  sn n| }}t        |||	      D cg c]  }d|cxk  rdk  sn n| }}||z   }|D cg c]<  }||z  |z  |z  ||z  |z  z   ||z  z   |
z   ||z  |z  |z  ||z  |z  z   |	|z  z   |z   f> c}| |gz   }t        |      S c c}w c c}w c c}w )aX  Calculates the bounding rectangle for a quadratic Bezier segment.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples.

    Returns:
        A four-item tuple representing the bounding rectangle ``(xMin, yMin, xMax, yMax)``.

    Example::

        >>> calcCubicBounds((0, 0), (25, 100), (75, 100), (100, 0))
        (0, 0, 100, 75.0)
        >>> calcCubicBounds((0, 0), (50, 0), (100, 50), (100, 100))
        (0.0, 0.0, 100, 100)
        >>> print("%f %f %f %f" % calcCubicBounds((50, 0), (0, 100), (100, 100), (50, 0)))
        35.566243 0.000000 64.433757 75.000000
          @rq   r   rW   )calcCubicParametersr   r   )r,   r-   r.   r/   rt   ru   rv   rw   rx   ry   dxdyax3ay3bx2by2r}   xRootsyRootsr|   r~   s                        r1   r   r     sC   $ .Ac3PS-T*HRhr2R(2r
s(C
s(C
s(C
s(C'S"5DAa!aDFD'S"5DAa!aDFDVOE 
  FQJNR!VaZ'"q&025FQJNR!VaZ'"q&025	
 
c
F f EDs   C#C#,C(=C(AC-c                     | \  }}|\  }}||z
  }||z
  }	|}
|}||	f|   }|dk(  r| |fgS ||
|f|   z
  |z  }d|cxk  rdk  rn n||z  |
z   |	|z  |z   f}| |f||fgS | |fgS )a  Split a line at a given coordinate.

    Args:
        pt1: Start point of line as 2D tuple.
        pt2: End point of line as 2D tuple.
        where: Position at which to split the line.
        isHorizontal: Direction of the ray splitting the line. If true,
            ``where`` is interpreted as a Y coordinate; if false, then
            ``where`` is interpreted as an X coordinate.

    Returns:
        A list of two line segments (each line segment being two 2D tuples)
        if the line was successfully split, or a list containing the original
        line.

    Example::

        >>> printSegments(splitLine((0, 0), (100, 100), 50, True))
        ((0, 0), (50, 50))
        ((50, 50), (100, 100))
        >>> printSegments(splitLine((0, 0), (100, 100), 100, True))
        ((0, 0), (100, 100))
        >>> printSegments(splitLine((0, 0), (100, 100), 0, True))
        ((0, 0), (0, 0))
        ((0, 0), (100, 100))
        >>> printSegments(splitLine((0, 0), (100, 100), 0, False))
        ((0, 0), (0, 0))
        ((0, 0), (100, 100))
        >>> printSegments(splitLine((100, 0), (0, 0), 50, False))
        ((100, 0), (50, 0))
        ((50, 0), (0, 0))
        >>> printSegments(splitLine((0, 100), (0, 0), 50, True))
        ((0, 100), (0, 50))
        ((0, 50), (0, 0))
    r   rW   r6   )r,   r-   whereisHorizontalpt1xpt1ypt2xpt2yrt   ru   rv   rw   rd   r}   midPts                  r1   r   r     s    H JD$JD$	B	B	B	B	RAAvc
|	"b,'	'1,AAzzQR!Vb[(eucl++c
|r2   c                     t        | ||      \  }}}t        ||   ||   ||   |z
        }t        d |D              }|s| ||fgS t        |||g| S )a  Split a quadratic Bezier curve at a given coordinate.

    Args:
        pt1,pt2,pt3: Control points of the Bezier as 2D tuples.
        where: Position at which to split the curve.
        isHorizontal: Direction of the ray splitting the curve. If true,
            ``where`` is interpreted as a Y coordinate; if false, then
            ``where`` is interpreted as an X coordinate.

    Returns:
        A list of two curve segments (each curve segment being three 2D tuples)
        if the curve was successfully split, or a list containing the original
        curve.

    Example::

        >>> printSegments(splitQuadratic((0, 0), (50, 100), (100, 0), 150, False))
        ((0, 0), (50, 100), (100, 0))
        >>> printSegments(splitQuadratic((0, 0), (50, 100), (100, 0), 50, False))
        ((0, 0), (25, 50), (50, 50))
        ((50, 50), (75, 50), (100, 0))
        >>> printSegments(splitQuadratic((0, 0), (50, 100), (100, 0), 25, False))
        ((0, 0), (12.5, 25), (25, 37.5))
        ((25, 37.5), (62.5, 75), (100, 0))
        >>> printSegments(splitQuadratic((0, 0), (50, 100), (100, 0), 25, True))
        ((0, 0), (7.32233, 14.6447), (14.6447, 25))
        ((14.6447, 25), (50, 75), (85.3553, 25))
        ((85.3553, 25), (92.6777, 14.6447), (100, -7.10543e-15))
        >>> # XXX I'm not at all sure if the following behavior is desirable:
        >>> printSegments(splitQuadratic((0, 0), (50, 100), (100, 0), 50, True))
        ((0, 0), (25, 50), (50, 50))
        ((50, 50), (50, 50), (50, 50))
        ((50, 50), (75, 50), (100, 0))
    c              3   >   K   | ]  }d |cxk  rdk  sn n|  ywr   rW   Nr6   .0r}   s     r1   	<genexpr>z!splitQuadratic.<locals>.<genexpr>"       :QqAzzq:   
)rr   r   sorted_splitQuadraticAtT)	r,   r-   r.   r   r   rd   re   c	solutionss	            r1   r   r     ss    F &c34GAq!	,<!L/E*AI :)::Ic3  aA2	22r2   c                     t        | |||      \  }}}}	t        ||   ||   ||   |	|   |z
        }
t        d |
D              }
|
s| |||fgS t        ||||	g|
 S )a  Split a cubic Bezier curve at a given coordinate.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples.
        where: Position at which to split the curve.
        isHorizontal: Direction of the ray splitting the curve. If true,
            ``where`` is interpreted as a Y coordinate; if false, then
            ``where`` is interpreted as an X coordinate.

    Returns:
        A list of two curve segments (each curve segment being four 2D tuples)
        if the curve was successfully split, or a list containing the original
        curve.

    Example::

        >>> printSegments(splitCubic((0, 0), (25, 100), (75, 100), (100, 0), 150, False))
        ((0, 0), (25, 100), (75, 100), (100, 0))
        >>> printSegments(splitCubic((0, 0), (25, 100), (75, 100), (100, 0), 50, False))
        ((0, 0), (12.5, 50), (31.25, 75), (50, 75))
        ((50, 75), (68.75, 75), (87.5, 50), (100, 0))
        >>> printSegments(splitCubic((0, 0), (25, 100), (75, 100), (100, 0), 25, True))
        ((0, 0), (2.29379, 9.17517), (4.79804, 17.5085), (7.47414, 25))
        ((7.47414, 25), (31.2886, 91.6667), (68.7114, 91.6667), (92.5259, 25))
        ((92.5259, 25), (95.202, 17.5085), (97.7062, 9.17517), (100, 1.77636e-15))
    c              3   >   K   | ]  }d |cxk  rdk  sn n|  ywr   r6   r   s     r1   r   zsplitCubic.<locals>.<genexpr>G  r   r   )r   r    r   _splitCubicAtT)r,   r-   r.   r/   r   r   rd   re   r   r`   r   s              r1   r   r   (  s    6 %S#sC8JAq!Q	,<!L/1\?U;RI :)::Ic3$%%!Q11y11r2   c                 @    t        | ||      \  }}}t        |||g| S )a  Split a quadratic Bezier curve at one or more values of t.

    Args:
        pt1,pt2,pt3: Control points of the Bezier as 2D tuples.
        *ts: Positions at which to split the curve.

    Returns:
        A list of curve segments (each curve segment being three 2D tuples).

    Examples::

        >>> printSegments(splitQuadraticAtT((0, 0), (50, 100), (100, 0), 0.5))
        ((0, 0), (25, 50), (50, 50))
        ((50, 50), (75, 50), (100, 0))
        >>> printSegments(splitQuadraticAtT((0, 0), (50, 100), (100, 0), 0.5, 0.75))
        ((0, 0), (25, 50), (50, 50))
        ((50, 50), (62.5, 50), (75, 37.5))
        ((75, 37.5), (87.5, 25), (100, 0))
    )rr   r   )r,   r-   r.   tsrd   re   r   s          r1   r   r   M  s,    ( &c34GAq!aA+++r2   c                 F    t        | |||      \  }}}}t        ||||g| S )a   Split a cubic Bezier curve at one or more values of t.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as 2D tuples.
        *ts: Positions at which to split the curve.

    Returns:
        A list of curve segments (each curve segment being four 2D tuples).

    Examples::

        >>> printSegments(splitCubicAtT((0, 0), (25, 100), (75, 100), (100, 0), 0.5))
        ((0, 0), (12.5, 50), (31.25, 75), (50, 75))
        ((50, 75), (68.75, 75), (87.5, 50), (100, 0))
        >>> printSegments(splitCubicAtT((0, 0), (25, 100), (75, 100), (100, 0), 0.5, 0.75))
        ((0, 0), (12.5, 50), (31.25, 75), (50, 75))
        ((50, 75), (59.375, 75), (68.75, 68.75), (77.3438, 56.25))
        ((77.3438, 56.25), (85.9375, 43.75), (93.75, 25), (100, 0))
    )r   r   	r,   r-   r.   r/   r   rd   re   r   r`   s	            r1   r   r   e  s2    ( %S#sC8JAq!Q!Q1*r**r2   )r,   r-   r.   r/   rd   re   r   r`   c              '   d   K   t        | |||      \  }}}}t        ||||g| E d{    y7 w)a  Split a cubic Bezier curve at one or more values of t.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as complex numbers..
        *ts: Positions at which to split the curve.

    Yields:
        Curve segments (each curve segment being four complex numbers).
    N)calcCubicParametersC_splitCubicAtTCr   s	            r1   r   r   }  s9     ( &c3S9JAq!Qq!Q/B///s   &0.0)r}   r,   r-   r.   r/   pointAtToff1off2)r   _1_t_1_t_2_2_t_1_tc                    ||z  }d|z
  }||z  }d|z  |z  }||z  | z  d||z  |z  ||z  |z  z   z  z   ||z  |z  z   }	|| z  ||z  z   ||z  z   }
||z  ||z  z   ||z  z   }| || z
  |z  z   }|||z
  |z  z   }| ||
|	f|	|||ffS )a  Split a cubic Bezier curve at t.

    Args:
        pt1,pt2,pt3,pt4: Control points of the Bezier as complex numbers.
        t: Position at which to split the curve.

    Returns:
        A tuple of two curve segments (each curve segment being four complex numbers).
    rW   rV   r4   r6   )r,   r-   r.   r/   r}   r   r   r   r   r   r   r   s               r1   r   r     s    0 
QBq5DD[F1ut|Ha6A:#3dRi#o#EFFaRUU  C<(S.(283DC<(S.(283D
sa
C
sd"
"C#tX&4c(BCCr2   c                    t        |      }g }|j                  dd       |j                  d       | \  }}|\  }}|\  }	}
t        t	        |      dz
        D ]  }||   }||dz      }||z
  }||z  }||z  }||z  }d|z  |z  |z   |z  }d|z  |z  |z   |z  }||z  }||z  ||z  z   |	z   }||z  ||z  z   |
z   }t        ||f||f||f      \  }}}|j                  |||f        |S )Nr   rj   rI   rW   rV   )listinsertrs   rangelencalcQuadraticPoints)rd   re   r   r   segmentsrt   ru   rv   rw   rx   ry   ir   r   deltadelta_2a1xa1yb1xb1yt1_2c1xc1yr,   r-   r.   s                             r1   r   r     s8   	bBHIIaIIcNFBFBFB3r7Q; )UAYR%-7l7l2v{R5(2v{R5(Bw4i"r'!B&4i"r'!B&+S#Jc
S#JOS#c3()  Or2   c                 j   t        |      }|j                  dd       |j                  d       g }| \  }}|\  }}	|\  }
}|\  }}t        t	        |      dz
        D ]  }||   }||dz      }||z
  }||z  }||z  }||z  }||z  }||z  }||z  }d|z  |z  |z   |z  }d|z  |z  |	z   |z  }d|z  |z  |
z   d|z  |z  z   |z  }d|	z  |z  |z   d|z  |z  z   |z  }||z  ||z  z   |
|z  z   |z   }||z  |	|z  z   ||z  z   |z   }t        ||f||f||f||f      \  }}} }!|j                  ||| |!f        |S Nr   rj   rI   rW   r4   rV   )r   r   rs   r   r   calcCubicPoints)"rd   re   r   r`   r   r   rt   ru   rv   rw   rx   ry   r   r   r   r   r   r   r   delta_3r   t1_3r   r   r   r   r   r   d1xd1yr,   r-   r.   r/   s"                                     r1   r   r     s   	bBIIaIIcNHFBFBFBFB3r7Q; .UAYR%-'/BwDy 7l7l2v{R7*2v{R7*2v{R!b&4-/582v{R!b&4-/584i"t)#b2g-24i"t)#b2g-2,#Jc
S#Jc

S#s 	c3,--.. Or2   )rd   re   r   r`   r   r   r   r   r   a1b1c1r_   c              '     K   t        |      }|j                  dd       |j                  d       t        t	        |      dz
        D ]  }||   }||dz      }||z
  }||z  }	||	z  }
||z  }||z  }| |
z  }d| z  |z  |z   |	z  }d|z  |z  |z   d| z  |z  z   |z  }| |z  ||z  z   ||z  z   |z   }t        ||||      \  }}}}||||f  y wr   )r   r   rs   r   r   calcCubicPointsC)rd   re   r   r`   r   r   r   r   r   r   r   r   r   r   r   r   r_   r,   r-   r.   r/   s                        r1   r   r     s      
bBIIaIIcN3r7Q; #UAYR%-'/BwDy [!ebj1n'!ebj1nq1ut|+u4XD 1r6)A--b"b"=S#sCc""!#s   CC)rY   acoscospic                     t        |       t        k  rt        |      t        k  rg }|S | |z  g}|S ||z  d| z  |z  z
  }|dk\  r" ||      }| |z   dz  | z  | |z
  dz  | z  g}|S g }|S )uK  Solve a quadratic equation.

    Solves *a*x*x + b*x + c = 0* where a, b and c are real.

    Args:
        a: coefficient of *x²*
        b: coefficient of *x*
        c: constant term

    Returns:
        A list of roots. Note that the returned list is neither guaranteed to
        be sorted nor to contain unique values!
          @rj   rq   rC   rk   )rd   re   r   rY   r|   DDrDDs          r1   r   r   (  s     1vq6GE L R!VHE L US1Wq[ 9r(Cb3h#%)QBH+;a+?@E L ELr2   c           
         t        |       t        k  rt        |||      S t        |       } || z  }|| z  }|| z  }||z  d|z  z
  dz  }d|z  |z  |z  d|z  |z  z
  d|z  z   dz  }||z  }	||z  |z  }
|	t        k  rdn|	}	t        |
      t        k  rdn|
}
|	|
z
  }|	dk(  r|
dk(  rt	        | dz  t
              }|||gS |t        dz  k  rut        t        t        |t        |
      z  d	      d
            }dt        |      z  }|dz  }|t        |dz        z  |z
  }|t        |dt        z  z   dz        z  |z
  }|t        |dt        z  z   dz        z  |z
  }t        |||g      \  }}}||z
  t        k  r*||z
  t        k  rt	        ||z   |z   dz  t
              x}x}}n||z
  t        k  r)t	        ||z   dz  t
              x}}t	        |t
              }ne||z
  t        k  r)t	        |t
              }t	        ||z   dz  t
              x}}n0t	        |t
              }t	        |t
              }t	        |t
              }|||gS t        t        |      t        |      z   d      }|||z  z   }|dk\  r| }t	        ||dz  z
  t
              }|gS )ut  Solve a cubic equation.

    Solves *a*x*x*x + b*x*x + c*x + d = 0* where a, b, c and d are real.

    Args:
        a: coefficient of *x³*
        b: coefficient of *x²*
        c: coefficient of *x*
        d: constant term

    Returns:
        A list of roots. Note that the returned list is neither guaranteed to
        be sorted nor to contain unique values!

    Examples::

        >>> solveCubic(1, 1, -6, 0)
        [-3.0, -0.0, 2.0]
        >>> solveCubic(-10.0, -9.0, 48.0, -29.0)
        [-2.9, 1.0, 1.0]
        >>> solveCubic(-9.875, -9.0, 47.625, -28.75)
        [-2.911392, 1.0, 1.0]
        >>> solveCubic(1.0, -4.5, 6.75, -3.375)
        [1.5, 1.5, 1.5]
        >>> solveCubic(-12.0, 18.0, -9.0, 1.50023651123)
        [0.5, 0.5, 0.5]
        >>> solveCubic(
        ...     9.0, 0.0, 0.0, -7.62939453125e-05
        ... ) == [-0.0, -0.0, -0.0]
        True
    r   g      "@rq   g      ;@g      K@r   rj   r5   rI   g      g       r   UUUUUU?)rC   rk   r   floatroundepsilonDigitsr   maxminrY   r   r   r   pow)rd   re   r   r`   r   a2a3QRR2Q3R2_Q3rT   thetarQ2a1_3rf   rg   x2s                      r1   r    r    I  s   L 1v aA&&aA	
QB	
QB	
QB	b38	s"A	rB	cBhm	+dRi	74?A	
QB	
QB7lB"gRBGE	SyR3Y2#)]+1ay	'C-	SQb\3/67T!WnCx3us{##d*3b(C/00473b(C/0047RRL)
B7Wb7!2 "r'B,#!5}EEBEb"WwR"WO];;Br=)B"Wwr=)BR"WO];;Br=)Br=)Br=)BB|Uc!f$g.AI8A!b3h,.s
r2   c                 v    |\  }}|\  }}| \  }}||z
  dz  }	||z
  dz  }
||z
  |	z
  }||z
  |
z
  }||f|	|
f||ffS )Nrq   r6   )r,   r-   r.   r   y2x3y3rx   ry   rv   rw   rt   ru   s                r1   rr   rr     sj    FBFBFB
r'SB
r'SB	b2B	b2B8b"XBx''r2   c                     |\  }}|\  }}|\  }}	| \  }
}||
z
  dz  }||z
  dz  }||z
  dz  |z
  }||z
  dz  |z
  }||
z
  |z
  |z
  }|	|z
  |z
  |z
  }||f||f||f|
|ffS Nr   r6   )r,   r-   r.   r/   r   r   r   r   x4y4r   r   rx   ry   rv   rw   rt   ru   s                     r1   r   r     s    FBFBFBFB
r'SB
r'SB
r'S2	B
r'S2	B	b2	B	b2	B8b"XBx"b11r2   )r,   r-   r.   r/   rd   re   r   c                 J    || z
  dz  }||z
  dz  |z
  }|| z
  |z
  |z
  }|||| fS r   r6   )r,   r-   r.   r/   r   re   rd   s          r1   r   r     sE     
scA	scAAc	AAq!S>r2   c                 ~    | \  }}|\  }}|\  }}|}	|}
|dz  |z   }|dz  |z   }||z   |z   }||z   |z   }|	|
f||f||ffS rB   r6   )rd   re   r   rt   ru   rv   rw   rx   ry   rg   y1r   r   r   r   s                  r1   r   r     st    FBFBFB	B	B
s(bB
s(bB	b2B	b2B8b"XBx''r2   c                     | \  }}|\  }}|\  }}	|\  }
}|
}|}|dz  |
z   }|	dz  |z   }||z   dz  |z   }||	z   dz  |z   }||
z   |z   |z   }||z   |	z   |z   }||f||f||f||ffS r   r6   )rd   re   r   r`   rt   ru   rv   rw   rx   ry   r   r   rg   r   r   r   r   r   r   r   s                       r1   r   r     s    FBFBFBFB	B	B
s(bB
s(bB
r'S2	B
r'S2	B	b2	B	b2	B8b"XBx"b11r2   rd   re   r   r`   r9   r:   p4c                 J    |dz  |z   }||z   dz  |z   }| |z   |z   |z   }||||fS )Nr   r6   r   s          r1   r   r     sC     
eqB
a%E	R	B	
QQBr2r?r2   c                 R    | d   d|z
  z  |d   |z  z   | d   d|z
  z  |d   |z  z   fS )zFinds the point at time `t` on a line.

    Args:
        pt1, pt2: Coordinates of the line as 2D tuples.
        t: The time along the line.

    Returns:
        A 2D tuple with the coordinates of the point.
    r   rW   r6   )r,   r-   r}   s      r1   r$   r$   	  sC     Vq1uA
*c!fA.>Q!.KMMr2   c                     d|z
  d|z
  z  | d   z  dd|z
  z  |z  |d   z  z   ||z  |d   z  z   }d|z
  d|z
  z  | d   z  dd|z
  z  |z  |d   z  z   ||z  |d   z  z   }||fS )zFinds the point at time `t` on a quadratic curve.

    Args:
        pt1, pt2, pt3: Coordinates of the curve as 2D tuples.
        t: The time along the curve.

    Returns:
        A 2D tuple with the coordinates of the point.
    rW   r   rV   r6   )r,   r-   r.   r}   rT   ys         r1   r!   r!     s     
Q1q5CF"Q!a%[1_s1v%==AANA	
Q1q5CF"Q!a%[1_s1v%==AANAq6Mr2   c                     ||z  }d|z
  }||z  }||z  | d   z  d||z  |d   z  ||z  |d   z  z   z  z   ||z  |d   z  z   }||z  | d   z  d||z  |d   z  ||z  |d   z  z   z  z   ||z  |d   z  z   }	||	fS )zFinds the point at time `t` on a cubic curve.

    Args:
        pt1, pt2, pt3, pt4: Coordinates of the curve as 2D tuples.
        t: The time along the curve.

    Returns:
        A 2D tuple with the coordinates of the point.
    rW   r   r4   r6   )
r,   r-   r.   r/   r}   r   r   r   rT   r   s
             r1   r"   r"   %  s     
QBq5DD[FA
vzCF"TBYQ%77
8	9
q&3q6/	  	A
vzCF"TBYQ%77
8	9
q&3q6/	 
 q6Mr2   )r}   r,   r-   r.   r/   )r   r   r   c                 l    ||z  }d|z
  }||z  }||z  | z  d||z  |z  ||z  |z  z   z  z   ||z  |z  z   S )zFinds the point at time `t` on a cubic curve.

    Args:
        pt1, pt2, pt3, pt4: Coordinates of the curve as complex numbers.
        t: The time along the curve.

    Returns:
        A complex number with the coordinates of the point.
    rW   r4   r6   )r,   r-   r.   r/   r}   r   r   r   s           r1   r#   r#   ?  s]    & 
QBq5DD[FD=3fqj3&6S&H!IIBQRFUXLXXr2   c                     t        |       dk(  rt        g | | S t        |       dk(  rt        g | | S t        |       dk(  rt        g | | S t	        d      NrV   r4      Unknown curve degree)r   r$   r!   r"   
ValueError)segr}   s     r1   r%   r%   X  sh    
3x1}$S$!$$	SQ )#)q))	SQ%c%1%%
+
,,r2   c                     | \  }}|\  }}|\  }}t        ||z
        t        k  rt        ||z
        t        k  ryt        ||z
        t        ||z
        kD  r||z
  ||z
  z  S ||z
  ||z
  z  S )Nr   )	ser   sxsyexeypxpys	            r1   _line_t_of_ptr  g  s}    FBFBFB
27|g#b2g,"8
27|c"r'l"RBG$$RBG$$r2   c                 x    | d   |d   z
  |d   |d   z
  z  }| d   |d   z
  |d   |d   z
  z  }|dk  xr |dk   S )Nr   rW   rj   r6   )rd   re   originxDiffyDiffs        r1   '_both_points_are_on_same_side_of_originr  u  s`    qTF1I!A$"23EqTF1I!A$"23E-#..r2   c           	      x   | \  }}|\  }}|\  }}	|\  }
}t        j                  ||
      r.t        j                  ||      rt        j                  ||      sg S t        j                  |	|      r.t        j                  ||      rt        j                  ||	      sg S t        j                  ||
      rt        j                  |	|      rg S t        j                  ||      rt        j                  ||      rg S t        j                  ||      rA|}||	z
  |
|z
  z  }|||z
  z  |	z   }||f}t        |t        | ||      t        |||            gS t        j                  ||
      rA|}||z
  ||z
  z  }|||z
  z  |z   }||f}t        |t        | ||      t        |||            gS ||z
  ||z
  z  }||	z
  |
|z
  z  }t        j                  ||      rg S ||z  |z
  ||z  z
  |	z   ||z
  z  }|||z
  z  |z   }||f}t	        |||       r2t	        |||      r%t        |t        | ||      t        |||            gS g S )a  Finds intersections between two line segments.

    Args:
        s1, e1: Coordinates of the first line as 2D tuples.
        s2, e2: Coordinates of the second line as 2D tuples.

    Returns:
        A list of ``Intersection`` objects, each object having ``pt``, ``t1``
        and ``t2`` attributes containing the intersection point, time on first
        segment and time on second segment respectively.

    Examples::

        >>> a = lineLineIntersections( (310,389), (453, 222), (289, 251), (447, 367))
        >>> len(a)
        1
        >>> intersection = a[0]
        >>> intersection.pt
        (374.44882952482897, 313.73458370177315)
        >>> (intersection.t1, intersection.t2)
        (0.45069111555824465, 0.5408153767394238)
    r
   )rX   iscloser	   r  r  )s1e1s2e2s1xs1ye1xe1ys2xs2ye2xe2yrT   slope34r   r   slope12s                    r1   r&   r&   {  sf   . HCHCHCHCS#4<<S#9$,,sTWBX	S#4<<S#9$,,sTWBX	||C$,,sC"8	||C$,,sC"8	||C9s+q3w#%V-B3b"b8Q
 	

 ||C9s+q3w#%V-B3b"b8Q
 	
 SyS3Y'GSyS3Y'G||GW%		3	w}	,s	2w7HIA1s7c!A
QB.
B
1"b"
=-B3b"b8Q
 	

 Ir2   c                     | d   }| d   }t        j                  |d   |d   z
  |d   |d   z
        }t        j                  |       j	                  |d    |d          S )Nr   r  rW   )rX   atan2r   rotate	translate)segmentstartendangles       r1   _alignment_transformationr-    sj     AJE
"+CJJs1va(#a&58*;<E??E6",,eAhYq	BBr2   c                 >   t        |      j                  |       }t        |       dk(  r#t        | \  }}}t	        |d   |d   |d         }nAt        |       dk(  r(t        | \  }}}}t        |d   |d   |d   |d         }nt        d      t        d |D              S )Nr4   rW   r  r  c              3   >   K   | ]  }d |cxk  rdk  sn n|  yw)rj   rW   Nr6   )r   r   s     r1   r   z._curve_line_intersections_t.<locals>.<genexpr>  s     <cQm!m!<r   )	r-  transformPointsr   rr   r   r   r    r  r   )curvelinealigned_curverd   re   r   intersectionsr`   s           r1   _curve_line_intersections_tr5    s    -d3CCEJM
5zQ)=91a&qtQqT1Q48	Uq(-8
1a"1Q41qtQqT:/00<]<<<r2   c                    t        |       dk(  rt        }n t        |       dk(  rt        }nt        d      g }t	        | |      D ]C  } |g | | }t        g || }t        g || }|j                  t        |||             E |S )a  Finds intersections between a curve and a line.

    Args:
        curve: List of coordinates of the curve segment as 2D tuples.
        line: List of coordinates of the line segment as 2D tuples.

    Returns:
        A list of ``Intersection`` objects, each object having ``pt``, ``t1``
        and ``t2`` attributes containing the intersection point, time on first
        segment and time on second segment respectively.

    Examples::
        >>> curve = [ (100, 240), (30, 60), (210, 230), (160, 30) ]
        >>> line  = [ (25, 260), (230, 20) ]
        >>> intersections = curveLineIntersections(curve, line)
        >>> len(intersections)
        3
        >>> intersections[0].pt
        (84.9000930760723, 189.87306176459828)
    r4   r  r  r
   )	r   r!   r"   r  r5  r  r$   rs   r	   )r1  r2  pointFinderr4  r}   r   line_ts          r1   r'   r'     s    * 5zQ'	Uq#/00M(5 C#%## ))b)(4((\RA&ABC r2   c                 p    t        |       dk(  rt        |  S t        |       dk(  rt        |  S t        d      )Nr4   r  r  )r   r   r   r  )r   s    r1   _curve_boundsr:    s:    
1v{"A&&	Q1""
+
,,r2   c                     t        |       dk(  r| \  }}t        |||      }||f||fgS t        |       dk(  rt        g | | S t        |       dk(  rt        g | | S t	        d      r   )r   r$   r   r   r  )r   r}   r  r  midpoints        r1   _split_segment_at_tr=    s    
1v{11a(H!}--
1v{ '!'Q''	Q1#a###
+
,,r2   c           	         t        |       }t        |      }|sd}|sd}t        ||      \  }}|sg S d }	t        |      k  rt        |      k  r |	|       |	|      fgS t        | d      \  }
}|d    |	|      f} |	|      |d   f}t        |d      \  }}|d    |	|      f} |	|      |d   f}g }|j	                  t        |
|||             |j	                  t        ||||             |j	                  t        |
|||             |j	                  t        ||||             fd}t               }g }|D ]1  } ||      }||v r|j                  |       |j                  |       3 |S )N)rj   rI   c                     d| d   | d   z   z  S )Nr5   r   rW   r6   )rs    r1   r<  z._curve_curve_intersections_t.<locals>.midpoint*  s    adQqTk""r2   r5   r   rW   )range1range2c                 H    t        | d   z        t        | d   z        fS )Nr   rW   )int)r   	precisions    r1   <lambda>z._curve_curve_intersections_t.<locals>.<lambda>O  s(    SA!23SA9J5KL r2   )	r:  r   r   r=  extend_curve_curve_intersections_tsetaddrs   )curve1curve2rE  rA  rB  bounds1bounds2
intersects_r<  c11c12	c11_range	c12_rangec21c22	c21_range	c22_rangefound
unique_keyseenunique_valuesr   keys     `                     r1   rH  rH    s    F#GF#G Wg.MJ	# 9$'):Y)F&!8F#3455"63/HCHV,-I&!6!9-I"63/HCHV,-I&!6!9-IE	LL$i	)	

 
LL$i	)	

 
LL$i	)	

 
LL$i	)	
 MJ5DM !n$;R ! r2   c                 Z    t        |       j                  |       }t        d |D              S )Nc              3   N   K   | ]  }t        j                  |d    d        yw)rW   rj   N)rX   r  )r   ps     r1   r   z_is_linelike.<locals>.<genexpr>_  s     :1t||AaD#&:s   #%)r-  r0  all)r)  	maybelines     r1   _is_linelikerc  ]  s(    )'2BB7KI:	:::r2   c           
      J   t        |       r8| d   | d   f}t        |      r|d   |d   f}t        g || S t        ||      S t        |      r|d   |d   f}t        | |      S t        | |      }|D cg c]#  }t	        t        | |d         |d   |d         % c}S c c}w )a  Finds intersections between a curve and a curve.

    Args:
        curve1: List of coordinates of the first curve segment as 2D tuples.
        curve2: List of coordinates of the second curve segment as 2D tuples.

    Returns:
        A list of ``Intersection`` objects, each object having ``pt``, ``t1``
        and ``t2`` attributes containing the intersection point, time on first
        segment and time on second segment respectively.

    Examples::
        >>> curve1 = [ (10,100), (90,30), (40,140), (220,220) ]
        >>> curve2 = [ (5,150), (180,20), (80,250), (210,190) ]
        >>> intersections = curveCurveIntersections(curve1, curve2)
        >>> len(intersections)
        3
        >>> intersections[0].pt
        (81.7831487395506, 109.88904552375288)
    r   r  rW   r
   )rc  r&   r'   rH  r	   r%   )rK  rL  line1line2intersection_tsr   s         r1   r(   r(   b  s    * Fq	6":%1Ivbz)E(8%8%88)&%88	f	q	6":%%fe44266BO " 	162a5RUK  s   5(B c                    d}t        |      t        |       kD  r| |} }d}t        |       dkD  r(t        |      dkD  rt        | |      }nBt        | |      }n5t        |       dk(  rt        |      dk(  rt        g | | }nt	        d      |s|S |D cg c].  }t        |j                  |j                  |j                        0 c}S c c}w )a)  Finds intersections between two segments.

    Args:
        seg1: List of coordinates of the first segment as 2D tuples.
        seg2: List of coordinates of the second segment as 2D tuples.

    Returns:
        A list of ``Intersection`` objects, each object having ``pt``, ``t1``
        and ``t2`` attributes containing the intersection point, time on first
        segment and time on second segment respectively.

    Examples::
        >>> curve1 = [ (10,100), (90,30), (40,140), (220,220) ]
        >>> curve2 = [ (5,150), (180,20), (80,250), (210,190) ]
        >>> intersections = segmentSegmentIntersections(curve1, curve2)
        >>> len(intersections)
        3
        >>> intersections[0].pt
        (81.7831487395506, 109.88904552375288)
        >>> curve3 = [ (100, 240), (30, 60), (210, 230), (160, 30) ]
        >>> line  = [ (25, 260), (230, 20) ]
        >>> intersections = segmentSegmentIntersections(curve3, line)
        >>> len(intersections)
        3
        >>> intersections[0].pt
        (84.9000930760723, 189.87306176459828)

    FTrV   z4Couldn't work out which intersection function to user
   )	r   r(   r'   r&   r  r	   r   r   r   )seg1seg2swappedr4  r   s        r1   r)   r)     s    < G
4y3t94d
4y1}t9q=3D$?M24>M	TaCIN-;t;d;OPP=JKLADDQTTadd3KKKs   3C	c                 x    	 t        |       }ddj                  d |D              z  S # t        $ r d| z  cY S w xY w)zw
    >>> _segmentrepr([1, [2, 3], [], [[2, [3, 4], [0.1, 2.2]]]])
    '(1, (2, 3), (), ((2, (3, 4), (0.1, 2.2))))'
    z(%s)z, c              3   2   K   | ]  }t        |        y wrO   )_segmentrepr)r   rT   s     r1   r   z_segmentrepr.<locals>.<genexpr>  s     !>a,q/!>s   z%g)iterjoin	TypeError)objits     r1   rn  rn    sG    
?#Y 		!>2!>>>>  czs   ( 99c                 :    | D ]  }t        t        |              y)zlHelper for the doctests, displaying each segment in a list of
    segments on a single line as a tuple.
    N)printrn  )r   r)  s     r1   printSegmentsrv    s       %l7#$%r2   __main__)g{Gzt?)gMbP?NN)W__doc__fontTools.misc.arrayToolsr   r   r   fontTools.misc.transformr   rX   collectionsr   r   compiledCOMPILEDAttributeErrorImportErrorfontTools.miscr	   __all__r   r=   returnsdoublelocalsr+   rD   r   r   rk   cfuncinlinerR   r[   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rY   r   r   r   r   r    rr   r   r   r   r   r   r$   r!   r"   r#   r%   r  r  r&   r-  r5  r'   r:  r=  rH  rc  r(   r)   rn  rv  __name__sysdoctestexittestmodfailedr6   r2   r1   <module>r     s   E D -  "H .*<=@& ~~~~~~~~	 FMM6==I	
 J 	
 	 mm	A	 A 
 &..V^^4& 5   & ;     ; PF ~~~~nnnn 
--]]mmmm}}}} &@W" 
 }}}}}}
 BD< 	 }}}}}}}}}}!" !"H#L6r*3Z"2J,0+0 nnnnnnnn	0	0 mm^^			 }}6==D	  D46 F nnnnnnnn}}}}
--MMMM~~~~~~~~##6 % $ "& BYB(2 nnnnnn  
(2  nnnnnnnn~~~~~~  
N4 mm &--fmmFMMJY K  Y -%/K\C
=#L-	- 9=@F;
$N-L`
?% zCHH_W__%%&	 A. 	$ %H	s   b% %b87b8