+
    K<i                         R t ^ RIHtHtHtHtHt ^ RIHt R t	R t
R tRt]! R],          4      tR t ! R R	4      tR
 tR# )z=Helpers for manipulating 2D points and vectors in COLR table.)copysigncoshypotisclosepiotRoundc                 ^    V^ ,          V ^ ,          ,
          V^,          V ^,          ,
          3#      )origintargets   &&=/usr/lib/python3/dist-packages/fontTools/colorLib/geometry.py_vector_betweenr      s'    1Iq	!6!9vay#899    c                 J    \        V ^ ,          4      \        V ^,          4      3# r
   r   )pts   &r   _round_pointr      s    BqENGBqEN++r   c                 f    \        V !  pV^ 8X  d   R# V ^ ,          V,          V ^,          V,          3# r   N)r   )veclengths   & r   _unit_vectorr      s0    C[F{FVOSVf_--r   g-C6?c                     \        V 4      pV'       g   R# . pV FL  p\        ) Tu;8:  d   \        8  d   M MVP                  ^ 4       K1  VP                  \        RV4      4       KN  	  \	        V4      # )r         ?)r   r   )r   _UNIT_VECTOR_THRESHOLDappendr   tuple)	directionuvresultuv_components   &   r   _rounding_offsetr#      se     
i	 BF""lK5KK MM! MM(356  =r   c                   J   a  ] tR t^6t o R tR tR t]3R ltR t	R t
RtV tR# )	Circlec                    Wn         W n        R # Ncentreradius)selfr)   r*   s   &&&r   __init__Circle.__init__7   s    r   c                <    R V P                    RV P                   R2# )zCircle(centre=z	, radius=)r(   r+   s   &r   __repr__Circle.__repr__;   s    }Idkk]!DDr   c                f    \        \        V P                  4      \        V P                  4      4      # r'   )r%   r   r)   r   r*   r0   s   &r   roundCircle.round>   s!    l4;;/1EFFr   c                    V P                   \        \        V P                  VP                  4      !  ,           p\	        VP                   V\
        R 7      ;'       g    VP                   V8  # ))rel_tol)r*   r   r   r)   r   _CIRCLE_INSIDE_TOLERANCE)r+   outer_circle	tolerancedists   &&& r   insideCircle.insideA   sV    {{UODKKATAT$UVVL''7OP * *""T)	
r   c                4    V P                   VP                   8H  # r'   r)   )r+   others   &&r   
concentricCircle.concentricH   s    {{ell**r   c                x    V P                   ^ ,          V,           V P                   ^,          V,           3V n         R# r   r?   )r+   dxdys   &&&r   moveCircle.moveK   s(    {{1~*DKKNR,?@r   r(   N)__name__
__module____qualname____firstlineno__r,   r1   r4   r8   r<   rA   rF   __static_attributes____classdictcell__)__classdict__s   @r   r%   r%   6   s2     EG .F 
+A Ar   r%   c                   \        W4      \        W#4      rTVP                  V4      pVP                  4       pVP                  4       pVP                  V4      p	Wi8X  d   V# V	'       d$   \        VP                  VP                  4      p
RpM"\        VP                  VP                  4      p
Rp\        V
4      w  r^p\        V4       Fp  pVP                  V4      '       d.   V;P                  V,          un        VP                  ^ 8  g   Q hMVP                  W4       WgP                  V4      8X  g   Ko   V# 	  \        RT RV'       d   RMR RV RV R2	4      h)	a  Round start circle so that it stays inside/outside end circle after rounding.

The rounding of circle coordinates to integers may cause an abrupt change
if the start circle c0 is so close to the end circle c1's perimiter that
it ends up falling outside (or inside) as a result of the rounding.
To keep the gradient unchanged, we nudge it in the right direction.

See:
https://github.com/googlefonts/colr-gradients-spec/issues/204
https://github.com/googlefonts/picosvg/issues/158
r   zRounding circle  r<   outsidez failed after z
 attempts!g      )r%   r<   r4   r   r)   r#   rangerA   r*   rF   AssertionError)c0r0c1r1startendinside_before_roundround_start	round_endinside_after_roundr   radius_deltarD   rE   max_attempts_s   &&&&            r   %round_start_circle_stable_containmentra   O   sL    3,,s+++-K		I$++I60	#I$4$4k6H6HI	 $K$6$6	8H8HI	i(FB" L< !!),,,.%%***R$"4"4Y"?? ! ! ugQ.xI>ae>,z;
 	
r   Ng      ?)__doc__mathr   r   r   r   r   fontTools.misc.roundToolsr   r   r   r   r8   r   r#   r%   ra   r   r   r   <module>re      sO    C 2 2 -:,.    URZ .A A2@r   