
    h
                     0    S r SSKJrJrJr  SS jrSS jrg)zE
Helper module for the *bbox_inches* parameter in `.Figure.savefig`.
    )BboxTransformedBboxAffine2DNc                   ^ ^^^^^^ T R                   mT R                  mT R                  R                  m/ m/ m[	        5       mT R
                   H  nUR                  5       nUb  UR                  U" US5      5        TR                  U5        UR                  SS9R                  5       nUR                  U4S j5        SUR                  ;   a  TR                  UR                  5        OTR                  T5        S	S jUl        M     UU UUUUU4S jnUc  T R                  n[        5       R                  U5      nUT R                  -  n[         R"                  " SS/UR$                  Q76 T l        UR'                  UR(                  5      u  pT R                   R$                  U-  u  p[         R"                  " U	* U
* X5      T R                  l        T R                  R+                  5         [-        T R                  U5      T l         T R.                  R1                  X-  X-  T R                   R2                  U-  T R                   R4                  U-  5        U$ )
a3  
Temporarily adjust the figure so that only the specified area
(bbox_inches) is saved.

It modifies fig.bbox, fig.bbox_inches,
fig.transFigure._boxout, and fig.patch.  While the figure size
changes, the scale of the original figure is conserved.  A
function which restores the original values are returned.
NF)originalc                     U$ N )ar_poss      H/var/www/html/env/lib/python3.13/site-packages/matplotlib/_tight_bbox.py<lambda>adjust_bbox.<locals>.<lambda>   s    4    apply_aspectc                     g r	   r
   )poss    r   r   r   %   s    4r   c                  6  > [        TR                  TT5       H&  u  pnU R                  U5        UT	L a  U ?M   X l        M(     TTl        TTl        TTR                  l        TR                  R                  5         TR                  R                  SSSS5        g )Nr      )zipaxesset_axes_locatorr   bboxbbox_inchestransFigure_boxout
invalidatepatch
set_bounds)
axlocaspectr   figlocator_list
old_aspectorigBboxorigBboxInchessentinels
      r   restore_bbox!adjust_bbox.<locals>.restore_bbox'   s    "388\:FOBV$!O"(  G (")""$		Q1a(r   r   r	   )r   r   r   r   objectr   get_axes_locatorr   appendget_positionfrozenr   __dict__dpir   scaler   from_boundssize	transformp0r   r   r   r    widthheight)r$   r   	fixed_dpir!   locatorcurrent_posr*   tr	dpi_scalex0y0w1h1r   r%   r&   r'   r(   r)   s   `            @@@@@@r   adjust_bboxrC      s    xxH__Noo%%GJLxHhh%%'OOGB-.G$oouo5<<>
k?@R[[(boo.h'/ ) ) GG				)	$BCGG#I&&q!?k.>.>?CO\\+..)FBXX]]Y&FB"..sRC@COOOO s3CHII"'",chhoo.BD r   c                 6    Uu  p4U" 5         [        XU5      nX54$ )z
A function that needs to be called when figure dpi changes during the
drawing (e.g., rasterizing).  It recovers the bbox and re-adjust it with
the new dpi.
)rC   )r$   bbox_inches_restorer:   r   r*   r   s         r   process_figure_for_rasterizingrF   I   s%     !4KNCi0A>r   r	   )__doc__matplotlib.transformsr   r   r   rC   rF   r
   r   r   <module>rI      s    B A>Br   