
    hX                     D    S SK rS SKJr  SSKJr  S SKJr   " S S5      rg)    N)cbook   )RendererAgg)process_figure_for_rasterizingc                   8    \ rS rSrSr  S	S jrS rS rS rSr	g)
MixedModeRenderer   a  
A helper class to implement a renderer that switches between
vector and raster drawing.  An example may be a PDF writer, where
most things are drawn with PDF vector commands, but some very
complex objects, such as quad meshes, are rasterised and then
output as images.
Nc                     Uc  [         nX`l        X l        X0l        X@l        XPl        SU l        Xl        UR                  U l        Xpl	        XPl
        g)a  
Parameters
----------
figure : `~matplotlib.figure.Figure`
    The figure instance.
width : float
    The width of the canvas in logical units
height : float
    The height of the canvas in logical units
dpi : float
    The dpi of the canvas
vector_renderer : `~matplotlib.backend_bases.RendererBase`
    An instance of a subclass of
    `~matplotlib.backend_bases.RendererBase` that will be used for the
    vector drawing.
raster_renderer_class : `~matplotlib.backend_bases.RendererBase`
    The renderer class to use for the raster drawing.  If not provided,
    this will use the Agg backend (which is currently the only viable
    option anyway.)

N)r   _raster_renderer_class_width_heightdpi_vector_renderer_raster_rendererfigure_figdpi_bbox_inches_restore	_renderer)selfr   widthheightr   vector_rendererraster_renderer_classbbox_inches_restores           S/var/www/html/env/lib/python3.13/site-packages/matplotlib/backends/backend_mixed.py__init__MixedModeRenderer.__init__   sP    0 !($/!&;# / $
 zz$7!(    c                 .    [        U R                  U5      $ )N)getattrr   )r   attrs     r   __getattr__MixedModeRenderer.__getattr__>   s     t~~t,,r   c                 j   U R                   U R                  l         U R                  (       a&  [        U R                  U R                  5      nXl        U R	                  U R
                  U R                   -  U R                  U R                   -  U R                   5      U l        U R                  U l        g)z
Enter "raster" mode.  All subsequent drawing commands (until
`stop_rasterizing` is called) will be drawn with the raster backend.
N)	r   r   r   r   r   r   r   r   r   )r   rs     r   start_rasterizing#MixedModeRenderer.start_rasterizingG   s     (($$.t{{/3/H/HJA()% $ ; ;KK $,,txx"7!C..r   c           	         U R                   U l        U R                  U R                  -  n[        R
                  " U R                  R                  5       5      n[        R                  " US   5      u  p4X#U4   nUR                  (       a  U R                  R                  5       nU R                  R                  UUR                  U R                  -  U R                  -  XR                  -
  U R                  -  U R                  -  USSS2   5        SU l        U R                  U R                   l        U R"                  (       a2  [%        U R                   U R"                  U R                  5      nXpl        gg)z
Exit "raster" mode.  All of the drawing that was done since
the last `start_rasterizing` call will be copied to the
vector backend by calling draw_image.
).   N)r   r   r   r   npasarrayr   buffer_rgbar   _get_nonzero_slicessizenew_gc
draw_imagestartr   stopr   r   r   )r   r   imgslice_yslice_xcropped_imggcr%   s           r   stop_rasterizing"MixedModeRenderer.stop_rasterizingW   s(    ..(jj..::<= 44S[A7*+&&(B NN%%,txx7,,&$,,6ADbD!	#
 !% ,,$$.t{{/3/H/H/3||=A )*%	 %r   )
r   r   r   r   r   r   r   r   r   r   )NN)
__name__
__module____qualname____firstlineno____doc__r   r"   r&   r9   __static_attributes__ r   r   r   r      s$     (,%),)\-/  *r   r   )	numpyr+   
matplotlibr   backend_aggr   matplotlib._tight_bboxr   r   rA   r   r   <module>rF      s      $ Ao* o*r   