+
    5i                     h   R t ^ RIt^ RIt^ RIHt ^ RIHtHtHtH	t	 ^RI
HtHtHtHtHtHtHtHt ^RIHt ^RIHtHtHtHt ^RIHtHtHt ]'       d   ^RIHt R	 R
 lt R R lt!R R lt"R6RR/R R lllt#R R lt$R R lt%R R lt&R R lt' ! R R]4      t( ! R R]4      t) ! R R ]4      t* ! R! R"]4      t+ ! R# R$]4      t, ! R% R&]4      t- ! R' R(]-4      t. ! R) R*]-4      t/ ! R+ R,]4      t0 ! R- R.]4      t1R7R/ R0 llt2]Pf                  R3R1 R2 llt4RRR3]Pf                  R3R4 R5 llt5R# )8zx
Handles the creation of patterns and gradients

Usage documentation at: <https://py-pdf.github.io/fpdf2/Patterns.html>
N)ABC)TYPE_CHECKINGOptionalSequenceUnion)Color
ColorClass
ColorInput
DeviceCMYK
DeviceGray	DeviceRGB	Transformconvert_to_device_color)GradientSpreadMethod)NamePDFArrayPDFContentStream	PDFObject)FloatToleranceNumberClassformat_number)BoundingBoxc                H    V ^8  d   QhR\         R\         R\         R\         /# )   abtreturnfloat)formats   "R/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fpdf/pattern.py__annotate__r"      s(      E e  %     c                 .    WV ,
          V,          ,           # N r   r   r   s   &&&r!   lerpr(      s    A{?r#   c          
          V ^8  d   QhR\         \        R3,          R\         \        R3,          R\        R\         \        R3,          /# )r   r   .r   r   r   )tupler   )r    s   "r!   r"   r"   "   sG     = =UCZ="5#:.=38=
5#:=r#   c                   a aa \        S 4      \        S4      8w  d   \        R 4      h\        ;QJ d+    . V VV3R l\        \        S 4      4       4       F  NK  	  5# ! V VV3R l\        \        S 4      4       4       4      # )z!Mismatched color component countsc              3   Z   <"   T F   p\        SV,          SV,          S4      x  K"  	  R # 5ir%   r(   ).0ir   r   r   s   & r!   	<genexpr>lerp_tuple.<locals>.<genexpr>'   s%     <madAaD!$$ms   (+)len
ValueErrorr*   ranger'   s   fffr!   
lerp_tupler5   "   sS     1vQ<==5<eCFm<5<5<eCFm<<<r#   c                ~    V ^8  d   QhR\         \        ,          R\        \        \         \        ,          3,          /# r   colorsr   )listr   r*   str)r    s   "r!   r"   r"   *   s,      U c4;>N8O r#   c                    V  Uu0 uF  p\        V4      P                  kK  	  ppR V9   d   \        V4      ^8  d   \        R4      hVRR08X  dW   V  Uu. uFF  p\	        V\
        4      '       d,   \        VP                  VP                  VP                  4      MTNKH  	  ppRV3# VR08X  d   RV 3# VR08X  d   RV 3# RV 3# u upi u upi )r
   'Can't mix CMYK with other color spaces.r   r   )type__name__r2   r3   
isinstancer   r   g)r8   ckindspromoteds   &   r!   pick_colorspace_and_promoterD   *   s    '-.v!T!WvE.uUaBCC{++ SY!
RXQ
1j(A(AIacc133$qHRX 	 !
 H$$V##F"" /
!
s   CAC
return_rawFc                T   V ^8  d   QhR\         \        \        \        \        \
        3,          3,          ,          R\        R\        R\        \
        \        \        \        \        3,          ,          \        \        \        \        \        3,          ,          ,          3,          /# )r   stopscoerce_to_devicerE   r   )	r   r*   r   r   r   r:   boolr9   r   )r    s   "r!   r"   r"   ;   s{     F0 F0E%ucz!2234F0F0 	F0
 3U5%<()8Due|9L4M+NNOF0r#   c                  aaa V '       g   \        R4      h. pV  FI  w  rE\        V4      pV'       d   \        VR4      '       g   \        V4      MTpVP	                  Wg34       KK  	  VP                  R R7       . oV FR  w  rhS'       d4   \        P                  ! SR,          ^ ,          V4      '       d	   Wh3SR&   K@  SP	                  Wh34       KT  	  R R loR VV3R llp	V	! R	4       V	! R
4       . p
S F-  w  rhVR	8  d   R	pMVR
8  d   R
pMTpV
P	                  W34       K/  	  V
P                  R R7       . pV
 FR  w  rV'       d4   \        P                  ! VR,          ^ ,          V4      '       d	   W3VR&   K@  VP	                  W34       KT  	  \        V4      ^8X  d   V^ ,          w  rR	V3R
V3.pM\        P                  ! V^ ,          ^ ,          4      '       g$   VP                  ^ R	V^ ,          ^,          34       MR	V^ ,          ^,          3V^ &   \        P                  ! VR,          ^ ,          R
4      '       g#   VP	                  R
VR,          ^,          34       MR
VR,          ^,          3VR&   \        V UUu. uF  w  rVNK	  	  upp4      w  op\        W4       UUUu. uF  w  w  rqV3NK  	  ppppV'       g   SVR3# R V3R llpS UUu. uF  w  rVV! V4      3NK  	  pppSVV3# u uppi u upppi u uppi )af  
Clamp/sort/merge, ensure endpoints at 0 and 1, coerce to single Device* colorspace.

When ``return_raw`` is true, also returns a list of the original stop positions
(prior to clamping to [0,1]) converted to the same device colorspace. The raw
offsets are sorted and merged (last stop wins for near-duplicates) but no
implicit 0/1 endpoints are synthesized.
At least one stop is requiredr8   c                     V ^ ,          #     r&   r   s   &r!   <lambda>!normalize_stops.<locals>.<lambda>V   s    1Q4r#   keyc                H    V ^8  d   QhR\         R\         R\        R\         /# )r   c0c1r   r   )r   r   )r    s   "r!   r"   %normalize_stops.<locals>.__annotate___   s(       5 U u r#   c                 2   V P                   pVP                   p\        W4V4      p\        V R R4      p\        VR R4      pRpVf   Ve,   \        Vf   RM
\	        V4      Vf   RM
\	        V4      V4      p\        V \        4      '       d   \        V^ ,          V4      # \        V \        4      '       d$   \        V^ ,          V^,          V^,          V4      # \        V \        4      '       d,   \        V^ ,          V^,          V^,          V^,          V4      # V # )r   N      ?)	r8   r5   getattrr(   r   r?   r   r   r
   )	rU   rV   r   comps0comps1blendeda0a1alphas	   &&&      r!   _lerp_color$normalize_stops.<locals>._lerp_color_   s    VQ/Rd#Rd#>R^zuRy#rTUE b*%%gaj%00b)$$WQZWQZGGb*%%gaj'!*gaj'!*eTT	r#   c                (    V ^8  d   QhR\         RR/# )r   targetr   Nr   )r    s   "r!   r"   rW   s   s      U t r#   c           
        < S'       g   R # \         P                  ! V S^ ,          ^ ,          4      '       g,   \         P                  ! V SR,          ^ ,          4      '       d   R # S F$  w  r\         P                  ! W4      '       g   K#   R # 	  \	        ^\        S4      4       F  pSV^,
          ,          w  rESV,          w  rg\         P                  ! W4      '       g   K>  \         P                  ! W4      '       g   K\  \        Wd,
          \         P                  4      pW,
          V,          p	SP                  W0S
! WWV	4      34        R # 	  R # )N)r   	less_thangreater_thanequalr4   r2   greater_equal
less_equalmax	TOLERANCEinsert)rd   u_idxu0rU   u1rV   spanr   ra   
merged_raws   &         r!   _ensure_stop%normalize_stops.<locals>._ensure_stops   s    ##JqM!$
 
((B1BCCDA##A..  C
O,Ca(FB_FB++F77N<U<U= = 27N$<$<=[D(!!#BA0F'GH -r#           rY   c                     V ^ ,          # rM   r&   rO   s   &r!   rP   rQ      s    qtr#   Nc                0    V ^8  d   QhR\         R\         /# )r   colorr   r   )r    s   "r!   r"   rW      s      5 U r#   c                   < SR 8X  d`   \        V \        4      '       d   V # \        V \        4      '       d   V P                  4       # \        V \        4      '       d   \        R4      hSR8X  dZ   \        V \        4      '       d   V # \        V \        4      '       d,   \        V P                  V P                  V P                  4      # V # )r   z&Can't mix CMYK with non-CMYK gradientsr   )r?   r   r   to_grayr
   r3   r@   )r{   
space_names   &r!   promote_raw$normalize_stops.<locals>.promote_raw   s    %%,,%++}}&%,, !IJJ$%++%,, %''577;;r#   rf   )r3   r   hasattrr   appendsortr   ri   r2   is_zerorn   rD   zip)rG   rH   rE   raw_entriesoffcolraw_urA   r{   rv   clamped_entriesro   merged_clampedrp   palettep
normalizedr   raw_promotedra   ru   r   s   &&$                @@@r!   normalize_stopsr   ;   s    899-/Kc
 !h)?)? $C( 	

 	E:&  (,.J#...z"~a/@%HH#^JrNun-	 $( * 13O"3;AS[AAz* # ^,02N#n22>"3Ea3H!LL"#N2!!1*-	 $ >a!!$,e5%%nQ&7&:;;!!!c>!+<Q+?%@A!$nQ&7&: ;N1##N2$6q$93??!!3r(:1(=">?"%~b'9!'<!=N25^6T^TQq^6TUJ*-n*FG*FYVaQa&*FJG:t++  ?IIj
QE*+jLIz<//- 7UG( Js   	K=
0L L
c          	          V ^8  d   QhR\         \        \        \        \        \
        3,          3,          ,          R\         \        \        \        \        \
        3,          3,          ,          /# )r   pairsr   )r   r*   r   r   r   r:   )r    s   "r!   r"   r"      sL      E%ucz!2234eE5,,-.r#   c           	      :   . pV  EF  w  r#V'       d   \         P                  ! VR,          ^ ,          V4      '       d   VR,          w  rEWS8X  d	   W#3VR&   KR  \        \         P                  ^
,          R4      pWF,
          p\         P                  ! VR4      '       d   Wu3VR&   VP                  W#34       K  W&,           pVR8  d%   Rp\        R\        WHV,
          4      4      V3VR&   MWE3VR&   VP                  W34       K  VP                  W#34       EK  	  V# )   ư>rx   rY   rf   )r   ri   rl   rm   rj   r   min)	r   outro   r   prev_uprev_colstepnudged_prevnudgeds	   &        r!   merge_near_duplicatesr      s     24C>''B
A66"2wF(B~//"4d;D -K++K==&1B

A8$C< F"3FTM(BCXNCG%0CG

F=)JJx - . Jr#   c                <    V ^8  d   QhR\         R\        R\         /# )r   ro   methodr   )r   r   )r    s   "r!   r"   r"      s"     & &% &!5 &% &r#   c                    V\         P                  8X  d   V R8  d   R# V R8  d   R# T # V\         P                  8X  d   V \        P                  ! V 4      ,
          # V R,          pVR8:  d   V# RV,
          # )u*   Map u∈R -> [0,1] via PAD/REPEAT/REFLECT.rx   rY          @)r   PADREPEATmathfloor)ro   r   vs   && r!   
spread_mapr      sm    %)))#gs8!c'38q8%,,,4::a=  	CAS1%cAg%r#   c                    V ^8  d   QhR\         \        \        \        3,          ,          R\        R\        \        R3,          /# )r   stops01ro   r   .r9   r*   r   r   )r    s   "r!   r"   r"      s8     	! 	!$uUE\23 	! 	!%s
BS 	!r#   c                   \        ^\        V 4      4       F  pW,          w  r4\        P                  ! W4      '       g   K+  W^,
          ,          w  rV\	        W5,
          \        P
                  4      pW,
          V,          p\        VP                  VP                  V4      u # 	  V R,          ^,          P                  # )zTPiecewise-linear sampling in [0,1]. Assumes normalized/sorted stops incl. endpoints.rf   )r4   r2   r   rk   rl   rm   r5   r8   )	r   ro   r/   rs   rV   rr   rU   rt   r   s	   &&       r!   sample_stopsr      s    1c'l#$$Q++U^FBrw 8 89D4AbiiA66 $ 2;q>   r#   c                    V ^8  d   QhR\         \        \        \        3,          ,          R\         \        \        \        3,          ,          /# )r   r   r   r   )r    s   "r!   r"   r"      s8      %u%&	%u
r#   c                |    . pV  F3  w  r#\        VRR4      pTP                  Y$f   RM
\        V4      34       K5  	  V# )u5   Return [(u, a)] with a∈[0,1]; missing alpha => 1.0.r   NrY   )rZ   r   r   )r   r   ro   rA   r   s   &    r!   extract_alpha_stopsr      sC     &(CAsD!

AisU1X67  Jr#   c                      a a ] tR tRt oRtV3R lV 3R llt]V3R lR l4       t]V3R lR l4       tV3R	 lR
 lt	V3R lR lt
V3R lR ltV3R lR ltRtVtV ;t# )Patterni  z
Represents a PDF Pattern object.

Currently, this class supports only "shading patterns" (pattern_type 2),
using either a linear or radial gradient. Tiling patterns (pattern_type 1)
are not yet implemented.
c                .   < V ^8  d   QhRS[ R,          /# )r   shading)GradientShadingMeshShading)r   )r    __classdict__s   "r!   r"   Pattern.__annotate__  s     	$ 	$&J K 	$r#   c                   < \         SV `  4        \        R 4      V n        ^V n        Wn        \        P                  ! 4       V n        RV n	        R# )r   TN)
super__init__r   r=   pattern_type_shadingr   identity_matrix_apply_page_ctm)selfr   	__class__s   &&r!   r   Pattern.__init__  s@    O	 ))+  $r#   c                    < V ^8  d   QhRS[ /# r   r   r:   )r    r   s   "r!   r"   r     s     > > >r#   c                P    V P                   P                  4       P                   R 2# ) 0 R)r   get_shading_objectidr   s   &r!   r   Pattern.shading  s#    --224778==r#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   r     s     
 
 
r#   c                   R \        V P                  P                  4       R\        V P                  P                  4       R\        V P                  P                  4       R\        V P                  P
                  4       R\        V P                  P                  4       R\        V P                  P                  4       R2# )[ ])r   r   r   r   rA   defr   s   &r!   matrixPattern.matrix  s     dllnn-.adllnn0M/NaT\\^^,-Q}T\\^^/L.MQT\\^^,-Q}T\\^^/L.MQP	
r#   c                $   < V ^8  d   QhRS[ RR/# )r   r   r   r   r   )r    r   s   "r!   r"   r   $  s       y r#   c                    Wn         V # r%   r   )r   r   s   &&r!   
set_matrixPattern.set_matrix$  s    r#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   r   (  s      I r#   c                    V P                   # r%   r   r   s   &r!   
get_matrixPattern.get_matrix(      ||r#   c                $   < V ^8  d   QhRS[ RR/# )r   applyr   NrI   )r    r   s   "r!   r"   r   +  s     % % % %r#   c                    Wn         R # r%   r   )r   r   s   &&r!   set_apply_page_ctmPattern.set_apply_page_ctm+  s    $r#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   r   .  s     $ $D $r#   c                    V P                   # r%   r   r   s   &r!   get_apply_page_ctmPattern.get_apply_page_ctm.  s    ###r#   )r   r   r   r   r=   )r>   
__module____qualname____firstlineno____doc__r   propertyr   r   r   r   r   r   __static_attributes____classdictcell____classcell__r   r   s   @@r!   r   r     si     	$ 	$ > > 
 
  % %$ $ $r#   r   c                   ^   a a ] tR tRt oRtV3R lV 3R llt]V3R lR l4       tRtVt	V ;t
# )Type2Functioni2  zTransition between 2 colorsc                &   < V ^8  d   QhRS[ RS[ /# )r   color_1color_2r|   )r    r   s   "r!   r"   Type2Function.__annotate__5  s        r#   c                ^  < \         SV `  4        ^V n        RV n        V P	                  V4      pV P	                  V4      p\        V4      \        V4      8w  d   \        R4      hRRP                  R V 4       4       R2V n        RRP                  R V 4       4       R2V n	        ^V n
        R# )	r   [0 1]z6Type2Function endpoints must have same component countr   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir%   r   r.   rA   s   & r!   r0   )Type2Function.__init__.<locals>.<genexpr>>       <A}Q//   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir%   r   r  s   & r!   r0   r  ?  r  r  N)r   r   function_typedomain_get_color_componentsr2   r3   joinrU   rV   n)r   r   r   rV   c2r   s   &&&  r!   r   Type2Function.__init__5  s    ''0''0r7c"gUVVchh<<<=Q?chh<<<=Q?r#   c                :   < V ^8  d   QhRS[ RS[S[R3,          /# )r   r{   r   .)r   r*   r   )r    r   s   "r!   r"   r   C  s$      % E%*4E r#   c                `    \        V\        4      '       d   VP                  3# VP                  # r%   )r?   r   r@   r8   )clsr{   s   &&r!   r  #Type2Function._get_color_componentsB  s%    eZ((GG:||r#   rU   rV   r  r  r
  )r>   r   r   r   r   r   classmethodr  r   r   r   r   s   @@r!   r   r   2  s+     %    r#   r   c                   B   a a ] tR tRt oRtV3R lV 3R lltRtVtV ;t# )Type2FunctionGrayiI  u@   1‑channel exponential interpolation for alpha/luminance ramps.c                &   < V ^8  d   QhRS[ RS[ /# )r   g0g1r   )r    r   s   "r!   r"   Type2FunctionGray.__annotate__L  s      5 e r#   c                   < \         SV `  4        ^V n        RV n        R\	        V4       R2V n        R\	        V4       R2V n        ^V n        R# )r   r   r   r   N)r   r   r  r  r   rU   rV   r
  )r   r  r  r   s   &&&r!   r   Type2FunctionGray.__init__L  sP    mB'(*mB'(*r#   r  )	r>   r   r   r   r   r   r   r   r   r   s   @@r!   r  r  I  s     J  r#   r  c                   ^   a a ] tR tRt oRtV3R lV 3R llt]V3R lR l4       tRtVt	V ;t
# )Type3FunctioniU  zWhen multiple colors are used, a type 3 function is necessary to stitch type 2 functions together
and define the bounds between each color transitionc                ^   < V ^8  d   QhRS[ S[S[S[R3,          ,          RS[ S[,          /# )r   	functionsr  bounds)r   r   r   r  r   )r    r   s   "r!   r"   Type3Function.__annotate__Y  s9     @ @E-1BO"STU@ @r#   c                   < \         SV `  4        ^V n        RV n        Wn        RRP                  R V 4       4       R2V n        RRP                  R V 4       4       R2V n        R# )   r   r   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir%   r   )r.   bounds   & r!   r0   )Type3Function.__init__.<locals>.<genexpr>c  s     "LVE=#7#7Vr  r   c              3   &   "   T F  pR x  K	  	  R# 5i)z0 1Nr&   )r.   rp   s   & r!   r0   r%  d  s     "<)Q5)s   N)r   r   r  r  
_functionsr	  r  encode)r   r  r  r   s   &&&r!   r   Type3Function.__init__Y  sd    
 	##(("LV"LLMQO#(("<)"<<=Q?r#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   r   g  s     G G3 Gr#   c                N    R RP                  R V P                   4       4       R2# )r   r   c              3   >   "   T F  qP                    R 2x  K  	  R# 5i)r   N)r   )r.   r   s   & r!   r0   *Type3Function.functions.<locals>.<genexpr>h  s     C?attfDM?s   r   )r	  r'  r   s   &r!   r  Type3Function.functionsf  s%    388C4??CCDAFFr#   )r'  r  r  r(  r  )r>   r   r   r   r   r   r   r  r   r   r   r   s   @@r!   r  r  U  s2     ;@ @ G G Gr#   r  c                   ~   a a ] tR tRt oV3R lV 3R llt]V3R lR l4       tV3R lR ltV3R lR	 ltR
t	Vt
V ;t# )r   ik  c                   < V ^8  d   QhRS[ RS[S[,          RS[RS[S[,          S[,          RS[S[S[,          S[,          ,          RS[	RS[	/# )r   shading_type
backgroundcolor_spacecoordsr  extend_beforeextend_after)
intr   r   r:   r   r   r   r  r  rI   )r    r   s   "r!   r"   Shading.__annotate__l  sn       UO 	
 #% M,==MN  r#   c                $  < \         SV `  4        Wn        V'       d'   R RP                  R VP                   4       4       R2MRV n        \        V4      V n        W@n        WPn	        R V'       d   RMR RV'       d   RMR R2V n
        RV n        R# )r   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir%   r   r  s   & r!   r0   #Shading.__init__.<locals>.<genexpr>y       E3Daq))3Dr  r   NtruefalseT)r   r   r1  r	  r8   r2  r   r3  r4  r'  extend
anti_alias)	r   r1  r2  r3  r4  r  r5  r6  r   s	   &&&&&&&&r!   r   Shading.__init__l  s     	(  E:3D3DEEFaH 	
  ,#M&w?q<]d@eefgr#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   r8    s     / /# /r#   c                B    V P                   R,          P                   R2# )zHReference to the *top-level* function object for the shading dictionary.r   rf   )r'  r   r   s   &r!   functionShading.function  s!     //"%(()..r#   c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r   r   r   r  r  )r    r   s   "r!   r"   r8    s%      	-"33mC	Dr#   c                    V P                   # )zIAll function objects used by this shading (Type2 segments + final Type3).)r'  r   s   &r!   get_functionsShading.get_functions  s     r#   c                   < V ^8  d   QhRR/# r   r   r   r&   )r    r   s   "r!   r"   r8    s      I r#   c                    V # )z1Return self, as this is already a shading object.r&   r   s   &r!   r   Shading.get_shading_object  s    r#   )r'  r@  r2  r3  r4  r?  r1  )r>   r   r   r   r   r   rD  rI  r   r   r   r   r   s   @@r!   r   r   k  s<      . / /   r#   r   c                      a  ] tR tRt o V 3R lR lt]V 3R lR l4       tV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltRV 3R lR lltRtV tR# )r   i  c                x   < V ^8  d   QhRS[ S[,          RS[S[,          RS[RS[RS[S[ S[,          ,          /# )r   r8   r2  r5  r6  r  )r   r	   r   rI   r   )r    r   s   "r!   r"   Gradient.__annotate__  sW     -C -C$-C Z(-C 	-C
 -C %)-Cr#   c                   V P                  V4      w  V n        V n        V n        R V n        V'       Ed   \        V\        .\        O\        O54      '       d   \        V4      M\        V!  pV P                  R8X  dJ   \        V\        4      '       d   VP                  4       pM\        V\        4      '       d   \        R4      hMtV P                  R8X  dd   \        V\        4      '       d-   \        VP                  VP                  VP                  4      pM!\        V\        4      '       d   \        R4      hW`n        W0n        W@n        V'       d   TM[\%        \'        V P                  4      ^,
          4       Uu. uF,  qw^,           \'        V P                  4      ^,
          ,          NK.  	  upV n        \'        V P(                  4      \'        V P                  4      ^,
          8w  d   \        R4      hV P+                  4       V n        \/        V 4      V n        R V n        R V n        R V n        ^ V n        R V n        R # u upi )Nr   z0Can't mix CMYK background with non-CMYK gradientr   z>Bounds array length must be two less than the number of colors)_convert_colorsr3  r8   _alphasr2  r?   r:   r   r   r   r   r~   r
   r3   r   r@   r5  r6  r4   r2   r  _generate_functionsr  r   pattern_shading_object_alpha_shading_objectr4  r1  	raw_stops)r   r8   r2  r5  r6  r  bgr/   s   &&&&&&  r!   r   Gradient.__init__  s    7;6J6J66R3$+t|: j3*J*Jk*JKK (
3,j9  </b),,BJ//$%WXX 0!![0b*--"244rtt4BJ//$%WXX O*(  <A#dkkBRUVBV<WX<Wqq5S-122<WX 	
 t{{s4;;/!33P  113t}268<"15>B Ys   >2Ic                p   < V ^8  d   QhRS[ S[,          RS[S[S[S[,          S[S[,          3,          /# r7   )r   r	   r*   r:   r9   r   r   )r    r   s   "r!   r"   rQ    s6     8, 8,j)8,	sDKe,	-8,r#   c                r   \        V4      ^8  d   \        R4      h. p\        4       p. pV F  p\        V\        .\
        O\        O54      '       d   \        V4      M\        V!  pVP                  V4       VP                  \        V4      P                  4       \        VRR4      pTP                  Ve   \        V4      MR4       K  	  RV9   d   \        V4      ^8  d   \        R4      hVR08X  d   RW$3# VRR08X  d   . pV F~  p	\        V	\        4      '       d=   VP                  \        V	P                   V	P                   V	P                   4      4       KU  \        V	\        4      '       g   Q hVP                  V	4       K  	  RW3# VR08X  d   RW$3# VR08X  d   V U	u. uF  p	\        V	\        4      '       g   K  V	NK  	  p
p	\"        ;QJ d    R	 V
 4       F  '       d   K   R
M	  RM! R	 V
 4       4      '       d#   RV
 U	u. uF  qP%                  4       NK  	  up	V3# RW$3# RW$3# u up	i u up	i )zXNormalize colors to a single device colorspace and capture per-stop alpha (default 1.0).(A gradient must have at least two colorsr   NrY   r
   r<   r   r   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir%   )is_achromaticr  s   & r!   r0   +Gradient._convert_colors.<locals>.<genexpr>  s     :k??$$ks   FT)r2   r3   setr?   r:   r   r   r   r   addr=   r>   rZ   r   r   r   r@   allr~   )r  r8   r   spacesalphasr{   dcr   rC   rA   rgb_palettes   &&         r!   rS  Gradient._convert_colors  s   
 v;?GHH  "5 E ec%EJ%E%EFF (.,e4 
 NN2JJtBx(()C&AMMam%(=  6!c&kAoFGG l^#00 lK00$&Ha,,OOIacc133$<=%a3333OOA&  00 l^#00 k]" #,"ajI&>7  , s:k:sss:k:::#;%G;aiik;%GOO// G++, &Hs   &H/H/
H4c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r   r9   r   r  r  )r    r   s   "r!   r"   rQ    s%      	m//-?	@r#   c           	     "   \        V P                  4      ^8  d   \        R4      h\        V P                  4      ^8X  d0   \        V P                  ^ ,          V P                  ^,          4      .# \        V P                  4      p. p\	        V^,
          4       FG  pVP                  \        V P                  V,          V P                  V^,           ,          4      4       KI  	  VP                  \        VR,          V P                  4      4       V# )r   r^  NNN)r2   r8   r3   r   r4   r   r  r  )r   number_of_colorsr  r/   s   &   r!   rU  Gradient._generate_functions  s     t{{aGHHt{{q !$++a.$++a.ABBt{{+MO	'!+,A]4;;q>4;;q1u;MNO -y|T[[ABr#   c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r   rk  )r    r   s   "r!   r"   rQ    s$      tM4E$E$UV r#   c                    V P                   # r%   )r  r   s   &r!   rI  Gradient.get_functions  s    ~~r#   c                   < V ^8  d   QhRR/# rL  r&   )r    r   s   "r!   r"   rQ    s     $ $I $r#   c           
        V P                   '       g   V P                  f   RMY\        V P                   Uu. uF,  p\        V\        \
        34      '       d   \        V4      MTNK.  	  up4      P                  4       p\        V P                  V P                  V P                  VV P                  V P                  V P                  R7      V n         V P                   # u upi )N r1  r2  r3  r4  r  r5  r6  )rW  r4  r   r?   r7  r   r   	serializer   r1  r2  r3  r  r5  r6  )r   valuer4  s   &  r!   r   Gradient.get_shading_object  s    ### ;;&  &*[[ &1E  *%#u>> *%0!&' &1	 )+  $+!..?? ,,.."00!..$D  ###'s   2Cc                    < V ^8  d   QhRS[ /# r   )r   )r    r   s   "r!   r"   rQ  *  s      W r#   c                    V P                   # r%   )rV  r   s   &r!   get_patternGradient.get_pattern*  r   r#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   rQ  -  s     K K4 Kr#   c                    \         ;QJ d&    R V P                   4       F  '       g   K   R# 	  R# ! R V P                   4       4      # )z&True if any stop carries alpha != 1.0.c              3   Z   "   T F!  p\         P                  ! VR 4      '       * x  K#  	  R# 5i)rY   N)r   ri   )r.   r   s   & r!   r0   %Gradient.has_alpha.<locals>.<genexpr>/  s#     J\~++As333\s   )+TF)anyrT  r   s   &r!   	has_alphaGradient.has_alpha-  s3    sJT\\JssJsJsJT\\JJJr#   c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r   rG  )r    r   s   "r!   r"   rQ  1  s%      	-"33mC	Dr#   c           	        \        V P                  4      ^8  d   \        R4      h\        V P                  4      ^8X  d0   \        V P                  ^ ,          V P                  ^,          4      .# . p\	        \        V P                  4      ^,
          4       FG  pVP                  \        V P                  V,          V P                  V^,           ,          4      4       KI  	  VP                  \        VR,          V P                  4      4       V# )z>Stitched Type2 gray functions mirroring the color ramp bounds.z&Alpha ramp requires at least two stopsrm  )r2   rT  r3   r  r4   r   r  r  )r   r  r/   s   &  r!   _generate_alpha_functions"Gradient._generate_alpha_functions1  s     t||q EFFt||!%dll1ot||AGHH=?	s4<<(1,-A.t||AQQRU@STU .y|T[[ABr#   Nc                B   < V ^8  d   QhRS[ R,          RS[ R,          /# )r   rp   r   r   r   r   )r    r   s   "r!   r"   rQ  ?  s'     * *-(*	)	*r#   c           
        V P                  4       '       g   R# V P                  '       g   V P                  ee   \        V P                  \        \
        34      '       d?   \        V P                  4      ^8  d%   \        V P                  4      P                  4       pMRp\        V P                  RRVV P                  4       V P                  V P                  R7      V n        V P                  # )zGGrayscale Shading object representing the alpha ramp (for a soft mask).Nru  r   rv  )r  rX  r4  r?   r9   r*   r2   r   rw  r   r1  r  r5  r6  )r   rp   r4  s   && r!   get_alpha_shading_object!Gradient.get_alpha_shading_object?  s     ~~)))'t{{T5M::$q(!$++.88:)0!..(88:"00!..*D& )))r#   )rX  rT  rW  r2  r  r3  r8   r4  r6  r5  r  rV  rY  r1  r%   )r>   r   r   r   r   r  rS  rU  rI  r   r|  r  r  r  r   r   )r   s   @r!   r   r     st     -C -C^ 8, 8,t  $ $6 K K * * *r#   r   c                   B   a a ] tR tRt oRV3R lV 3R llltRtVtV ;t# )LinearGradientiZ  c                   < V ^8  d   QhRS[ RS[ RS[ RS[ RS[S[,          RS[S[,          RS[RS[R	S[S[S[ ,          ,          /	# )
r   from_xfrom_yto_xto_yr8   r2  r5  r6  r  r   r   r	   r   rI   r9   )r    r   s   "r!   r"   LinearGradient.__annotate__[  sx     5 55 5 	5
 5 $5 Z(5 5 5 e%5r#   c
                N   < \         S
V `  WVWxV	4       VVVV3V n        ^V n        R# )a  
A shading pattern that creates a linear (axial) gradient in a PDF.

The gradient is defined by two points: (from_x, from_y) and (to_x, to_y),
along which the specified colors are interpolated. Optionally, you can set
a background color, extend the gradient beyond its start or end, and
specify custom color stop positions via `bounds`.

Args:
    from_x (int or float): The x-coordinate of the starting point of the gradient,
        in user space units.
    from_y (int or float): The y-coordinate of the starting point of the gradient,
        in user space units.
    to_x (int or float): The x-coordinate of the ending point of the gradient,
        in user space units.
    to_y (int or float): The y-coordinate of the ending point of the gradient,
        in user space units.
    colors (list[str or tuple[int, int, int]]): A list of colors along which the gradient
        will be interpolated. Colors may be given as hex strings (e.g., "#FF0000") or
        (R, G, B) tuples.
    background (str or tuple[int, int, int], optional): A background color to use
        if the gradient does not fully cover the region it is applied to.
        Defaults to None (no background).
    extend_before (bool, optional): Whether to extend the first color beyond the
        starting point (from_x, from_y). Defaults to False.
    extend_after (bool, optional): Whether to extend the last color beyond the
        ending point (to_x, to_y). Defaults to False.
    bounds (list[float], optional): An optional list of floats in the range (0, 1)
        that represent gradient stops for color transitions. The number of bounds
        should be two less than the number of colors (for multi-color gradients).
        Defaults to None, which evenly distributes color stops.
Nr   r   r4  r1  )r   r  r  r  r  r8   r2  r5  r6  r  r   s   &&&&&&&&&&r!   r   LinearGradient.__init__[  s;    X 	]&Q 	
 	 r#   r4  r1  NFFNr>   r   r   r   r   r   r   r   r   s   @@r!   r  r  Z  s     5 5 5r#   r  c                   B   a a ] tR tRt oRV3R lV 3R llltRtVtV ;t# )RadialGradienti  c                   < V ^8  d   QhRS[ RS[ RS[ RS[ RS[ RS[ RS[S[,          RS[S[,          R	S[R
S[RS[S[S[ ,          ,          /# )r   start_circle_xstart_circle_ystart_circle_radiusend_circle_xend_circle_yend_circle_radiusr8   r2  r5  r6  r  r  )r    r   s   "r!   r"   RadialGradient.__annotate__  s     ; ;; ; #	;
 ; ; !; $; Z(; ; ; e%;r#   c                R   < \         SV `  WxWV4       VVVVVV3V n        ^V n        R# )a  
A shading pattern that creates a radial (or circular/elliptical) gradient in a PDF.

The gradient is defined by two circles (start and end). Colors are blended from the
start circle to the end circle, forming a radial gradient. You can optionally set a
background color, extend the gradient beyond its circles, and provide custom color
stop positions via `bounds`.

Args:
    start_circle_x (int or float): The x-coordinate of the inner circle's center,
        in user space units.
    start_circle_y (int or float): The y-coordinate of the inner circle's center,
        in user space units.
    start_circle_radius (int or float): The radius of the inner circle, in user space units.
    end_circle_x (int or float): The x-coordinate of the outer circle's center,
        in user space units.
    end_circle_y (int or float): The y-coordinate of the outer circle's center,
        in user space units.
    end_circle_radius (int or float): The radius of the outer circle, in user space units.
    colors (list[str or tuple[int, int, int]]): A list of colors along which the gradient
        will be interpolated. Colors may be given as hex strings (e.g., "#FF0000") or
        (R, G, B) tuples.
    background (str or tuple[int, int, int], optional): A background color to display
        if the gradient does not fully cover the region it's applied to. Defaults to None
        (no background).
    extend_before (bool, optional): Whether to extend the gradient beyond the start circle.
        Defaults to False.
    extend_after (bool, optional): Whether to extend the gradient beyond the end circle.
        Defaults to False.
    bounds (list[float], optional): An optional list of floats in the range (0, 1) that
        represent gradient stops for color transitions. The number of bounds should be one
        less than the number of colors (for multi-color gradients). Defaults to None,
        which evenly distributes color stops.
Nr  )r   r  r  r  r  r  r  r8   r2  r5  r6  r  r   s   &&&&&&&&&&&&r!   r   RadialGradient.__init__  sA    ` 	]&Q 
 	 r#   r  r  r  r   s   @@r!   r  r    s     ; ; ;r#   r  c                      a a ] tR tRt oRtRRRR/V3R lV 3R llltV3R	 lR
 ltV3R lR lt]V3R lR l4       t	Rt
VtV ;t# )r   i  zN
PDF Shading type 4 (free-form Gouraud triangle mesh) with per-vertex colors.
r2  Nr@  Tc                "  < V ^8  d   QhRS[ RRRS[RS[S[S[S[S[3,          S[S[S[3,          S[S[S[3,          3,          ,          RS[S[S[S[R3,          S[S[R3,          S[S[R3,          3,          ,          RS[R	,          R
S[/# )r   r3  bboxr   
comp_count	trianglesr8   .r2  r   r@  )r:   r7  r9   r*   r   r   rI   )r    r   s   "r!   r"   MeshShading.__annotate__  s     *L *L *L 	*L
 *L %u%uUE\':E%,<OOP
*L U5,eE3J.?uczARRST*L W%*L *Lr#   c               2  < \        R 4      V n        ^V n        \        V4      V n        V'       d'   RRP	                  R VP
                   4       4       R2MRV n        W n        W@n        WPn	        Wpn
        W0n        ^V n        ^V n        ^V n        VP                  VP                   VP"                  VP$                  .RR.V,          Op\'        V U	u. uF  p	\)        V	4      NK  	  up	4      V n        \,        S
V `]  V P1                  4       RR	7       R# u up	i )
r   r   r   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir%   r   r  s   & r!   r0   'MeshShading.__init__.<locals>.<genexpr>  r<  r  r   Nrx   rY   T)contentscompress)r   r=   r1  r3  r	  r8   r2  _bbox
_triangles_triangle_colorsr@  _comp_countbits_per_coordinatebits_per_componentbits_per_flagx0x1y0y1r   r   decoder   r   _encode_stream_raw)r   r3  r  r  r  r8   r2  r@  decode_valuesrx  r   s   &$$$$$$$  r!   r   MeshShading.__init__  s
    O	,  E:3D3DEEFaH 	
 
# &$% $& "$ GGGGGGGG	

 Cj:%
 -P-e 4-PQ$"9"9";dK  Qs   Dc                   < V ^8  d   QhRR/# )r   r   r   r&   )r    r   s   "r!   r"   r    s      M r#   c                    V # r%   r&   r   s   &r!   r   MeshShading.get_shading_object  s    r#   c                    < V ^8  d   QhRS[ /# r   )bytes)r    r   s   "r!   r"   r    s        E  r#   c                  aa V P                   P                  V P                   P                  r!V P                   P                  V P                   P                  rC^V P
                  ,          ^,
          oS\        W!,
          \        P                  4      ,          pS\        WC,
          \        P                  4      ,          p^V P                  ,          ^,
          oR V3R llpR V3R llpV P                  ^8  d   RMRp	RWP                  ,          ,           p
\        4       p\        V P                  V P                  4       F  w  w  rpw  pppW3VV3VV33 F|  w  w  ppp\        V P                  4       Uu. uF$  pV\!        V4      8  d   V! VV,          4      M^ NK&  	  ppV\"        P$                  ! V
^ V! VW4      V! VW64      .VO5!  ,          pK~  	  K  	  \'        V4      # u upi )r   c                H    V ^8  d   QhR\         R\         R\         R\        /# )r   ro   uminscaler   r   r7  )r    s   "r!   r"   4MeshShading._encode_stream_raw.<locals>.__annotate__  s(     	> 	>5 	> 	>e 	> 	>r#   c                 n   < \        \        W,
          V,          4      4      pV^ 8  d   ^ # VS8  d   S# T# rM   )r7  round)ro   r  r  uimaxcs   &&& r!   q16+MeshShading._encode_stream_raw.<locals>.q16  s5    UAH-./BQ1=BID=2=r#   c                0    V ^8  d   QhR\         R\        /# )r   r   r   r  )r    s   "r!   r"   r    s     	F 	F5 	FS 	Fr#   c                 t   < \        \        \        V 4      S,          4      4      pV^ 8  d   ^ # VS8  d   S# T# rM   )r7  r  r   )r   ivmax_comps   & r!   q_component3MeshShading._encode_stream_raw.<locals>.q_component  s7    U58h./0BQ1EXHE2Er#   HBz>BHH)r  r  r  r  r  r  rl   r   rm   r  r  	bytearrayr   r  r  r4   r2   structpackr  )r   xminxmaxyminymaxsxsyr  r  comp_fmt
vertex_fmtr   v0v1v2rU   rV   r  xycompsr/   component_bytesr  r  s   &                      @@r!   r  MeshShading._encode_stream_raw  s   ZZ]]DJJMMdZZ]]DJJMMdT---2C^%=%=>>C^%=%=>>000A5	> 	>	F 	F 11A533x*:*::;
k*-doot?T?T*U&LRR,2r2#%(RHr2h!?A #4#3#34#4 ./U^Ka)B4   # v{{4$4$	
 %  "@ +V Sz#s   <*G+c                P   < V ^8  d   QhRS[ S[S[,          S[,          ,          /# r   rG  )r    r   s   "r!   r"   r  *  s%      	-"33mC	Dr#   c                    . # )zNType-4 mesh shadings don't use Function objects; return empty list for output.r&   )r  s   &r!   rI  MeshShading.get_functions)  s	    
 	r#   )r  r  r  r  r@  r2  r  r  r  r3  r  r1  r=   )r>   r   r   r   r   r   r   r  r  rI  r   r   r   r   s   @@r!   r   r     s[     *L )-*L  *L *LZ    D   r#   r   c                      a a ] tR tRt oRtRt]P                  RR3V3R lV 3R llltV3R lR lt	V3R	 lR
 lt
V3R lR ltRtVtV ;t# )SweepGradienti1  z
Conic/sweep gradient that materializes as a type-4 (mesh) Shading.
Build is bbox-dependent, so we create the shading lazily at emit time.
NMb`?c                   < V ^8  d   QhRS[ RS[ RS[ RS[ RS[S[S[ S[S[S[3,          3,          ,          RS[RS[3,          RS[S[,          R	S[ /# )
r   cxcystart_angle	end_anglerG   spread_methodr   segmentsinner_radius_factor)r   r   r*   r   r   r:   r   r7  )r    r   s   "r!   r"   SweepGradient.__annotate__E  s     &: &:&: &: 	&:
 &: eU5#:%6678&: 3S89&: 3-&: #&:r#   c	                n  < \         S	V `  4        \        V4      \        V4      uV n        V n        \        V4      \        V4      uV n        V n        WPn        \        \        R 4      '       d   \        P                  ! V4      M
\        V4      V n        Wpn        Wn        RV n        RV n        RV n        R# )coerceN)r   r   r   r  r  r  r  rG   r   r   r  r  r  r  _cached_keyr   _alpha_shading)
r   r  r  r  r  rG   r  r  r  r   s
   &&&&&&&&&r!   r   SweepGradient.__init__E  s     	 9eBi+0+=uY?O($.
 +X66 !''6%m4 	
 !#6   	 0459r#   c                    < V ^8  d   QhRS[ /# r   r   )r    r   s   "r!   r"   r  m  s      4 r#   c                    V P                    F`  w  r\        VR 4      '       g   \        V4      MTp\        VRR4      pVf   K7  \        P
                  ! \        V4      R4      '       d   K_   R# 	  R# )r8   r   NrY   TF)rG   r   r   rZ   r   ri   r   )r   rp   rA   rg  r   s   &    r!   r  SweepGradient.has_alpham  s\    JJDA3:1h3G3G(+QBC&A}^%9%9%(C%H%H	 
 r#   c                "   < V ^8  d   QhRRRR/# r   r  r   r   r   r&   )r    r   s   "r!   r"   r  v  s      }  r#   c                X   VP                   VP                  VP                  VP                  V P                  V P
                  V P                  V P                  V P                  V P                  V P                  P                  3pV P                  e   V P                  V8X  d   V P                  # W n        \        V P                  V P
                  V P                  V P                  V P                  V P                  VV P                  V P                  R7	      V n        V P                  # )Nr  r  r  r  )r  r  r  r  r  r  r  r  r  r  r  rx  r   r   shape_sweep_gradient_as_meshrG   )r   r  rS   s   && r!   r    SweepGradient.get_shading_objectv  s    GGGGGGGGGGGGNNMM$$$$
 ==$)9)9S)@== 4GGGGNNJJ,,]] $ 8 8

 }}r#   c                2   < V ^8  d   QhRRRS[ R,          /# r  r  )r    r   s   "r!   r"   r    s      )# )#] )#x?V )#r#   c                   V P                  4       '       g   R # \        V P                  4      w  r#p\        V4      pV UUu. uF  w  rVV\	        V4      3NK  	  pppRVP
                  VP                  VP                  VP                  V P                  V P                  V P                  V P                  V P                  V P                  V P                  P                   3p\#        V RR 4      V8X  d   V P$                  # \'        V P                  V P                  V P                  V P                  VV P                  VV P                  V P                  R7	      V n        Wn        V P$                  # u uppi )Nr`   _alpha_cached_keyr	  )r  r   rG   r   r   r  r  r  r  r  r  r  r  r  r  r  rx  rZ   r  r
  r  )	r   r  rp   r   alpha01ro   r   
gray_stopsrS   s	   &&       r!   r  &SweepGradient.get_alpha_shading_object  s@   ~~ (

3A%g.-47
-46AQ
1W 	 7

 GGGGGGGGGGGGNNMM$$$$
 4,d3s:&&&:GGGGNN,,]] $ 8 8

 "%"""E7
s   E1)r  r  r   r   r  r  r  r  r  r  r  rG   )r  r  r  r  rG   r  r  r  r   r   r  )r>   r   r   r   r   	__slots__r   r   r   r  r   r  r   r   r   r   s   @@r!   r  r  1  sQ     
I* =Q<T<T"&%*&: &:P  <)# )# )#r#   r  c                    V ^8  d   QhR\         R\         R\         R\         R\        \        \         \        \        \
        3,          3,          ,          R\        RRR	\        \        ,          R
\         R\        /
# )r   r  r  r  r  rG   r  r  r   r  r  r   )
r   r   r*   r   r   r:   r   r   r7  r   )r    s   "r!   r"   r"     s     ` ``` ` 	`
 E%ucz!2234` (` ` sm` ` `r#   c	           
       aaaCaDaEaFaGaHaIaJaKaL \        V4      w  rp	V
^ ,          ^,          p\        V\        4      '       d   Rp^pM\        V\        4      '       d   Rp^pMRp^pR\        P
                  ,          oLVS,
          p\        P                  ! V4      '       d   SLpVR8  d;   VSuopV
 UUu. uF  w  ppRV,
          V3NK  	  p
ppV
P                  R R7       V) p\        P                  ! VR4      '       d   TMSLoH\        SHSL4      oEVf   \        R
\        V
4      ^`,          4      pM\        ^V4      pSE\        V4      ,          p\        \        V\        P
                  R,          4      \        P
                  R,          4      pVP                  W4      p\        \        VP                  VP                   4      \        V4      ,          \        P"                  4      p\        P$                  ! SSL4      oJSJR8  d
   SJSL,          oJ\        P$                  ! SJSH,           SL4      pVR8  d
   VSL,          p\        P&                  ! SHSL4      ;'       d    VSJ8  p\        P(                  ! SHSL4      oISLSJ,
          SL,          oG\        P*                  ! SGR4      '       d   SEoGR.p\-        \        P.                  ! SESH,          4      4      pSEVSH,          ,
          p\        P*                  ! VR4      '       d   Rp\1        V4       F6  pVSH,          pV
 F$  w  rVP3                  VVSH,          ,           4       K&  	  K8  	  VR8  dn   VSH,          pVSH,          pV
 FC  w  r\        P                  ! VV4      '       d    M#VP3                  VVSH,          ,           4       KE  	  VP3                  SE4       MVP3                  SE4       S\4        P6                  8X  EdX   SI'       EgO   \        SESH,
          R4      p\        P                  ! SGR4      '       d/   \        P*                  ! SGSE4      '       d   VP3                  SG4       \        P                  ! VR4      '       d   \        P&                  ! SGSE4      '       d   \        P                  ! SGSH4      '       d   \        \        SHR,          \        P"                  4      SGSH,
          \        P"                  ,
          SESG,
          \        P"                  ,
          4      p\        P                  ! VR4      '       d   VP3                  SGV,
          4       VP                  4        . pV FG  p V'       d,   \        P8                  ! V VR,          4      '       d   V VR&   K6  VP3                  V 4       KI  	  V'       g   RSE.pM/\        V4      ^8X  d    VP3                  V^ ,          SE,           4       SJSH,           p!\        P                  ! V!SL4      oFSSG,           p"R VEVFVGVHVIVVVJVL3	R llp#. p$V F  p \        P(                  ! V SE4      '       d=   SI'       g5   \        P                  ! SESH4      '       d   S\4        P6                  8w  d   K\  SV ,           p%V#! V 4      p&S\4        P6                  8X  d   V&R8:  d   RM
V&R8  d   RMT&p'M\;        V&S4      p'\=        V
V'4      p(V$P3                  V%V&V(34       K  	  V$'       g   . p)EMS\4        P6                  8X  d   SI'       g   V'       d   SSG,           p"V$^ ,          ^,          p*. p)Rp+V$ Fm  w  p%p&p(V)P3                  V%V(34       V+'       d   K$  \        P8                  ! V%V"4      '       g   KC  V)P3                  V%\        P"                  ,           V*34       Rp+Ko  	  V+'       g)   V)P3                  V"\        P"                  ,           V*34       MV$ U%U	U(u. uF  w  p%p	p(V%V(3NK  	  p)p	p%p(. p,V
^ ,          ^,          P>                  p-V)'       Ed   V,P3                  V)^ ,          4       \1        \        V)4      ^,
          4       EFU  p.V)V.,          w  p/oCV)V.^,           ,          w  p0oDV0V/,
          p1\        P*                  ! V1R4      '       d&   V,'       d	   V0SD3V,R&   MV,P3                  V0SD34       Kn  V'       d"   \        P                  ! V/V"4      '       d   V-oCV-oD\        ^\-        \        P@                  ! V1V,          4      4      4      p2\1        ^V2^,           4       Fw  p3V3V2,          oKV/SKV1,          ,           p%\B        ;QJ d"    . VCVDVK3R l\1        V4       4       F  NK  	  5M! VCVDVK3R l\1        V4       4       4      p(V,P3                  V%V(34       Ky  	  EKX  	  \        V,4      ^8:  d\   V)'       d   V)^ ,          ^ ,          MSp%V)'       d   V)^ ,          ^,          MV
^ ,          ^,          P>                  p4V%V43V%SE,           V43.p,. p5. p6V,^ ,          w  p7p8V V\        PD                  ! V74      ,          ,           p9VV\        PF                  ! V74      ,          ,           p:V V\        PD                  ! V74      ,          ,           p;VV\        PF                  ! V74      ,          ,           p<V,R,           F  w  p=p>V V\        PD                  ! V=4      ,          ,           p?VV\        PF                  ! V=4      ,          ,           p@V V\        PD                  ! V=4      ,          ,           pAVV\        PF                  ! V=4      ,          ,           pBV5P3                  V9V:3V;V<3VAVB334       V6P3                  V8V8V>34       V5P3                  V9V:3VAVB3V?V@334       V6P3                  V8V>V>34       T=T>p8p7T?T@p:p9TATBp<p;EK  	  \I        VVVV5V6R	RR7      # u uppi u up(p	p%i )u   
Approximate a sweep (conic) gradient as a Type 4 mesh (triangles).
We build a full 0..2π fan so PAD/REPEAT/REFLECT outside [0,1] are respected.
Angles are expected in radians.
r   r   r
   r   rx   rY   c                     V ^ ,          # rM   r&   rO   s   &r!   rP   .shape_sweep_gradient_as_mesh.<locals>.<lambda>  s    adr#   rR   Ni   g     v@g{Gz?c                0    V ^8  d   QhR\         R\         /# )r   progressr   r   )r    s   "r!   r"   2shape_sweep_gradient_as_mesh.<locals>.__annotate__>  s     & &E &e &r#   c                 0  <	 \         P                  ! SR 4      '       d   R # SV ,           p\         P                  ! V S4      '       d?   S
\        P                  8X  d(   S	'       g    \         P
                  ! SS4      '       d   R # R# S
\        P                  8X  d   S	'       d)   \         P
                  ! SR 4      '       d
   V S,          # R # S'       g~   \        P                  ! VS4      pVR 8  d
   VS,          pSS,           p\         P                  ! VS4      '       d   R # \         P                  ! W#4      '       d   VS,
          S,          # R # \        S\         P                  4      p\         P                  ! W4      '       d	   W,          # R # V S,          # )rx   rY   )r   rk   rj   r   r   rh   r   fmodrg   rl   rm   )r  theta	angle_mod	end_limitvisible
cover_spancrosses_360seam_progressrt   span_covers_full_circler  r  	start_modtaus   &    r!   raw_from_progress7shape_sweep_gradient_as_mesh.<locals>.raw_from_progress>  s>   $$T3//h&''*==!5!9!99/"//
DAA0444&'5'B'B4'M'MHtOSV  IIeS1	s?$I%,	!++IyAA!,,YBB%	1T99 -)A)ABG((;;))$r#   FTc              3   |   <"   T F1  pSV,          SV,          SV,          ,
          S,          ,           x  K3  	  R # 5ir%   r&   )r.   jcolor0color1r   s   & r!   r0   /shape_sweep_gradient_as_mesh.<locals>.<genexpr>  s3      EVF1IVAY!6! ;;;EVs   9<:r   NN)r3  r  r  r  r8   r2  r@  rf   )%r   r?   r   r   r   pir   r   r   rh   rl   r2   r   r   max_distance_to_pointwidthheightrm   r  rg   rj   rk   r7  r   r4   r   r   r   ri   r   r   r8   ceilr*   cossinr   )Mr  r  r  r  rG   r  r  r  r  rp   
norm_stopsfirst_cr3  r  deltaro   rA   base_segments	max_angler_outerr_innerend_modwrapsprogress_candidates
tile_count	remaindertilebase_progressportiontail_lengthseam_epsprogress_nodesr  	span_pluslimit_thetar&  fan_line_rawr  rawmappedr{   fan_line	pad_colorinsertedsamplesstart_color_componentsrq   theta0theta1delta_thetasplitss
base_colorr  
tri_colors
theta_prev
color_prevx_prev_innery_prev_innerx_prev_outery_prev_outer
theta_next
color_nextx_next_innery_next_innerx_next_outery_next_outerr*  r+  r   r!  r"  rt   r#  r$  r   r%  sM   &&f&&f&&&                                                          @@@@@@@@@@r!   r
  r
    s	     'u-A1mAG':&&"
	GY	'	'!
"

-C#Ee$$s{!*KY1;<v1sQwl
<N+"//s;;5DT3JD#j/B"67B)U=11IC	477S=1477U?CI((0GDJJ$u-@'AA  G
 		+s+I3S	ii	D(#.G}3$$T3/GGGi4GE,::4E9_+M  44"(+uTZZ
T 123JZ$..I  C00	j!tDA&&}q4x'?@  "
 3d""T)DA**1g66&&}q4x'?@  	"":."":.,0009P9P*t+S1&&3
 
''zBB&&}5''S99((
CC++M4@@D4K!9!9:$~'?'??]*^-E-EEH
 **8S99#**=8+CD"$N'n228^B=OPP!)N2!!(+	 ( z*	^		!nQ/*<=D I --i=K-K& & &P BDL"((:>>+++J==!5!9!99h&)04443JS3#:C3F]3FZ0UC/0 #" :<-111'!M1 OA&	!-E3OOUEN+8 4 4UK H H)A)A!A9 MN	 ".
 OO[>+C+CCYOP<HIL'8q%UENLI57G']1-44xx{#X*+C%c]NFF%cAg.NFF 6/K((c::#)6"2GBKNNFF#3444V[II//C		+	*A BCDF1fqj)J[0 EJ:EV EJ:EV  u~. * ,, 7|q"*A'/Xa[^Z]15E5L5L
JZ,
 	  	  %QZJ
$((:"666L$((:"666L$((:"666L$((:"666L")"++
JGdhhz&:::Gdhhz&:::Gdhhz&:::Gdhhz&:::|,|,|,	
 	:z:>?|,|,|,	
 	:z:>?!+ZJ
%1<l%1<ll5 #.8  k =P Js   4n?oc                   V ^8  d   QhR\         R\         R\         R\         R\        \        \         \        \        \
        3,          3,          ,          R\        \        \
        3,          R\        R,          R	\        /# )
r   r  r  x2y2rG   r  r  r   r   )	r   r   r*   r   r   r:   r   r   r  )r    s   "r!   r"   r"     s     @ @@@ 	@ 		@
 E%ucz!2234@ -s23@ =
!@ @r#   c                   V'       g   \        R4      h\        P                  ! V4      p\        VRR7      w  rxp	V\        P                  8X  g   VfI   V UU
u. uF  w  rzV
NK	  	  ppp
V^R	  UUu. uF  w  rVNK	  	  ppp\        V VVVVVRRR7      pWn        V# V	RJ;'       d    \        V	4      ^8  pV'       d   T	MTpVf   Q hV^ ,          ^ ,          pVR	,          ^ ,          p\        VV,
          \        P                  4      p\        P                  ! VR4      '       d   RpRpTpVP                  WW#4      w  ppp\        P                  ! VR4      '       d6   V^ ,          ^,          VR	,          ^,          pp\        V VVVVV.. RRR7      # VV,          pVV,          p\        P                  ! VV,
          V,          4      ^,
          p\        P                  ! VV,
          V,          4      ^,           p. p\!        VV^,           4       F  pVV,          pV\        P"                  8X  g   V^,          ^ 8X  d)   V F   w  p p!VP%                  VV ,           V!34       K"  	  KW  \'        V4       F7  w  p p!VV,           V,           V V,
          ,
          p"VP%                  V"V!34       K9  	  K  	  \        VR4      p#VV#,
          p$VV#,           p%V U&U'u. uFH  w  p&p'\        P(                  ! V&V$4      '       g   K%  \        P                  ! V&V%4      '       g   KD  V&V'3NKJ  	  up'p&;'       g    Tp(V(^ ,          ^ ,          p)V(R	,          ^ ,          p*\        V*V),
          \        P                  4      p+V( U&U'u. uF  w  p&p'V&V),
          V+,          V'3NK  	  p,p&p'T)p-V)V+,           p.V V-W ,
          ,          ,           p/VV-W1,
          ,          ,           p0V V.W ,
          ,          ,           p1VV.W1,
          ,          ,           p2\+        V,4      p3V3 UU'u. uF  w  pp'V'NK
  	  p4pp'V3^R	  U5Uu. uF  w  p5pV5NK
  	  p6p5p\        V/V0V1V2V4V6RRR7      pWn        V# u up
pi u uppi u up'p&i u up'p&i u up'pi u upp5i )
z
Create a linear gradient for a shape with SVG-like stops (offset in [0,1]).
REPEAT/REFLECT are implemented by expanding stops to cover the bbox projection.
rK   TrE   N)r  r  r  r  r8   r  r5  r6  rx   rY   Frf   )r3   r   r  r   r   r  rY  r2   rl   r   rm   rk   project_interval_on_axisr   r   r1  r4   r   r   reversedrj   r   )7r  r  rd  re  rG   r  r  rp   normalized_stopsrY  r{   r8   offsetr  gradientuse_raw_period
tile_stops
base_startbase_end	base_spantmintmaxLrU   rV   	tmin_norm	tmax_norm
start_tileend_tileexpandedkshiftro   r   mirroredmarginr   r   rT  rA   clippeds0sNrt   renormlam0lam1nx1ny1nx2ny2mergedlinear_gradient_colorsolinear_gradient_boundss7   &&&&&&&                                                r!   shape_linear_gradientr    sO    899(//>M%4Ut%L"A,000DL
 )99(8HA%(89*:1R*@A*@YV&*@A!	
 ' d*BBs9~/BN,2BJ!!!Aq!J"~a HHz)>+C+CDI  C00
	%
11""AMD$  C((!!$Q')9")=a)@B8	
 		
 qIqIY3y@AAEJyy)j0I=>BH68H:x!|,I0777AEa<$3C 01 % #:.3 :-	9Q^L30 / - C FFAFA FQ''1- 	2@2K2KAq2Q 	A   
	  
AB	QBrBw001D189v1B$"F9 D9D
trw
C
trw
C
trw
C
trw
C #6*F,23FDAqaF3,21RL9LDAqaL9%%	H #OO :AB : 49s0   Q0Q"Q;QQ6Q!
Q'#Q-rx   c                F   V ^8  d   QhR\         R\         R\         R\        \        \         \        \        \
        3,          3,          ,          R\        \         ,          R\        \         ,          R\         R\        \        \
        3,          R	\        R
,          R\        /
# )r   r  r  rrG   fxfyfrr  r  r   r   )	r   r   r*   r   r   r:   r   r   r  )r    s   "r!   r"   r"   f  s     e eee e E%ucz!2234	e
 	e 	e 	e -s23e =
!e er#   c	                ,	  a aaaaaa7a8 V'       g   \        R4      h\        P                  ! V4      p\        VRR7      w  rpS^ 8  d   \        R4      hS^ 8  d   RoSf   S oSf   SoSS8  d   SoV\        P                  8X  g   VfL   V
 U	Uu. uF  w  rVNK	  	  pp	pV
^R  UU	u. uF  w  rVNK	  	  ppp	\        SSSS SSVVRRR7
      pVVn        V# VRJ;'       d    \        V4      ^8  pV'       d   TMT
pVf   Q hV^ ,          ^ ,          o8VR,          ^ ,          p\        VS8,
          \        P                  4      o7\        P                  ! S7R4      '       d   Ro8Ro7T
p\        P                  ! SS4      '       dL   V
 U	Uu. uF  w  rVNK	  	  pp	pV
^R  UU	u. uF  w  rVNK	  	  ppp	\        SSSS SSVVRRR7
      pVVn        V# R	 V7V83R
 llpR V VVVVV3R llpTpVeq   Rp\        V4       FO  p	V! V4      pV! V4      w  ppp\        P                  ! VP                  VV4      V4      '       d    MVS7,          pKQ  	  VVS7,          ,           p^ pVV8  d%   \        P                   ! VV,
          S7,          4      p. p\        V^,           4       F  pVS7,          pV\        P"                  8X  g   V^,          ^ 8X  d)   V F   w  p p!VP%                  VV ,           V!34       K"  	  KW  \'        V4       F7  w  p p!VS8,           S7,           V S8,
          ,
          p"VP%                  V"V!34       K9  	  K  	  V'       g
   VR,          pVS7,           R,           p#V U$u. uF  p$V$^ ,          V#8:  g   K  V$NK  	  pp$V^ ,          ^ ,          p%VR,          ^ ,          p&\        V&V%,
          \        P                  4      p'V U(U)u. uF  w  p(p)V(V%,
          V',          V)3NK  	  p*p(p)V! V%4      p+V! V&4      p,V! V+4      w  p-p.p/V! V,4      w  p0p1p2\)        V*4      p3V3 U	U)u. uF  w  p	p)V)NK
  	  p4p	p)V3^R  U5U	u. uF  w  p5p	V5NK
  	  p6p5p	\        V-V.V/V0V1V2V4V6RRR7
      pVVn        V# u upp	i u up	pi u upp	i u up	pi u up$i u up)p(i u up)p	i u up	p5i )z
Create a radial gradient for a shape with SVG-like stops (offset in [0,1]).
- (cx, cy, r): outer circle
- (fx, fy, fr): focal/inner circle (defaults to center with radius 0)
REPEAT/REFLECT are implemented by expanding stops to cover the bbox projection.
rK   Trg  zOuter radius r must be >= 0rx   N)
r  r  r  r  r  r  r8   r  r5  r6  rY   c                0    V ^8  d   QhR\         R\         /# )r   sigmar   r   )r    s   "r!   r"   +shape_radial_gradient.<locals>.__annotate__  s     0 0u 0 0r#   c                 $   < V S,
          S,          # r%   r&   )r  rq  ro  s   &r!   sigma_to_lambda.shape_radial_gradient.<locals>.sigma_to_lambda  s    
"i//r#   c                \    V ^8  d   QhR\         R\        \         \         \         3,          /# )r   lamr   )r   r*   )r    s   "r!   r"   r    s&     
 
u 
ueU':!; 
r#   c                 P   < \        SSV 4      \        SSV 4      \        SSV 4      3# r%   r-   )r  r  r  r  r  r  r  s   &r!   	circle_at(shape_radial_gradient.<locals>.circle_at  s1    RRQ
 	
r#      rm  r   Frf   )r3   r   r  r   r   r  rY  r2   rl   r   rm   rk   ri   r4   r.  r   r1  r   r   ri  r   )9r  r  r  rG   r  r  r  r  r  rp   rj  rY  r{   r8   rk  r  rl  rm  rn  rp  r  r  target_sigma	max_tilesr  cx_lamcy_lamr_lamtiles_neededry  rz  r{  ro   r   r|  
clip_limitpairr  r  rt   rT  rA   r  r  r  r  r  srexeyerr  radial_gradient_colorsr  radial_gradient_boundsrq  ro  s9   fff&fff&&                                              @@r!   shape_radial_gradientr  f  s   " 899(//>M%4Ut%L"A1u677	Av	z	z	Av,000DL
 )99(8HA%(89*:1R*@A*@YV&*@A! "
 ' d*BBs9~/BN,2BJ!!!Aq!J"~a HHz)>+C+CDI  C00
	%
 Ar""(89(8HA%(89*:1R*@A*@YV&*@A! "
 '0 0
 
 L	y!A!,/C$-cN!FFE((**66:E  I%L " $i)&;;LLhyy,"9Y!FG*,H<!#$I0777AEa<$3C 01 % #:.3 :-	9Q^L30 / % a= 	)D0J!)CT!W
-BHC	!QB	"aBrBw001D19:v1B$"F:2D2D4JBB4JBB #6*F,23FDAqaF3,21RL9LDAqaL9%%H #HOy :A> :Ax D
 ; 49s6   Q'(Q-Q3 Q9#Q?8Q?RR
8R)T)Nr  )6r   r   r  abcr   typingr   r   r   r   drawing_primitivesr   r   r	   r
   r   r   r   r   enumsr   syntaxr   r   r   r   utilr   r   r   drawingr   r(   r5   rD   r   r   r   r   r   r   r   r  r  r   r   r  r  r   r  r
  r   r  r  r&   r#   r!   <module>r     sD      ; ;	 	 	 ( ? ? < <$="F0 	F0 F0R<&	!+$i +$\I .		 	GI G,%i %PD*s D*N6X 6r<X <~\" \~L#I L#^`R	 7K6N6N$(@P 6J6N6N$(e er#   