o
    }ôjã
  ã                   @   s0   d Z ddlmZmZmZ ddd„Zddd„ZdS )	zE
Helper module for the *bbox_inches* parameter in `.Figure.savefig`.
é    )ÚBboxÚTransformedBboxÚAffine2DNc                    sz  ˆj ‰ˆj‰ˆjj‰ g ‰g ‰tƒ ‰ˆjD ]?}| ¡ }|dur&| ||dƒ¡ ˆ |¡ |j	dd� 
¡ }| |fdd„¡ d|jv rHˆ |j¡ nˆ ˆ¡ ddd„|_q‡ ‡‡‡‡‡‡fdd	„}|du rgˆj}tƒ  |¡}|ˆj }tjd
d
g|j¢R Ž ˆ_| |j¡\}	}
ˆj j| \}}t |	 |
 ||¡ˆj_ˆj ¡  tˆj|ƒˆ_ ˆj |	| |
| ˆj j| ˆj j| ¡ |S )aO  
    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                 S   s   |S ©N© )ÚaÚrÚ_posr   r   úg/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/matplotlib/_tight_bbox.pyÚ<lambda>   ó    zadjust_bbox.<locals>.<lambda>Úapply_aspectc                 S   s   d S r   r   )Úposr   r   r   r   %   r   c                     sl   t ˆjˆˆƒD ]\} }}|  |¡ |ˆu r| `q|| _qˆˆ_ˆˆ_ˆ ˆj_ˆj ¡  ˆj	 
dddd¡ d S )Nr   é   )ÚzipÚaxesÚset_axes_locatorr   ÚbboxÚbbox_inchesÚtransFigureÚ_boxoutÚ
invalidateÚpatchÚ
set_bounds)ÚaxÚlocÚaspect©r   ÚfigZlocator_listZ
old_aspectZorigBboxZorigBboxInchesÚsentinelr   r   Úrestore_bbox'   s   

z!adjust_bbox.<locals>.restore_bboxr   r   )r   r   r   r   Úobjectr   Zget_axes_locatorr   ÚappendÚget_positionÚfrozenr   Ú__dict__Údpir   Úscaler   Úfrom_boundsÚsizeÚ	transformÚp0r   r   r   r   ÚwidthÚheight)r   r   Ú	fixed_dpir   ÚlocatorZcurrent_posr!   ÚtrZ	dpi_scaleÚx0Úy0Úw1Úh1r   r   r   Úadjust_bbox   s@   






ÿr6   c                 C   s"   |\}}|ƒ  t | ||ƒ}||fS )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.
    )r6   )r   Úbbox_inches_restorer/   r   r!   r	   r   r   r   Úprocess_figure_for_rasterizingI   s   r8   r   )Ú__doc__Úmatplotlib.transformsr   r   r   r6   r8   r   r   r   r   Ú<module>   s    
A