o
    îÇhL  ã                   @   sŒ   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ G dd„ de	ƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZeZeZdS )aâ  
A fully functional, do-nothing backend intended as a template for backend
writers.  It is fully functional in that you can select it as a backend e.g.
with ::

    import matplotlib
    matplotlib.use("template")

and your program will (should!) run without error, though no output is
produced.  This provides a starting point for backend writers; you can
selectively implement drawing methods (`~.RendererTemplate.draw_path`,
`~.RendererTemplate.draw_image`, etc.) and slowly see your figure come to life
instead having to have a full-blown implementation before getting any results.

Copy this file to a directory outside the Matplotlib source tree, somewhere
where Python can import it (by adding the directory to your ``sys.path`` or by
packaging it as a normal Python package); if the backend is importable as
``import my.backend`` you can then select it using ::

    import matplotlib
    matplotlib.use("module://my.backend")

If your backend implements support for saving figures (i.e. has a ``print_xyz`` method),
you can register it as the default handler for a given file type::

    from matplotlib.backend_bases import register_backend
    register_backend('xyz', 'my_backend', 'XYZ File Format')
    ...
    plt.savefig("figure.xyz")
é    )Ú_api)ÚGcf)ÚFigureCanvasBaseÚFigureManagerBaseÚGraphicsContextBaseÚRendererBase)ÚFigurec                       sd   e Zd ZdZ‡ fdd„Zddd„Zdd„ Zdd
d„Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Z‡  ZS )ÚRendererTemplatezò
    The renderer handles drawing/rendering operations.

    This is a minimal do-nothing class that can be used to get started when
    writing a new backend.  Refer to `.backend_bases.RendererBase` for
    documentation of the methods.
    c                    s   t ƒ  ¡  || _d S ©N)ÚsuperÚ__init__Údpi)Úselfr   ©Ú	__class__© úx/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/backends/backend_template.pyr   0   s   

zRendererTemplate.__init__Nc                 C   ó   d S r
   r   )r   ÚgcÚpathÚ	transformÚrgbFacer   r   r   Ú	draw_path4   ó   zRendererTemplate.draw_pathc                 C   r   r
   r   )r   r   ÚxÚyÚimr   r   r   Ú
draw_imageO   r   zRendererTemplate.draw_imageFc	           	      C   r   r
   r   )	r   r   r   r   ÚsÚpropÚangleÚismathÚmtextr   r   r   Ú	draw_textR   r   zRendererTemplate.draw_textc                 C   ó   dS )NTr   ©r   r   r   r   ÚflipyU   ó   zRendererTemplate.flipyc                 C   r$   )N)éd   r(   r   r%   r   r   r   Úget_canvas_width_heightY   r'   z(RendererTemplate.get_canvas_width_heightc                 C   r$   )N)é   r*   r*   r   )r   r   r   r!   r   r   r   Úget_text_width_height_descent]   r   z.RendererTemplate.get_text_width_height_descentc                 C   s   t ƒ S r
   )ÚGraphicsContextTemplater%   r   r   r   Únew_gc`   s   zRendererTemplate.new_gcc                 C   s   |S r
   r   )r   Úpointsr   r   r   Úpoints_to_pixelsd   r'   z!RendererTemplate.points_to_pixelsr
   )FN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r#   r&   r)   r+   r-   r/   Ú__classcell__r   r   r   r   r	   '   s    

r	   c                   @   ó   e Zd ZdZdS )r,   aì  
    The graphics context provides the color, line styles, etc.  See the cairo
    and postscript backends for examples of mapping the graphics context
    attributes (cap styles, join styles, line widths, colors) to a particular
    backend.  In cairo this is done by wrapping a cairo.Context object and
    forwarding the appropriate calls to it using a dictionary mapping styles
    to gdk constants.  In Postscript, all the work is done by the renderer,
    mapping line styles to postscript calls.

    If it's more appropriate to do the mapping at the renderer level (as in
    the postscript backend), you don't need to override any of the GC methods.
    If it's more appropriate to wrap an instance (as in the cairo backend) and
    do the mapping here, you'll need to override several of the setter
    methods.

    The base GraphicsContext stores colors as an RGB tuple on the unit
    interval, e.g., (0.5, 0.0, 1.0). You may need to map this to colors
    appropriate for your backend.
    N©r0   r1   r2   r3   r   r   r   r   r,   m   ó    r,   c                   @   r5   )ÚFigureManagerTemplatea"  
    Helper class for pyplot mode, wraps everything up into a neat bundle.

    For non-interactive backends, the base class is sufficient.  For
    interactive backends, see the documentation of the `.FigureManagerBase`
    class for the list of methods that can/should be overridden.
    Nr6   r   r   r   r   r8   ‹   r7   r8   c                   @   s>   e Zd ZdZeZdd„ Zi ej¥ddi¥Zdd„ Z	dd	„ Z
d
S )ÚFigureCanvasTemplatea2  
    The canvas the figure renders into.  Calls the draw and print fig
    methods, creates the renderers, etc.

    Note: GUI templates will want to connect events for button presses,
    mouse movements and key presses to functions that call the base
    class methods button_press_event, button_release_event,
    motion_notify_event, key_press_event, and key_release_event.  See the
    implementations of the interactive backends for examples.

    Attributes
    ----------
    figure : `~matplotlib.figure.Figure`
        A high-level Figure instance
    c                 C   s   t | jjƒ}| j |¡ dS )aE  
        Draw the figure using the renderer.

        It is important that this method actually walk the artist tree
        even if not output is produced because this will trigger
        deferred work (like computing limits auto-limits and tick
        values) that users may want access to before saving to disk.
        N)r	   Úfigurer   Údraw)r   Úrendererr   r   r   r;   «   s   	zFigureCanvasTemplate.drawÚfoozMy magic Foo formatc                 K   s   |   ¡  dS )a{  
        Write out format foo.

        This method is normally called via `.Figure.savefig` and
        `.FigureCanvasBase.print_figure`, which take care of setting the figure
        facecolor, edgecolor, and dpi to the desired output values, and will
        restore them to the original values.  Therefore, `print_foo` does not
        need to handle these settings.
        N)r;   )r   ÚfilenameÚkwargsr   r   r   Ú	print_foo¾   s   
zFigureCanvasTemplate.print_fooc                 C   r$   )Nr=   r   r%   r   r   r   Úget_default_filetypeÊ   r   z)FigureCanvasTemplate.get_default_filetypeN)r0   r1   r2   r3   r8   Úmanager_classr;   r   Ú	filetypesr@   rA   r   r   r   r   r9   •   s    r9   N)r3   Ú
matplotlibr   Úmatplotlib._pylab_helpersr   Úmatplotlib.backend_basesr   r   r   r   Úmatplotlib.figurer   r	   r,   r8   r9   ÚFigureCanvasÚFigureManagerr   r   r   r   Ú<module>   s    F
?