OwlCyberSecurity - MANAGER
Edit File: backend_mixed.cpython-38.pyc
U ��]� � @ s4 d dl Zd dlmZ d dlmZ G dd� de�ZdS )� N)�RendererAgg)�process_figure_for_rasterizingc @ s2 e Zd ZdZddd�Zdd� Zdd� Zd d � ZdS )�MixedModeRenderera& 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 C sV |dkrt }|| _|| _|| _|| _|| _d| _d| _|| _|� � | _ || _|| _dS )a+ Parameters ---------- figure : `matplotlib.figure.Figure` The figure instance. width : scalar The width of the canvas in logical units height : scalar The height of the canvas in logical units dpi : scalar 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.) Nr ) r �_raster_renderer_class�_width�_height�dpi�_vector_renderer�_raster_renderer�_rasterizing�figureZget_dpi�_figdpi�_bbox_inches_restore� _renderer)�selfr �width�heightr Zvector_rendererZraster_renderer_classZbbox_inches_restore� r �C/usr/lib/python3/dist-packages/matplotlib/backends/backend_mixed.py�__init__ s zMixedModeRenderer.__init__c C s t | j|�S )N)�getattrr )r �attrr r r �__getattr__C s zMixedModeRenderer.__getattr__c C sn | j �| j� | jr(t| j | j�}|| _| jdkr\| �| j| j | j| j | j�| _ | j | _ | jd7 _dS )a Enter "raster" mode. All subsequent drawing commands (until stop_rasterizing is called) will be drawn with the raster backend. If start_rasterizing is called multiple times before stop_rasterizing is called, this method has no effect. r � N)r �set_dpir r r r r r r r r )r �rr r r �start_rasterizingL s � �z#MixedModeRenderer.start_rasterizingc C s� | j d8 _ | j dkr�| j| _| j| j }| j�� \}}|\}}}}|dkr�|dkr�tj|tj d�}|� ||df�}|ddd� }| j�� } | j�| || j | j || | | j | j |� d| _d| _ | j�| j � | jr�t| j| j| j �} | | _dS )a9 Exit "raster" mode. All of the drawing that was done since the last start_rasterizing command will be copied to the vector backend by calling draw_image. If stop_rasterizing is called multiple times before start_rasterizing is called, this method has no effect. r r )Zdtype� N���F)r r r r r r Ztostring_rgba_minimized�npZ frombufferZuint8ZreshapeZnew_gcZ draw_imager r r r r )r r �bufferZbounds�l�b�w�hZimage�gcr r r r �stop_rasterizingd s4 ��z"MixedModeRenderer.stop_rasterizing)NN)�__name__� __module__�__qualname__�__doc__r r r r&