+
    iH                        R t ^ RIt^ RIt^ RIt^ RIt ^ RIt]P                  R8  d   ]! R]P                   R24      h ^RIHtHtHt ^ RIHtHtHtHtHt ^ RIHt ^ RIHt ^ R	IHt R
 tRR ltR t ! R R]4      t ! R R]4      t ! R R4      t  ! R R]4      t!]PD                   ! R R]4      4       t#R#   ] d!     ^ RI	t L  ] d   t
]! R4      ]
hRt
A
ii ; ii ; i)z
A Cairo backend for Matplotlib
==============================
:Author: Steve Chaplin and others

This backend depends on cairocffi or pycairo.
Nz/Cairo backend requires cairo>=1.14.0, but only z is availablezEcairo backend requires that pycairo>=1.14.0 or cairocffi is installed)_apicbookfont_manager)_BackendFigureCanvasBaseFigureManagerBaseGraphicsContextBaseRendererBase)ttfFontProperty)Path)Affine2Dc                     \        V4      ^8X  g	   V'       d   V P                  ! . VR,          OVN5!   R# V P                  ! V!   R# )   Nr   NN)lenset_source_rgba)ctxcoloralphaforced_alphas   &&&&ځ/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/matplotlib/backends/backend_cairo.py	_set_rgbar   %   s7    
5zQ,.U2Y..U#    c                    VP                  VR VR7       EF<  w  rEV\        P                  8X  d   V P                  ! V!   K-  V\        P                  8X  d   V P                  4        KT  V\        P                  8X  d   V P                  ! V!   K{  V\        P                  8X  d   \        P                  ! V P                  4       4      pVR,          pVRR pV P                  ! . V^,          V^,          ^,          ,           OV^,          ^,          V^,          ,           OVO5!   EK  V\        P                  8X  g   EK,  V P                  ! V!   EK?  	  R# )T)remove_nansclip:N   NN)iter_segmentsr   MOVETOmove_to	CLOSEPOLY
close_pathLINETOline_toCURVE3npasarrayget_current_pointcurve_toCURVE4)	r   path	transformr   pointscodecurabs	   &&&&     r   _append_pathr2   ,   s    **4d + 44;;KK T^^#NNT[[ KK T[[ **S2245Cr
ArsALLJ37QUQY.J1q519q1u3DJJT[[ LL&!4r   c                  a  V 3R lpV! R4      p\        \        RV! R4      P                  4        24      pV! R4      p\        P                  P                  WD4      R8  d   \        P                  M\        P                  pW#V3# )zo
Convert a `.FontProperties` or a `.FontEntry` to arguments that can be
passed to `.Context.select_font_face`.
c                 h   <  \        SR V  24      ! 4       #   \         d    \        ST 4      u # i ; i)get_)getattrAttributeError)fieldprops   &r   attr-_cairo_font_args_from_font_prop.<locals>.attrC   s:    	(44w022 	(4''	(s    11nameFONT_SLANT_styleweighti&  )r6   cairoupperr   weight_dictgetFONT_WEIGHT_NORMALFONT_WEIGHT_BOLD)r9   r:   r<   slantr?   s   f    r   _cairo_font_args_from_font_proprG   >   s|    
( <DE[g)<)<)>(?@AE(^F))--f=C &&))  r   c                      a a ] tR t^Rt oV 3R ltR t]R 4       tRR ltRR lt	R t
RR ltR tR	 tV 3R
 ltR tR tRtVtV ;t# )RendererCairoc                   < Wn         \        V R 7      V n        RV n        RV n        \
        P                  ! \
        P                  ! \
        P                  ^^4      4      V n	        \        SV `-  4        R# ))rendererN)dpiGraphicsContextCairogcwidthheightr@   ContextImageSurfaceFORMAT_ARGB32text_ctxsuper__init__)selfrL   	__class__s   &&r   rV   RendererCairo.__init__S   sU    &5
e111a8:r   c                   VP                  4       p\        VR 4      '       d4   \        VR4      '       d"   VP                  4       VP                  4       3pM\        VR4      '       d*   VP	                  4       pVP
                  VP                  3pMXVP                  4        VP                  4        VP                  4       vrVV'       d   \        R4      hVv rsVP                  4        WP                  n        Vw  V n        V n        R# )	get_width
get_heightget_extentszCannot infer surface sizeN)
get_targethasattrr[   r\   r]   rO   rP   save
reset_clipcopy_clip_rectangle_list	TypeErrorrestorerN   r   )rW   r   surfacesizeextrectrest_s   &&      r   set_contextRendererCairo.set_context\   s    .."7K((WWl-K-K$$&(:(:(<<DWm,,%%'C99cjj(DHHJNN668KD ;<<KAqKKM"&
DKr   c                    Ve=   V P                  4        \        WW#4       V P                  4        V P                  4        V P	                  4        R # N)r`   r   fill_preserverd   stroke)r   fill_cr   alpha_overridess   &&&&r   _fill_and_strokeRendererCairo._fill_and_stroken   s9    HHJc5:KKM

r   c                0   VP                   pVf#   VP                  4       f   VP                  4       MR pV\        4       P	                  ^R4      P                  ^ V P                  4      ,           pVP                  4        \        WRW64       VeZ   VP                  4        \        WTVP                  4       VP                  4       4       VP                  4        VP                  4        VP                  4       pV'       Ed   \!        V P"                  4      pVP%                  4       P'                  \(        P*                  P,                  W4      p	\(        P.                  ! V	4      p
\        W\        4       P	                  W) 4      P                  ^ V4      R 4       V
P1                  V P3                  VP5                  4       4      4       V
P6                  ! VP9                  4       !   V
P                  4        V
P;                  4        \(        P<                  ! V	4      pVP?                  \(        P@                  PB                  4       VP                  4        VPE                  V4       VP                  4        VP                  4        VP;                  4        R # N)#r   	get_hatchclip_extentsr   scale	translaterP   new_pathr2   r`   r   	get_alphaget_forced_alpharo   rd   get_hatch_pathintrL   r^   create_similarr@   ContentCOLOR_ALPHArQ   set_line_widthpoints_to_pixelsget_hatch_linewidthr   get_hatch_colorrp   SurfacePattern
set_extendExtendREPEAT
set_source)rW   rN   r+   r,   rgbFacer   r   
hatch_pathrL   hatch_surface	hatch_ctxhatch_patterns   &&&&&       r   	draw_pathRendererCairo.draw_pathw   s   ff ?r||~'=   " 	 z''2.88DKKHI	S	0HHJcBLLNB4G4G4IJKKM&&(
:dhh-CNN,;;))35Mm4I!))#t4>>q#F $$T%:%:2;Q;Q;S%TU%%r'9'9';<##%!00?M$$U\\%8%89HHJNN=)KKM

r   c           	        VP                   pVP                  4        \        WrV\        4       P	                  ^R4      ,           4       VP                  4       pVP                  4       w  rrV^ 8X  d   V	^ 8X  d   V
^ 8X  d   V^ 8X  d   RpRpMRpV\        4       P	                  ^R4      P                  ^ V P                  4      ,           pVP                  4        \        VP                  VRR7      4       F  w  pw  r\        V4      '       g   K  VRR w  ppVP                  4        VP                  VV4       VP                  V4       VP                  4        V'       g   VR,          ^ 8X  g   K~  V P                  WvVP!                  4       VP#                  4       4       K  	  V'       g2   V P                  WvVP!                  4       VP#                  4       4       R# R# )   FNT)simplifyi  rw   r   )r   r|   r2   r   rz   copy_path_flatfill_extentsr{   rP   	enumerater   r   r`   append_pathrd   rs   r}   r~   )rW   rN   marker_pathmarker_transr+   r,   r   r   x1y1x2y2fillediverticescodesxys   &&&&&&&           r   draw_markersRendererCairo.draw_markers   s    ffS|hj6F6Fq"6M'MN((* ))+7rQw27rQwFGFz''2.88DKKHI	 	$-""9u"=%? A 8}}}1
 a#, QX]))bllnb6I6I6KM#%?* !!bllnb.A.A.CE r   c                d   \         P                  ! VR R R1,          4      p\        P                  P	                  VP                  4       P                  \        P                  VP                  ^,          VP                  ^ ,          VP                  ^,          ^,          4      pVP                  pV P                  V,
          VP                  ^ ,          ,
          pVP                  4        VP                  V\        V4      \        V4      4       VP                  4        VP                  4        R # rv   )r   ._unmultiplied_rgba8888_to_premultiplied_argb32r@   rR   create_for_dataraveldatarS   shaper   rP   r`   set_source_surfacefloatpaintrd   )rW   rN   r   r   imre   r   s   &&&&&  r   
draw_imageRendererCairo.draw_image   s    AA"TrT(K$$44HHJOOU00HHQK!bhhqkAo7 ffKK!Obhhqk)
wa%(;		r   c	                p   V'       d   V P                  WW4WV4       R # VP                  p	V	P                  4        V	P                  W#4       V	P	                  4        V	P
                  ! \        V4      !   V	P                  V P                  VP                  4       4      4       \        P                  ! 4       p
V
P                  VP                  4       4       V	P                  V
4       V'       d'   V	P                  \         P"                  ! V) 4      4       V	P%                  V4       V	P'                  4        R # rn   )_draw_mathtextr   r|   r    r`   select_font_facerG   set_font_sizer   get_size_in_pointsr@   FontOptionsset_antialiasget_antialiasedset_font_optionsrotater&   deg2rad	show_textrd   )rW   rN   r   r   sr9   angleismathmtextr   optss   &&&&&&&&&  r   	draw_textRendererCairo.draw_text   s    
 qT9 &&CLLNKKHHJ  "A$"GHd33D4K4K4MNO$$&Dr1134  &

2::uf-.MM!KKMr   c                   VP                   pV P                  P                  P                  W@P                  V4      w  rrpVP                  4        VP                  W#4       V'       d'   VP                  \        P                  ! V) 4      4       V F  w  rpppVP                  4        VP                  VV) 4       VP                  ! \        \        V4      4      !   VP                  V P!                  V4      4       VP#                  \%        V4      4       K  	  V FQ  w  ppppVP                  4        VP'                  VV) VV) 4       VP)                  ^ ^ ^ 4       VP+                  4        KS  	  VP-                  4        R# )    N)r   
_text2pathmathtext_parserparserL   r`   r{   r   r&   r   r|   r    r   rG   r
   r   r   r   chr	rectangleset_source_rgbro   rd   )rW   rN   r   r   r   r9   r   r   rO   rP   descentglyphsrectsfontfontsizeidxoxoywhs   &&&&&&&             r   r   RendererCairo._draw_mathtext   s2   ffOO++11!XXtD 	.w 	
aJJrzz5&)*+1'DCRLLNKKRC   01FGId33H=>MM#c(# ,2 "LBAqLLNMM"rc1qb)q!Q'	 " 	r   c                2    V P                   V P                  3# rn   )rO   rP   rW   s   &r   get_canvas_width_height%RendererCairo.get_canvas_width_height  s    zz4;;&&r   c                  < VR 8X  d   \         SV `  WV4      # V'       d7   V P                  P                  P	                  WP
                  V4      vrErgWEV3# V P                  pVP                  4        VP                  ! \        V4      !   VP                  V P                  VP                  4       4      4       VP                  V4      R,          w  rpVP                  4        WW,           3# )TeX:r      N)rU   get_text_width_height_descentr   r   r   rL   rT   r`   r   rG   r   r   r   text_extentsrd   )rW   r   r9   r   rO   rP   r   rj   r   	y_bearingr   r   rX   s   &&&&        r   r   +RendererCairo.get_text_width_height_descent  s     U?78&II//55a4H 'E7'))mm 	
=dCD$//0G0G0IJK**1-c2	aQ]""r   c                    V P                   P                  P                  4        ^V P                   n        RV P                   n        RV P                   n        V P                   # )r   FN)rN   r   r`   _alpha_forced_alpha_hatchr   s   &r   new_gcRendererCairo.new_gc'  sC    
  %wwr   c                6    V^H,          V P                   ,          # )H   )rL   )rW   r-   s   &&r   r   RendererCairo.points_to_pixels3  s    {TXX%%r   )rL   rN   rP   rT   rO   rn   )FN)__name__
__module____qualname____firstlineno__rV   rk   staticmethodrs   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classcell__rX   __classdict__s   @@r   rI   rI   R   sX     '$  #J.E`04'#0
& &r   rI   c                   "  a a ] tR tRt oR]P
                  R]P                  R]P                  /tR]P                  R]P                  R]P                  /tV 3R ltR tV 3R	 ltR
 tR tR tR tR tR tRV 3R lltR tR tR tRtVtV ;t# )rM   i8  bevelmiterroundbutt
projectingc                0   < \         SV `  4        Wn        R # rn   )rU   rV   rK   )rW   rK   rX   s   &&r   rV   GraphicsContextCairo.__init__E  s     r   c                :    V P                   P                  4        R # rn   )r   rd   r   s   &r   rd   GraphicsContextCairo.restoreI  s    r   c                   < \         SV `  V4       \        V P                  V P                  V P                  4       V P                  4       4       R # rn   )rU   	set_alphar   r   _rgbr}   r~   )rW   r   rX   s   &&r   r  GraphicsContextCairo.set_alphaL  s:    % HHdii!143H3H3J	Lr   c                    V P                   P                  V'       d   \        P                  4       R # \        P                  4       R # rn   )r   r   r@   ANTIALIAS_DEFAULTANTIALIAS_NONE)rW   r1   s   &&r   set_antialiased$GraphicsContextCairo.set_antialiasedQ  s/    '(E##	D.3.B.B	Dr   c                6    V P                   P                  4       # rn   )r   get_antialiasr   s   &r   r   $GraphicsContextCairo.get_antialiasedU  s    xx%%''r   c                    V P                   P                  \        P                  ! V P                  VR 7      4       Wn        R# ))capstyleN)r   set_line_capr   check_getitem_capd	_capstyle)rW   css   &&r   set_capstyle!GraphicsContextCairo.set_capstyleX  s*    d00bIJr   c                    V'       g   R # \         P                  ! VP                  4      w  r#rEV P                  pVP	                  4        VP                  W P                  P                  V,
          V,
          WE4       VP                  4        R # rn   )	r&   r   boundsr   r|   r   rK   rP   r   )rW   r   r   r   r   r   r   s   &&     r   set_clip_rectangle'GraphicsContextCairo.set_clip_rectangle\  s]    XXi../
ahha--1A5q<
r   c                8   V'       g   R # VP                  4       w  r#V P                  pVP                  4        V\        4       P	                  ^R4      P                  ^ V P                  P                  4      ,           p\        WBV4       VP                  4        R # rv   )
get_transformed_path_and_affiner   r|   r   rz   r{   rK   rP   r2   r   )rW   r+   tpathaffiner   s   &&   r   set_clip_path"GraphicsContextCairo.set_clip_pathe  sq    <<>hhJ$$Q+55a9M9MNOS(
r   c           	         W3V n         Vf   V P                  P                  . ^ 4       R # V P                  P                  \        V P                  P                  \        P                  ! V4      4      4      V4       R # rn   )_dashesr   set_dashlistrK   r   r&   r'   )rW   offsetdashess   &&&r   
set_dashesGraphicsContextCairo.set_dashesp  sY    ~>HHb!$HHT]]33BJJv4FGHr   c                   < \         SV `  W4       \        V P                  4      ^8X  d'   V P                  P
                  ! V P                  !   R# V P                  P                  ! V P                  !   R# )r   N)rU   set_foregroundr   r  r   r   r   )rW   fgisRGBArX   s   &&&r   r+  #GraphicsContextCairo.set_foregroundy  sL    r*tyy>QHH##TYY/HH$$dii0r   c                `    V P                   P                  4       P                  4       R ,          # )r   )r   
get_sourceget_rgbar   s   &r   get_rgbGraphicsContextCairo.get_rgb  s#    xx""$--/33r   c                    V P                   P                  \        P                  ! V P                  VR 7      4       Wn        R# ))	joinstyleN)r   set_line_joinr   r  _joind
_joinstyle)rW   jss   &&r   set_joinstyle"GraphicsContextCairo.set_joinstyle  s*    t11$++LMr   c                    \        V4      V n        V P                  P                  V P                  P                  V4      4       R # rn   )r   
_linewidthr   r   rK   r   )rW   r   s   &&r   set_linewidth"GraphicsContextCairo.set_linewidth  s.    ( > >q ABr   )r  r#  r8  r=  rK   rn   )r   r   r   r   r@   LINE_JOIN_BEVELLINE_JOIN_MITERLINE_JOIN_ROUNDr7  LINE_CAP_BUTTLINE_CAP_SQUARELINE_CAP_ROUNDr  rV   rd   r  r
  r   r  r  r   r(  r+  r2  r:  r>  r   r   r   r   s   @@r   rM   rM   8  s     %''%''%''F 	u**u,,u++E!L
D(	14C Cr   rM   c                   &   a  ] tR tRt o R tRtV tR# )_CairoRegioni  c                    Wn         W n        R # rn   )_slices_data)rW   slicesr   s   &&&r   rV   _CairoRegion.__init__  s    
r   )rJ  rI  N)r   r   r   r   rV   r   r   r   s   @r   rG  rG    s      r   rG  c                      a  ] tR tRt o ]R 4       tR tR tR tR t	R t
]
tR tR	R
/R lt]P                  ! ]R4      t]P                  ! ]R4      t]P                  ! ]R4      t]P                  ! ]R4      tRtV tR# )FigureCanvasCairoi  c                    \        V R 4      '       g%   \        V P                  P                  4      V n        V P                  # _cached_renderer)r_   rI   figurerL   rR  r   s   &r   	_rendererFigureCanvasCairo._renderer  s3     t/00$1$++//$BD!$$$r   c                    V P                   # rn   )rT  r   s   &r   get_rendererFigureCanvasCairo.get_renderer  s    ~~r   c           	        V P                   P                  P                  P                  4       p\	        V\
        P                  4      '       g   \        R 4      hVP                  4       pVP                  4       p\        P                  ! VP                  4      p\        P                  ! VP                  4      p\        P                  ! WAP                  ,
          4      p\        P                  ! WAP                   ,
          4      p^ V8:  dJ   Wc8:  dD   VP                  VP                  8:  d)   ^ V8:  d"   W8:  d   VP                   VP                  8:  g   \#        R4      h\%        Ww\'        W,
          ^ 4      ,           4      \%        WU\'        We,
          ^ 4      ,           4      3p	\(        P*                  ! VP-                  4       \(        P.                  4      P1                  WC34      V	,          P3                  4       p
\5        W4      # )z;copy_from_bbox only works when rendering to an ImageSurfacezInvalid bbox)rT  rN   r   r^   
isinstancer@   rR   RuntimeErrorr[   r\   mathceilx0floorr   r   y0
ValueErrorslicemaxr&   
frombufferget_datauint32reshapecopyrG  )rW   bboxre   swshr^  r   r`  r   slsr   s   &&         r   copy_from_bbox FigureCanvasCairo.copy_from_bbox  s_   ..##''224'5#5#566MO O !YYtwwZZ YYrGG|$ZZWW%RBHDGG);GTWW-?^,,BS!_,-uRc"'1o9M/NNg..0"))<""3((, 	C&&r   c                   V P                   P                  P                  P                  4       p\	        V\
        P                  4      '       g   \        R 4      hVP                  4        VP                  4       pVP                  4       pVP                  w  rVVP                  \        P                  ! VP                  4       \        P                   4      P#                  WC34      WV3&   VP%                  VP&                  VP&                  VP(                  VP&                  ,
          VP(                  VP&                  ,
          4       R# )z;restore_region only works when rendering to an ImageSurfaceN)rT  rN   r   r^   rZ  r@   rR   r[  flushr[   r\   rI  rJ  r&   rd  re  rf  rg  mark_dirty_rectanglestartstop)rW   regionre   rj  rk  slyslxs   &&     r   restore_region FigureCanvasCairo.restore_region  s    ..##''224'5#5#566MO O !>>)/ 
w'')299	5
'2(
CH
&$$IIsyy#((SYY"63998L	Nr   c                D    V P                  4       P                  V4       R # rn   )_get_printed_image_surfacewrite_to_png)rW   fobjs   &&r   	print_pngFigureCanvasCairo.print_png  s    '')66t<r   c           	         V P                  4       w  r#V P                  4       P                  4       pVP                  \        P
                  ! \        P                  ! V4      P                  W#^34      4      4       R# )r   N)	get_width_heightrz  re  writer   ._premultiplied_argb32_to_unmultiplied_rgba8888r&   r'   rg  )rW   r|  rO   rP   bufs   &&   r   
print_rgbaFigureCanvasCairo.print_rgba  s]    --/--/88:

5GGJJsO##UA$679 	:r   c                f   V P                   P                  V P                  n        V P                  4       w  r\        P
                  ! \        P                  W4      pV P                  P                  \        P                  ! V4      4       V P                   P                  V P                  4       V# rn   )
rS  rL   rT  r  r@   rR   rS   rk   rQ   draw)rW   rO   rP   re   s   &   r   rz  ,FigureCanvasCairo._get_printed_image_surface  st    ![[__--/$$U%8%8%H""5==#9:(r   orientationportraitc                  ^HpW@P                   n        V P                   P                  4       w  rVWT,          Wd,          rVR8X  d   YrVR8X  d:   \        \        R4      '       g   \        R4      h\        P                  ! W'V4      p	MVR8X  d:   \        \        R4      '       g   \        R4      h\        P                  ! W'V4      p	MVR9   d   \        \        R	4      '       g   \        R
4      hVR8X  dH   \        V\        4      '       d   \        P                  ! VR4      pM\        P                  ! RRVR7      p\        P                  ! W'V4      p	M\        RV: 24      hV P                   P                  V P                  n        V P                  P                  \        P                   ! V	4      4       V P                  P"                  P$                  p
VR8X  d:   V
P'                  \(        P*                  ^,          4       V
P-                  ^ V) 4       V P                   P/                  V P                  4       V
P1                  4        V	P3                  4        VR8X  d   VP5                  4        R# R# )r   	landscapeps	PSSurfacez3cairo has not been compiled with PS support enabledpdf
PDFSurfacez4cairo has not been compiled with PDF support enabledsvgz
SVGSurfacez4cairo has not been compiled with SVG support enabledwbN)fileobjzUnknown format: )svgr  )rS  rL   get_size_inchesr_   r@   r[  r  r  rZ  strgzipGzipFiler  ra  rT  rk   rQ   rN   r   r   r&   pir{   r  	show_pagefinishclose)rW   fmtr|  r  rL   w_inh_inwidth_in_pointsheight_in_pointsre   r   s   &&&$       r   _saveFigureCanvasCairo._save  s    [[002
,0J
)+%  . $;5+.." $5 6 6ood=MNGE\5,//" $5 6 6&&t>NOGO#5,//" $5 6 6f}dC((==t4D==tTBD&&t>NOG/w788![[__""5==#9:nn##+%JJruuqy!MM!../ 	(&=JJL r   r  r  r  r  rQ  N)r   r   r   r   propertyrT  rW  rm  rw  r}  r  	print_rawrz  r  	functoolspartialmethod	print_pdfprint_ps	print_svg
print_svgzr   r   rM  s   @r   rO  rO    s     % %'&N=: I1j 1f ''u5I&&ud3H''u5I((7Jr   rO  c                   6    ] tR tRt]P
                  t]t]	t
RtR# )_BackendCairoi   N)r   r   r   r   r@   versionbackend_versionrO  FigureCanvasr   FigureManagerr   r  r   r   r  r    s    mmO$L%Mr   r  )r      r   rn   )$__doc__r  r  r\  numpyr&   r@   version_infoImportError	cairocffierr r   r   r   matplotlib.backend_basesr   r   r   r   r	   matplotlib.font_managerr
   matplotlib.pathr   matplotlib.transformsr   r   r2   rG   rI   rM   rG  rO  exportr  r  r   r   <module>r     s       %J& &&+&8&8%9H I 	I ' ) (  4   *$"$(c&L c&LQC. QCh x8( x8v 
&H & &u  %%! %!$	%%%s)   +B< <C#C

C	CCC#