Ë
    ¨ehš ã                   ó´  — d dl Z d dlZd dlZd dlmZmZ d dlZd dlZd dlm	Z	 d dl
Z
d dlZd dlZd dlmZ d dlZd dlZd dlZd dlmZ d dlZd dlmZmZmZmZ d dlmZmZ d dlmZ   ejB                  e"«      Z#ejH                  dk(  rejJ                  nd Z&d	„ Z' G d
„ d«      Z( e(«       Z) G d„ de jT                  «      Z+ G d„ de+«      Z, G d„ de,«      Z-e)j]                  d«       G d„ de+«      «       Z/ G d„ d«      Z0e)j]                  d«       G d„ de0e,«      «       Z1e)j]                  d«       G d„ de0e-«      «       Z2 G d„ d«      Z3e)j]                  d«       G d „ d!e3e,«      «       Z4e)j]                  d"«       G d#„ d$e3e-«      «       Z5d%„ Z6d&„ Z7e)j]                  d'«       G d(„ d)e-«      «       Z8 G d*„ d+«      Z9 G d,„ d-e9«      Z: G d.„ d/e:«      Z; G d0„ d1e:«      Z<d2„ Z=y)3é    N)ÚBytesIOÚTextIOWrapper)ÚPath)ÚTemporaryDirectory)ÚImage)ÚDISPLAY_TEMPLATEÚINCLUDED_FRAMESÚ
JS_INCLUDEÚSTYLE_INCLUDE)Ú_apiÚcbookÚwin32c                 óŒ   — d„ }t        | |z  |z  «      |z  |z  }t        ||z  |z  «      |z  |z  } ||||«       ||||«      fS )a,  
    Compute figure size so that pixels are a multiple of n.

    Parameters
    ----------
    w, h : float
        Size in inches.

    dpi : float
        The dpi.

    n : int
        The target multiple.

    Returns
    -------
    wnew, hnew : float
        The new figure size in inches.
    c                 óž  — t        | |z  «      |z  dk7  r¸t        t        j                  | t        j                  «      |z  «      |z  dk(  r&t        j                  | t        j                  «      } | S t        t        j                  | t        j                   «      |z  «      |z  dk(  r%t        j                  | t        j                   «      } | S )Nr   )ÚintÚnpÚ	nextafterÚinf)ÚxÚdpiÚns      úR/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/matplotlib/animation.pyÚcorrect_roundoffz*adjusted_figsize.<locals>.correct_roundoff7   sœ   € Üˆq�‰u‹:˜‰>˜QÒÜ”2—<‘< ¤2§6¡6Ó*¨3Ñ.Ó/°!Ñ3°qÒ8Ü—L‘L ¤B§F¡FÓ+�ð ˆô ”R—\‘\ !¤b§f¡f WÓ-¨cÑ1Ó2°QÑ6¸!Ò;Ü—L‘L ¤R§V¡V GÓ,�Øˆó    )r   )ÚwÚhr   r   r   ÚwnewÚhnews          r   Úadjusted_figsizer       s_   € ò.ô ˆq�3‰w˜‰{Ó˜aÑ #Ñ%€DÜˆq�3‰w˜‰{Ó˜aÑ #Ñ%€DÙ˜D # qÓ)Ñ+;¸DÀ#ÀqÓ+IÐIÐIr   c                   ó4   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚMovieWriterRegistryz<Registry of available writer classes by human readable name.c                 ó"   — t        «       | _        y ©N)ÚdictÚ_registered©Úselfs    r   Ú__init__zMovieWriterRegistry.__init__G   s   € Ü›6ˆÕr   c                 ó   ‡ ‡— ˆˆ fd„}|S )zª
        Decorator for registering a class under a name.

        Example use::

            @registry.register(name)
            class Foo:
                pass
        c                 ó&   •— | ‰j                   ‰<   | S r#   )r%   )Ú
writer_clsÚnamer'   s    €€r   Úwrapperz-MovieWriterRegistry.register.<locals>.wrapperT   s   ø€ Ø%/ˆD×Ñ˜TÑ"ØÐr   © )r'   r,   r-   s   `` r   ÚregisterzMovieWriterRegistry.registerJ   s   ù€ õ	ð ˆr   c                 ó`   — 	 | j                   |   }|j                  «       S # t        $ r Y yw xY w)z¥
        Check if given writer is available by name.

        Parameters
        ----------
        name : str

        Returns
        -------
        bool
        F)r%   ÚKeyErrorÚisAvailable)r'   r,   Úclss      r   Úis_availablez MovieWriterRegistry.is_availableY   s:   € ð	Ø×"Ñ" 4Ñ(ˆCð �‰Ó Ð øô ò 	Ùð	ús   ‚! ¡	-¬-c              #   óZ   K  — | j                   D ]  }| j                  |«      sŒ|–— Œ y­w)z-Iterate over names of available writer class.N)r%   r4   ©r'   r,   s     r   Ú__iter__zMovieWriterRegistry.__iter__k   s.   è ø€ à×$Ñ$ò 	ˆDØ× Ñ  Õ&Ø“
ñ	ùs   ‚!+¤+c                 ó
   — g | ¢S )z%Get a list of available MovieWriters.r.   r&   s    r   ÚlistzMovieWriterRegistry.listq   s   € à�ˆwˆr   c                 ó`   — | j                  |«      r| j                  |   S t        d|› d�«      ‚)z,Get an available writer class from its name.zRequested MovieWriter (z) not available)r4   r%   ÚRuntimeErrorr6   s     r   Ú__getitem__zMovieWriterRegistry.__getitem__u   s6   € à×Ñ˜TÔ"Ø×#Ñ# DÑ)Ð)ÜÐ4°T°F¸/ÐJÓKÐKr   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r(   r/   r4   r7   r9   r<   r.   r   r   r!   r!   D   s$   „ ÙFò"òò!ò$òóLr   r!   c                   óÀ   — e Zd ZdZd
d„Zej                  dd„«       Zed„ «       Z	d„ Z
ej                  d„ «       Zej                  d„ «       Zej                  d	„ «       Zy)ÚAbstractMovieWriteraœ  
    Abstract base class for writing movies, providing a way to grab frames by
    calling `~AbstractMovieWriter.grab_frame`.

    `setup` is called to start the process and `finish` is called afterwards.
    `saving` is provided as a context manager to facilitate this process as ::

        with moviewriter.saving(fig, outfile='myfile.mp4', dpi=100):
            # Iterate over frames
            moviewriter.grab_frame(**savefig_kwargs)

    The use of the context manager ensures that `setup` and `finish` are
    performed as necessary.

    An instance of a concrete subclass of this class can be given as the
    ``writer`` argument of `Animation.save()`.
    Nc                 ó”   — || _         |�|ni | _        t        j                  |d«      | _        t        j                  |d«      | _        y )Nzanimation.codecúanimation.bitrate)ÚfpsÚmetadataÚmplÚ
_val_or_rcÚcodecÚbitrate)r'   rE   rF   rI   rJ   s        r   r(   zAbstractMovieWriter.__init__’   s=   € ØˆŒØ$,Ð$8™¸bˆŒÜ—^‘^ EÐ+<Ó=ˆŒ
Ü—~‘~ gÐ/BÓCˆ�r   c                 ó¨   — t        |«      j                  j                  d¬«       || _        || _        |€| j                  j
                  }|| _        y)a¿  
        Setup for writing the movie file.

        Parameters
        ----------
        fig : `~matplotlib.figure.Figure`
            The figure object that contains the information for frames.
        outfile : str
            The filename of the resulting movie file.
        dpi : float, default: ``fig.dpi``
            The DPI (or resolution) for the file.  This controls the size
            in pixels of the resulting movie file.
        T©ÚstrictN)r   ÚparentÚresolveÚoutfileÚfigr   )r'   rQ   rP   r   s       r   ÚsetupzAbstractMovieWriter.setup˜   sF   € ô  	ˆW‹×Ñ×$Ñ$¨DÐ$Ô1ØˆŒØˆŒØˆ;Ø—(‘(—,‘,ˆCØˆ�r   c                 óœ   — | j                   j                  «       \  }}t        || j                  z  «      t        || j                  z  «      fS )z7A tuple ``(width, height)`` in pixels of a movie frame.)rQ   Úget_size_inchesr   r   )r'   r   r   s      r   Ú
frame_sizezAbstractMovieWriter.frame_size¯   s?   € ð �x‰x×'Ñ'Ó)‰ˆˆ1Ü�1�t—x‘x‘<Ó ¤# a¨$¯(©(¡lÓ"3Ð3Ð3r   c                  ó   — y)z’
        Whether this writer supports transparency.

        Writers may consult output file type and codec to determine this at runtime.
        Fr.   r&   s    r   Ú_supports_transparencyz*AbstractMovieWriter._supports_transparencyµ   s   € ð r   c                  ó   — y)a=  
        Grab the image information from the figure and save as a movie frame.

        All keyword arguments in *savefig_kwargs* are passed on to the
        `~.Figure.savefig` call that saves the figure.  However, several
        keyword arguments that are supported by `~.Figure.savefig` may not be
        passed as they are controlled by the MovieWriter:

        - *dpi*, *bbox_inches*:  These may not be passed because each frame of the
           animation much be exactly the same size in pixels.
        - *format*: This is controlled by the MovieWriter.
        Nr.   ©r'   Úsavefig_kwargss     r   Ú
grab_framezAbstractMovieWriter.grab_frame½   ó   � r   c                  ó   — y)ú,Finish any processing for writing the movie.Nr.   r&   s    r   ÚfinishzAbstractMovieWriter.finishÌ   r\   r   c              /   ó@  K  — t         j                  d   dk(  rt        j                  d«        | j                  |||g|¢­i |¤Ž t        j
                  ddi«      5  	 | –— | j                  «        	 ddd«       y# | j                  «        w xY w# 1 sw Y   yxY w­w)z•
        Context manager to facilitate writing the movie file.

        ``*args, **kw`` are any parameters that should be passed to `setup`.
        úsavefig.bboxÚtightzkDisabling savefig.bbox = 'tight', as it may cause frame size to vary, which is inappropriate for animation.N)rG   ÚrcParamsÚ_logÚinforR   Ú
rc_contextr_   )r'   rQ   rP   r   ÚargsÚkwargss         r   ÚsavingzAbstractMovieWriter.savingÐ   s’   è ø€ ô �<‰<˜Ñ'¨7Ò2Ü�I‰Ið #ô $ð
 	ˆ�
‰
�3˜ Ð6 tÒ6¨vÒ6Ü�^‰^˜^¨TÐ2Ó3ñ 	ðØ’
à—‘•÷		ð 	øð —‘•ú÷		ð 	üs6   ‚ABÁBÁA=Á#BÁ4	BÁ=BÂBÂBÂB)é   NNNr#   )r=   r>   r?   r@   r(   ÚabcÚabstractmethodrR   ÚpropertyrU   rW   r[   r_   Ú
contextlibÚcontextmanagerri   r.   r   r   rB   rB      sŽ   „ ñó$Dð 	×Ñòó ðð, ñ4ó ð4ò
ð 	×Ññó ðð 	×Ññ;ó ð;ð ×Ññó ñr   rB   c                   óx   ‡ — e Zd ZdZdgZ	 	 dˆ fd„	Zd„ Zdˆ fd„	Zd„ Zd„ Z	d„ Z
d	„ Zed
„ «       Zed„ «       Zˆ xZS )ÚMovieWriteraß  
    Base class for writing movies.

    This is a base class for MovieWriter subclasses that write a movie frame
    data to a pipe. You cannot instantiate this class directly.
    See examples for how to use its subclasses.

    Attributes
    ----------
    frame_format : str
        The format used in writing frame data, defaults to 'rgba'.
    fig : `~matplotlib.figure.Figure`
        The figure to capture data from.
        This must be provided by the subclasses.
    Úrgbac                 óš   •— t        | «      t        u rt        d«      ‚t        ‰| �  ||||¬«       | j
                  d   | _        || _        y)a@  
        Parameters
        ----------
        fps : int, default: 5
            Movie frame rate (per second).
        codec : str or None, default: :rc:`animation.codec`
            The codec to use.
        bitrate : int, default: :rc:`animation.bitrate`
            The bitrate of the movie, in kilobits per second.  Higher values
            means higher quality movies, but increase the file size.  A value
            of -1 lets the underlying movie encoder select the bitrate.
        extra_args : list of str or None, optional
            Extra command-line arguments passed to the underlying movie encoder. These
            arguments are passed last to the encoder, just before the filename. The
            default, None, means to use :rc:`animation.[name-of-encoder]_args` for the
            builtin writers.
        metadata : dict[str, str], default: {}
            A dictionary of keys and values for metadata to include in the
            output file. Some keys that may be of use include:
            title, artist, genre, subject, copyright, srcform, comment.
        zNMovieWriter cannot be instantiated directly. Please use one of its subclasses.)rE   rF   rI   rJ   r   N)Útyperq   Ú	TypeErrorÚsuperr(   Úsupported_formatsÚframe_formatÚ
extra_args)r'   rE   rI   rJ   ry   rF   Ú	__class__s         €r   r(   zMovieWriter.__init__   s\   ø€ ô. �‹:œÑ$ô
 ð%ó&ð &ô 	‰Ñ˜S¨8¸5Ø!(ð 	ô 	*à ×2Ñ2°1Ñ5ˆÔØ$ˆ�r   c                 ó”  — | j                   dk(  ry| j                  j                  «       \  }}t        ||| j                  d«      \  }}||f||fk7  rU| j                  j                  ||d¬«       t        j                  d||||«       n| j                  j                  «       \  }}t        j                  dg| j                  ¢­Ž  ||fS )NÚh264é   T)Úforwardz?figure size in inches has been adjusted from %s x %s to %s x %szframe size in pixels is %s x %s)
rI   rQ   rT   r   r   Úset_size_inchesrd   re   ÚdebugrU   )r'   ÚwoÚhor   r   s        r   Ú_adjust_frame_sizezMovieWriter._adjust_frame_size%  s·   € Ø�:‰:˜ÒØ—X‘X×-Ñ-Ó/‰FˆB�Ü# B¨¨D¯H©H°aÓ8‰DˆAˆqØ�Bˆx˜A˜q˜6Ò!Ø—‘×(Ñ(¨¨A°tÐ(Ô<Ü—	‘	ð 4Ø57¸¸QÀõCð —8‘8×+Ñ+Ó-‰DˆAˆqÜ�
‰
Ð4ÐG°t·±ÓGØ�!ˆtˆr   c                 ó„   •— t         ‰| �  |||¬«       | j                  «       \  | _        | _        | j                  «        y ©N)r   )rv   rR   rƒ   Ú_wÚ_hÚ_run©r'   rQ   rP   r   rz   s       €r   rR   zMovieWriter.setup2  s7   ø€ ä‰‰�c˜7¨ˆÔ,Ø×2Ñ2Ó4ÑˆŒ�”ð 	�	‰	�r   c                 óÜ   — | j                  «       }t        j                  dt        j                  |«      «       t
        j                  }t        j                  ||||t        ¬«      | _	        y )Nz%MovieWriter._run: running command: %s)ÚstdinÚstdoutÚstderrÚcreationflags)
Ú_argsrd   re   r   Ú_pformat_subprocessÚ
subprocessÚPIPEÚPopenÚsubprocess_creation_flagsÚ_proc)r'   Úcommandr’   s      r   rˆ   zMovieWriter._run:  sS   € ð —*‘*“,ˆÜ�	‰	Ð9Ü×+Ñ+¨GÓ4ô	6ä�‰ˆÜ×%Ñ%Ø˜4¨°TÜ3ô5ˆ�
r   c                 ó¦  — | j                   j                  «       \  }}t        t        |«      «      j	                  «       }t        t        |«      «      j	                  «       }|rKt
        j                  | j                   j                  rt        j                  nt        j                  d|«       |rKt
        j                  | j                   j                  rt        j                  nt        j                  d|«       | j                   j                  r@t        j                  | j                   j                  | j                   j                  ||«      ‚y)r^   zMovieWriter stdout:
%szMovieWriter stderr:
%sN)r•   Úcommunicater   r   Úreadrd   ÚlogÚ
returncodeÚloggingÚWARNINGÚDEBUGr‘   ÚCalledProcessErrorrg   )r'   ÚoutÚerrs      r   r_   zMovieWriter.finishF  sæ   € à—:‘:×)Ñ)Ó+‰ˆˆSäœG C›LÓ)×.Ñ.Ó0ˆÜœG C›LÓ)×.Ñ.Ó0ˆÙÜ�H‰HØ#'§:¡:×#8Ò#8”—’¼g¿m¹mØ)¨3ô0ñ Ü�H‰HØ#'§:¡:×#8Ò#8”—’¼g¿m¹mØ)¨3ô0ð �:‰:× Ò Ü×/Ñ/Ø—
‘
×%Ñ% t§z¡z§¡¸¸SóBð Bð !r   c                 ó4  — t        |«       t        j                  d«       | j                  j	                  | j
                  | j                  «        | j                  j                  | j                  j                  f| j                  | j                  dœ|¤Ž y )Nz'MovieWriter.grab_frame: Grabbing frame.©Úformatr   )Ú_validate_grabframe_kwargsrd   r€   rQ   r   r†   r‡   Úsavefigr•   r‹   rx   r   rY   s     r   r[   zMovieWriter.grab_frameX  sq   € ä" >Ô2Ü�
‰
Ð<Ô=ð 	�‰× Ñ  §¡¨$¯'©'Ô2àˆ�‰×Ñ˜Ÿ™×)Ñ)ð 	9°$×2CÑ2CØ!ŸX™Xñ	9Ø)7ó	9r   c                 ó   — t        d«      S )z9Assemble list of encoder-specific command-line arguments.z)args needs to be implemented by subclass.©ÚNotImplementedErrorr&   s    r   r�   zMovieWriter._argsc  s   € ä"Ð#NÓOÐOr   c                 óN   — t        t        j                  | j                     «      S )zâ
        Return the binary path to the commandline tool used by a specific
        subclass. This is a class method so that the tool can be looked for
        before making a particular MovieWriter subclass available.
        )ÚstrrG   rc   Ú	_exec_key©r3   s    r   Úbin_pathzMovieWriter.bin_pathg  s   € ô ”3—<‘< §¡Ñ.Ó/Ð/r   c                 óL   — t        j                  | j                  «       «      duS )z<Return whether a MovieWriter subclass is actually available.N)ÚshutilÚwhichr®   r­   s    r   r2   zMovieWriter.isAvailablep  s   € ô �|‰|˜CŸL™L›NÓ+°4Ð7Ð7r   )rj   NNNNr#   )r=   r>   r?   r@   rw   r(   rƒ   rR   rˆ   r_   r[   r�   Úclassmethodr®   r2   Ú__classcell__©rz   s   @r   rq   rq   å   sf   ø„ ñð0  ˜ÐàCGØõ#%òJõò
5òBò$	9òPð ñ0ó ð0ð ñ8ó ô8r   rq   c                   óz   ‡ — e Zd ZdZˆ fd„Zd
d„Zd„ Zed„ «       Zej                  d„ «       Zd„ Z
d„ Zˆ fd	„Zˆ xZS )ÚFileMovieWriterz}
    `MovieWriter` for writing to individual files and stitching at the end.

    This must be sub-classed to be useful.
    c                 óT   •— t        ‰| �  |i |¤Ž t        j                  d   | _        y )Nzanimation.frame_format)rv   r(   rG   rc   rx   )r'   rg   rh   rz   s      €r   r(   zFileMovieWriter.__init__|  s'   ø€ Ü‰Ñ˜$Ð) &Ò)ÜŸL™LÐ)AÑBˆÕr   c                 óž  — t        |«      j                  j                  d¬«       || _        || _        |€| j                  j
                  }|| _        | j                  «        |€>t        «       | _        t        t        | j                  j                  d«      «      | _        nd| _        || _        d| _        t        «       | _        d| _        y)aÓ  
        Setup for writing the movie file.

        Parameters
        ----------
        fig : `~matplotlib.figure.Figure`
            The figure to grab the rendered frames from.
        outfile : str
            The filename of the resulting movie file.
        dpi : float, default: ``fig.dpi``
            The dpi of the output file. This, with the figure size,
            controls the size in pixels of the resulting movie file.
        frame_prefix : str, optional
            The filename prefix to use for temporary files.  If *None* (the
            default), files are written to a temporary directory which is
            deleted by `finish`; if not *None*, no temporary files are
            deleted.
        TrL   NÚtmpr   z
%s%%07d.%s)r   rN   rO   rQ   rP   r   rƒ   r   Ú_tmpdirr«   r,   Útemp_prefixÚ_frame_counterr9   Ú_temp_pathsÚfname_format_str)r'   rQ   rP   r   Úframe_prefixs        r   rR   zFileMovieWriter.setup€  s©   € ô( 	ˆW‹×Ñ×$Ñ$¨DÐ$Ô1ØˆŒØˆŒØˆ;Ø—(‘(—,‘,ˆCØˆŒØ×ÑÔ!àÐÜ-Ó/ˆDŒLÜ"¤4¨¯©×(9Ñ(9¸5Ó#AÓBˆDÕàˆDŒLØ+ˆDÔØˆÔÜ›6ˆÔØ ,ˆÕr   c                 ól   — t        | d«      r(| j                  r| j                  j                  «        y y y )Nrº   )Úhasattrrº   Úcleanupr&   s    r   Ú__del__zFileMovieWriter.__del__¦  s*   € Ü�4˜Ô#¨¯ªØ�L‰L× Ñ Õ"ð )5Ð#r   c                 ó   — | j                   S )zƒ
        Format (png, jpeg, etc.) to use for saving the frames, which can be
        decided by the individual subclasses.
        )Ú_frame_formatr&   s    r   rx   zFileMovieWriter.frame_formatª  s   € ð ×!Ñ!Ð!r   c           	      óÖ   — || j                   v r|| _        y t        j                  d|›dt	        | «      j
                  › d| j                   d   › d�«       | j                   d   | _        y )NzIgnoring file format z which is not supported by z; using r   z	 instead.)rw   rÅ   r   Úwarn_externalrt   r=   )r'   rx   s     r   rx   zFileMovieWriter.frame_format²  sr   € à˜4×1Ñ1Ñ1Ø!-ˆDÕä×ÑØ'¨Ð'7ð 8 Ü $ T£
× 3Ñ 3Ð4°HØ×)Ñ)¨!Ñ,Ð-¨Yð8ô9ð "&×!7Ñ!7¸Ñ!:ˆDÕr   c                 óL   — | j                   | j                  | j                  fz  S r#   )r¾   r»   rx   r&   s    r   Ú_base_temp_namezFileMovieWriter._base_temp_name½  s&   € ð ×$Ñ$¨×(8Ñ(8¸$×:KÑ:KÐ'LÑLÐLr   c                 ó²  — t        |«       t        | j                  «       | j                  z  «      }| j                  j                  |«       | xj                  dz  c_        t        j                  d| j                  |«       t        |d«      5 } | j                  j                  |f| j                  | j                  dœ|¤Ž d d d «       y # 1 sw Y   y xY w)Né   z8FileMovieWriter.grab_frame: Grabbing frame %d to path=%sÚwbr£   )r¥   r   rÉ   r¼   r½   Úappendrd   r€   ÚopenrQ   r¦   rx   r   )r'   rZ   ÚpathÚsinks       r   r[   zFileMovieWriter.grab_frameÂ  s»   € ô 	# >Ô2Ü�D×(Ñ(Ó*¨T×-@Ñ-@Ñ@ÓAˆØ×Ñ×Ñ Ô%Ø×Ò˜qÑ ÕÜ�
‰
ÐMØ×&Ñ&¨ô	.ä�$˜Óð 	/ ØˆD�H‰H×Ñ˜Tð /¨$×*;Ñ*;ÀÇÁñ /Ø-ò/÷	/÷ 	/ñ 	/ús   Â5CÃCc                 ój  •— 	 | j                  «        t        ‰| �	  «        | j                  r;t        j                  d| j                  «       | j                  j                  «        y y # | j                  r;t        j                  d| j                  «       | j                  j                  «        w w xY w)Nú'MovieWriter: clearing temporary path=%s)rˆ   rv   r_   rº   rd   r€   rÂ   )r'   rz   s    €r   r_   zFileMovieWriter.finishÏ  s‚   ø€ ð	'Ø�I‰IŒKÜ‰G‰NÔà�|Š|Ü—
‘
Ø=¸t¿|¹|ôð —‘×$Ñ$Õ&ð	 øˆt�|Š|Ü—
‘
Ø=¸t¿|¹|ôð —‘×$Ñ$Õ&ð	 ús   ƒA) Á)A	B2©NN)r=   r>   r?   r@   r(   rR   rÃ   rm   rx   ÚsetterrÉ   r[   r_   r³   r´   s   @r   r¶   r¶   v  s\   ø„ ñô
Có$-òL#ð ñ"ó ð"ð ×Ññ;ó ð;òMò
/÷'ð 'r   r¶   Úpillowc                   óB   ‡ — e Zd Zd„ Zed„ «       Zdˆ fd„	Zd„ Zd„ Zˆ xZ	S )ÚPillowWriterc                  ó   — y©NTr.   r&   s    r   rW   z#PillowWriter._supports_transparencyß  s   € Ør   c                  ó   — yrÙ   r.   r­   s    r   r2   zPillowWriter.isAvailableâ  ó   € àr   c                 ó8   •— t         ‰| �  |||¬«       g | _        y r…   )rv   rR   Ú_framesr‰   s       €r   rR   zPillowWriter.setupæ  s   ø€ Ü‰‰�c˜7¨ˆÔ,Øˆ�r   c           	      ó®  — t        |«       t        «       } | j                  j                  |fi i |¥d| j                  dœ¥¤Ž t        j                  d| j                  |j                  «       dddd«      }|j                  «       d   d   dk  r| j                  j                  |«       y | j                  j                  |j                  d	«      «       y )
Nrr   r£   ÚRGBAÚrawr   rË   é   éÿ   ÚRGB)r¥   r   rQ   r¦   r   r   Ú
frombufferrU   Ú	getbufferÚ
getextremarÝ   rÍ   Úconvert)r'   rZ   ÚbufÚims       r   r[   zPillowWriter.grab_frameê  s³   € Ü" >Ô2Ü‹iˆØˆ�‰×ÑØñ	JØH�nÐH°¸t¿x¹xÒHò	Jä×ÑØ�D—O‘O S§]¡]£_°e¸VÀQÈóKˆà�=‰=‹?˜1Ñ˜aÑ  3Ò&à�L‰L×Ñ Õ#ð �L‰L×Ñ §
¡
¨5Ó 1Õ2r   c           	      ó¤   — | j                   d   j                  | j                  d| j                   dd  t        d| j                  z  «      d¬«       y )Nr   TrË   éè  )Úsave_allÚappend_imagesÚdurationÚloop)rÝ   ÚsaverP   r   rE   r&   s    r   r_   zPillowWriter.finishù  sE   € Ø�‰�Q‰×ÑØ�L‰L 4°t·|±|ÀAÀBÐ7GÜ˜ §¡™Ó)°ð 	õ 	3r   r#   )
r=   r>   r?   rW   r²   r2   rR   r[   r_   r³   r´   s   @r   r×   r×   Ý  s+   ø„ òð ñó ðõò3ö3r   r×   c                   ó.   — e Zd ZdZdZdZd„ Zed„ «       Zy)Ú
FFMpegBasez†
    Mixin class for FFMpeg output.

    This is a base class for the concrete `FFMpegWriter` and `FFMpegFileWriter`
    classes.
    zanimation.ffmpeg_pathzanimation.ffmpeg_argsc                 óf   — t        | j                  «      j                  }|dv ry| j                  dv S )N¾   ú.gifú.apngú.avifú.webmú.webpT>   ÚbmpÚdpxÚgifÚpngÚapngÚavrpÚcfhdÚffv1ÚtiffÚv408ÚljpegÚqtrleÚtargaÚproresÚffvhuffÚhuffyuvÚutvideoÚjpeg2000ÚrawvideoÚ	prores_awÚ	prores_ks)r   rP   ÚsuffixrI   ©r'   r  s     r   rW   z!FFMpegBase._supports_transparency  s:   € Ü�d—l‘lÓ#×*Ñ*ˆØÐAÑAØð �z‰zð >ð >ð 	>r   c                 ó  — g }t        | j                  «      j                  }|dv r|dd  | _        n|j	                  d| j                  g«       | j
                  �| j
                  nt        j                  | j                     }| j                  dk(  rd|vr|j	                  ddg«       nM| j                  dk(  rd|vr|j	                  dd	g«       n&| j                  d
k(  rd|vr|j	                  g d¢«       | j                  dkD  r |j	                  dd| j                  z  g«       | j                  j                  «       D ]  \  }}|j	                  d|› d|› �g«       Œ |j	                  |«       |d| j                  gz   S )Nrô   rË   ú-vcodecr|   ú-pix_fmtÚyuv420prü   ú-filter_complexz1split [a][b];[a] palettegen [p];[b][p] paletteuseÚavif)r  z.split [rgb][rgba]; [rgba] alphaextract [alpha]ú-mapz[rgb]r  z[alpha]r   z-bz%dkz	-metadataú=z-y)r   rP   r  rI   Úextendry   rG   rc   Ú	_args_keyrJ   rF   Úitems)r'   rg   r  ry   ÚkÚvs         r   Úoutput_argszFFMpegBase.output_args  sj  € àˆÜ�d—l‘lÓ#×*Ñ*ˆØÐAÑAØ  ˜ˆD�Jà�K‰K˜ D§J¡JÐ/Ô0Ø)-¯©Ð)D�d—o’oÜŸ<™<¨¯©Ñ7ð 	ð �:‰:˜Ò J°jÑ$@Ø�K‰K˜ YÐ/Õ0ð �Z‰Z˜5Ò Ð%6¸jÑ%HØ�K‰KÐ*ØLðNõ Oð �Z‰Z˜6Ò!Ð&7¸zÑ&IØ�K‰Kò =ô >ð �<‰<˜!ÒØ�K‰K˜˜u t§|¡|Ñ3Ð4Ô5Ø—M‘M×'Ñ'Ó)ò 	3‰DˆAˆqØ�K‰K˜¨¨¨1¨Q¨C jÐ1Õ2ð	3à�‰�JÔà�t˜TŸ\™\Ð*Ñ*Ð*r   N)	r=   r>   r?   r@   r¬   r  rW   rm   r  r.   r   r   rò   rò     s,   „ ñð (€IØ'€Iò>ð ñ +ó ñ +r   rò   Úffmpegc                   ó   — e Zd ZdZd„ Zy)ÚFFMpegWriterat  
    Pipe-based ffmpeg writer.

    Frames are streamed directly to ffmpeg via a pipe and written in a single pass.

    This effectively works as a slideshow input to ffmpeg with the fps passed as
    ``-framerate``, so see also `their notes on frame rates`_ for further details.

    .. _their notes on frame rates: https://trac.ffmpeg.org/wiki/Slideshow#Framerates
    c                 ó  — | j                  «       dddddd| j                  z  d| j                  dt        | j                  «      g}t
        j                  «       t        j                  kD  r|dd	gz  }|d
dg| j                  z   z  }|S )Nú-fr  r  z-sú%dx%dr  ú
-framerateú	-loglevelÚerrorú-izpipe:)
r®   rU   rx   r«   rE   rd   ÚgetEffectiveLevelrœ   rž   r  ©r'   rg   s     r   r�   zFFMpegWriter._argsK  s…   € ð —‘“  z°9¸jØ�g §¡Ñ/°¸T×=NÑ=NØœc $§(¡(›mð-ˆô ×!Ñ!Ó#¤g§m¡mÒ3Ø�[ 'Ð*Ñ*ˆDØ��w� $×"2Ñ"2Ñ2Ñ2ˆØˆr   N)r=   r>   r?   r@   r�   r.   r   r   r!  r!  ?  s   „ ñ	ór   r!  Úffmpeg_filec                   ó   — e Zd ZdZg d¢Zd„ Zy)ÚFFMpegFileWriteray  
    File-based ffmpeg writer.

    Frames are written to temporary files on disk and then stitched together at the end.

    This effectively works as a slideshow input to ffmpeg with the fps passed as
    ``-framerate``, so see also `their notes on frame rates`_ for further details.

    .. _their notes on frame rates: https://trac.ffmpeg.org/wiki/Slideshow#Framerates
    ©rý   Újpegr  rà   rr   c           	      óŒ  — g }| j                   dv r|dddddd| j                  z  dd	gz  }|d
t        | j                  «      d| j	                  «       gz  }| j
                  s|dt        | j                  «      gz  }t        j                  «       t        j                  kD  r|ddgz  }| j                  «       g|¢| j                  ¢S )N>   rà   rr   r#  Úimage2r  r  z-video_sizer$  z-pixel_formatrr   r%  r(  z	-frames:vr&  r'  )rx   rU   r«   rE   rÉ   rº   r¼   rd   r)  rœ   rž   r®   r  r*  s     r   r�   zFFMpegFileWriter._argsi  sÎ   € ð ˆà×Ñ Ñ/ØØ�h 	¨:Ø˜w¨¯©Ñ8Ø ðñ ˆDð
 	�œs 4§8¡8›}¨d°D×4HÑ4HÓ4JÐKÑKˆØ�|Š|Ø�[¤# d×&9Ñ&9Ó":Ð;Ñ;ˆDô ×!Ñ!Ó#¤g§m¡mÒ3Ø�[ 'Ð*Ñ*ˆDØ—‘“Ð: $Ð:¨×)9Ñ)9Ð:Ð:r   N)r=   r>   r?   r@   rw   r�   r.   r   r   r-  r-  [  s   „ ñ	ò ?Ðó;r   r-  c                   óT   ‡ — e Zd ZdZdZdZd„ Zd„ Zeˆ fd„«       Z	eˆ fd„«       Z
ˆ xZS )ÚImageMagickBasea  
    Mixin class for ImageMagick output.

    This is a base class for the concrete `ImageMagickWriter` and
    `ImageMagickFileWriter` classes, which define an ``input_names`` attribute
    (or property) specifying the input names passed to ImageMagick.
    zanimation.convert_pathzanimation.convert_argsc                 óH   — t        | j                  «      j                  }|dv S )Nrô   )r   rP   r  r  s     r   rW   z&ImageMagickBase._supports_transparencyŒ  s"   € Ü�d—l‘lÓ#×*Ñ*ˆØÐEÐEÐEr   c                 óZ  — | j                   dk(  rdn| j                   }| j                  �| j                  nt        j                  | j                     }| j                  «       dd| j                  z  dddt        d| j                  z  «      d	d
|› d| j                  › �g
|¢| j                  ‘S )Nrà   rr   z-sizez%ix%iz-depthÚ8z-delayéd   z-loopÚ0ú:)rx   ry   rG   rc   r  r®   rU   r«   rE   Úinput_namesrP   )r'   Úfmtry   s      r   r�   zImageMagickBase._args�  s­   € à×)Ñ)¨UÒ2‰f¸×8IÑ8IˆØ)-¯©Ð)D�d—o’oÜŸ<™<¨¯©Ñ7ð 	ð �M‰M‹OØ�W˜tŸ™Ñ.Ø�cØ”c˜# §¡™.Ó)Ø�SØˆe�1�T×%Ñ%Ð&Ð'ð	
ð ð	
ð �L‰Lð	
ð 		
r   c                 ól   •— t         ‰| �  «       }|dk(  rt        j                  d«      j                  }|S )Nrç   Úmagick)rv   r®   rG   Ú_get_executable_infoÚ
executable)r3   Úbinpathrz   s     €r   r®   zImageMagickBase.bin_path   s3   ø€ ä‘'Ñ"Ó$ˆØ�iÒÜ×.Ñ.¨xÓ8×CÑCˆGØˆr   c                 óŽ   •— 	 t         ‰| �  «       S # t        j                  $ r }t        j                  d|«       Y d }~yd }~ww xY w)Nz"ImageMagick unavailable due to: %sF)rv   r2   rG   ÚExecutableNotFoundErrorrd   r€   )r3   Ú_enfrz   s     €r   r2   zImageMagickBase.isAvailable§  s>   ø€ ð	Ü‘7Ñ&Ó(Ð(øÜ×*Ñ*ò 	ä�J‰JÐ;¸TÔBÜûð	ús   ƒ ‘A¤?¿A)r=   r>   r?   r@   r¬   r  rW   r�   r²   r®   r2   r³   r´   s   @r   r3  r3  €  sG   ø„ ñð )€IØ(€IòFò
ð  óó ðð óó ôr   r3  Úimagemagickc                   ó   — e Zd ZdZdZy)ÚImageMagickWriterz‡
    Pipe-based animated gif writer.

    Frames are streamed directly to ImageMagick via a pipe and written
    in a single pass.
    ú-N)r=   r>   r?   r@   r:  r.   r   r   rF  rF  ²  s   „ ñð �Kr   rF  Úimagemagick_filec                   ó*   — e Zd ZdZg d¢Z ed„ «      Zy)ÚImageMagickFileWriterz‡
    File-based animated gif writer.

    Frames are written to temporary files on disk and then stitched
    together at the end.
    r.  c                 ó8   — | j                   › d| j                  › �S )Nz*.)r»   rx   r&   s    r   ú<lambda>zImageMagickFileWriter.<lambda>Ê  s   € ˜×(Ñ(Ð)¨¨D×,=Ñ,=Ð+>Ð?€ r   N)r=   r>   r?   r@   rw   rm   r:  r.   r   r   rJ  rJ  ¿  s   „ ñò ?ÐÙÙ?óA�Kr   rJ  c                 ó2   — t        j                  | ||¬«      S )N)ÚNframesÚ	frame_dirrx   )r	   r¤   )Úframe_countrx   rO  s      r   Ú_included_framesrQ  Ï  s   € Ü×!Ñ!¨+Ø,5Ø/;ô=ð =r   c                 óf   ‡‡— ‰dk(  rdŠdŠddj                  ˆˆfd„t        | «      D «       «      z   S )z7frame_list should be a list of base64-encoded png filesÚsvgzsvg+xmlz,  frames[{0}] = "data:image/{1};base64,{2}"
ú
Ú c           	   3   ój   •K  — | ]*  \  }}‰j                  |‰|j                  d d«      «      –— Œ, y­w)rT  z\
N)r¤   Úreplace)Ú.0ÚiÚ
frame_datarx   Útemplates      €€r   ú	<genexpr>z#_embedded_frames.<locals>.<genexpr>Û  s7   øè ø€ ò 4áˆAˆzð 	�‰˜˜<¨×);Ñ);¸DÀ&Ó)I×Jñ4ùs   ƒ03)ÚjoinÚ	enumerate)Ú
frame_listrx   r[  s    `@r   Ú_embedded_framesr`  Õ  s?   ù€ à�uÒà ˆØ>€HØ�"—'‘'ô 4ä& zÓ2ô4ó 4ñ 4ð 4r   Úhtmlc                   ó^   ‡ — e Zd ZdZg d¢Zed„ «       Z	 	 	 dˆ fd„	Zd	ˆ fd„	Zˆ fd„Z	d„ Z
ˆ xZS )
Ú
HTMLWriterz(Writer for JavaScript-based HTML movies.)rý   r/  r  rS  c                  ó   — yrÙ   r.   r­   s    r   r2   zHTMLWriter.isAvailableæ  rÛ   r   c	                 ó<  •— |rt         j                  d«       d}|| _        |j                  «       | _        t        j                  g d¢| j                  ¬«       t        j                  |d«      | _	        | xj                  dz  c_	        t        ‰	| �-  |||||«       y )NzHTMLWriter ignores 'extra_args'r.   )rï   ÚonceÚreflect)Údefault_modeúanimation.embed_limité   )rd   ÚwarningÚembed_framesÚlowerrh  r   Úcheck_in_listrG   rH   Ú_bytes_limitrv   r(   )
r'   rE   rI   rJ   ry   rF   rl  rh  Úembed_limitrz   s
            €r   r(   zHTMLWriter.__init__ê  s‰   ø€ ñ Ü�L‰LÐ:Ô;Øˆ
Ø(ˆÔØ(×.Ñ.Ó0ˆÔÜ×ÑÒ6Ø(,×(9Ñ(9õ	;ô  ŸN™N¨;Ð8OÓPˆÔà×Ò˜[Ñ(Õä‰Ñ˜˜e W¨j¸(ÕCr   c                 óL  •— t        |«      }t        j                  ddg|j                  ¬«       g | _        d| _        d| _        | j                  s9|€|j                  |j                  dz   «      }|j                  dd¬«       |d	z  }nd }t        ‰| �1  ||||«       d| _        y )
Nz.htmlz.htm)Úoutfile_extensionr   FrÝ   T)ÚparentsÚexist_okÚframe)r   r   rn  r  Ú_saved_framesÚ_total_bytesÚ
_hit_limitrl  Ú	with_nameÚstemÚmkdirrv   rR   Ú_clear_temp)r'   rQ   rP   r   rO  r¿   rz   s         €r   rR   zHTMLWriter.setupý  s�   ø€ Ü�w“-ˆÜ×Ñ˜G VÐ,ÀÇÁÕOàˆÔØˆÔØˆŒà× Ò ØÐ Ø#×-Ñ-¨g¯l©l¸YÑ.FÓG�	Ø�O‰O D°4ˆOÔ8Ø$ wÑ.‰LàˆLä‰‰�c˜7 C¨Ô6Ø ˆÕr   c                 óX  •— t        |«       | j                  �r| j                  ry t        «       } | j                  j
                  |f| j                  | j                  dœ|¤Ž t        j                  |j                  «       «      j                  d«      }| xj                  t        |«      z  c_        | j                  | j                  k\  r3t        j!                  d| j                  | j                  «       d| _        y | j"                  j%                  |«       y t'        ‰| �P  di |¤ŽS )Nr£   ÚasciizãAnimation size has reached %s bytes, exceeding the limit of %s. If you're sure you want a larger animation embedded, set the animation.embed_limit rc parameter to a larger value (in MB). This and further frames will be dropped.Tr.   )r¥   rl  rx  r   rQ   r¦   rx   r   Úbase64ÚencodebytesÚgetvalueÚdecoderw  Úlenro  rd   rk  rv  rÍ   rv   r[   )r'   rZ   ÚfÚ	imgdata64rz   s       €r   r[   zHTMLWriter.grab_frame  sö   ø€ Ü" >Ô2Ø×Óà�ŠØÜ“	ˆAØˆD�H‰H×Ñ˜Qð = t×'8Ñ'8Ø!%§¡ñ=Ø-;ò=ä×*Ñ*¨1¯:©:«<Ó8×?Ñ?ÀÓHˆIØ×Ò¤ Y£Ñ/ÕØ× Ñ  D×$5Ñ$5Ò5Ü—‘ðð !%× 1Ñ 1°4×3DÑ3DôFð #'�•à×"Ñ"×)Ñ)¨)Õ4ä‘7Ñ%Ñ7¨Ñ7Ð7r   c                 óX  — | j                   r6t        | j                  | j                  «      }t	        | j                  «      }nft	        | j
                  «      }t        || j                  | j
                  d   j                  j                  | j                  j                  «      «      }t        ddd¬«      }d|| j                  dz   <   d| j                  z  }t        | j                  d«      5 }|j                  t        t         z   «       |j                  t#        j$                  d
t'        j(                  «       j*                  |||dœ|¤Ž«       d d d «       | j,                  r;t.        j1                  d	| j,                  «       | j,                  j3                  «        y y # 1 sw Y   ŒQxY w)Nr   rU  )Úonce_checkedÚloop_checkedÚreflect_checkedÚcheckedÚ_checkedrë   r   )ÚidrN  Úfill_framesÚintervalrÒ   r.   )rl  r`  rv  rx   rƒ  r½   rQ  rN   Úrelative_torP   r$   rh  rE   rÎ   Úwriter
   r   r   r¤   ÚuuidÚuuid4Úhexrº   rd   r€   rÂ   )r'   r�  rP  Ú	mode_dictrŽ  Úofs         r   r_   zHTMLWriter.finish(  sg  € à×ÒÜ*¨4×+=Ñ+=Ø+/×+<Ñ+<ó>ˆKä˜d×0Ñ0Ó1‰Kô ˜d×.Ñ.Ó/ˆKÜ*Ø˜T×.Ñ.Ø× Ñ  Ñ#×*Ñ*×6Ñ6°t·|±|×7JÑ7JÓKóMˆKô  bØ&(Ø)+ô-ˆ	ð 5>ˆ	�$×#Ñ# jÑ0Ñ1à˜4Ÿ8™8Ñ#ˆä�$—,‘, Ó$ð 	;¨Ø�H‰H”Z¤-Ñ/Ô0Ø�H‰HÔ%×,Ñ,ð :´·
±
³×0@Ñ0@Ø5@Ø9DØ6>ñ:ð 09ñ	:ô ;÷	;ð �<Š<Ü�J‰JÐ@À$Ç,Á,ÔOØ�L‰L× Ñ Õ"ð ÷	;ð 	;ús   Ã.A"F Æ F))é   NNNNFrï   NrÓ   )r=   r>   r?   r@   rw   r²   r2   r(   rR   r[   r_   r³   r´   s   @r   rc  rc  à  s@   ø„ á2â6Ðàñó ðð EIØAGØ!õDõ&!ô&8ö0"#r   rc  c                   ó®   — e Zd ZdZdd„Zd„ Zd„ Zd„ Z	 	 	 dddœd„Zd	„ Z	d
„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zdd„Zd„ Zd„ Zd„ Zy)Ú	AnimationaÚ  
    A base class for Animations.

    This class is not usable as is, and should be subclassed to provide needed
    behavior.

    .. note::

        You must store the created Animation in a variable that lives as long
        as the animation should run. Otherwise, the Animation object will be
        garbage-collected and the animation stops.

    Parameters
    ----------
    fig : `~matplotlib.figure.Figure`
        The figure object used to get needed events, such as draw or resize.

    event_source : object, optional
        A class that can run a callback when desired events
        are generated, as well as be stopped and started.

        Examples include timers (see `TimedAnimation`) and file
        system notifications.

    blit : bool, default: False
        Whether blitting is used to optimize drawing.  If the backend does not
        support blitting, then this parameter has no effect.

    See Also
    --------
    FuncAnimation,  ArtistAnimation
    Nc                 ó�  — d| _         || _        |xr |j                  j                  | _        | j                  «       | _        || _        |j                  j                  d| j                  «      | _
        | j                  j                  j                  d| j                  «      | _        | j                  r| j                  «        y y )NFÚ
draw_eventÚclose_event)Ú_draw_was_startedÚ_figÚcanvasÚsupports_blitÚ_blitÚnew_frame_seqÚ	frame_seqÚevent_sourceÚmpl_connectÚ_startÚ_first_draw_idÚ_stopÚ	_close_idÚ_setup_blit)r'   rQ   r£  Úblits       r   r(   zAnimation.__init__o  s¢   € Ø!&ˆÔàˆŒ	ð Ò6˜cŸj™j×6Ñ6ˆŒ
ð ×+Ñ+Ó-ˆŒØ(ˆÔð "Ÿj™j×4Ñ4°\À4Ç;Á;ÓOˆÔð Ÿ™×)Ñ)×5Ñ5°mØ6:·j±jóBˆŒà�:Š:Ø×ÑÕð r   c                 óJ   — t        | dd«      st        j                  d«       y y )Nrœ  TzéAnimation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. `anim`, that exists until you output the Animation using `plt.show()` or `anim.save()`.)ÚgetattrÚwarningsÚwarnr&   s    r   rÃ   zAnimation.__del__Š  s%   € Ü�tÐ0°$Ô7Ü�M‰Mð!õð 8r   c                 óJ  — | j                   j                  j                  «       ry| j                   j                  j                  | j                  «       | j                  «        | j                  j                  | j                  «       | j                  j                  «        y)z‹
        Starts interactive animation. Adds the draw frame command to the GUI
        handler, calls show to start the event loop.
        N)
r�  rž  Ú	is_savingÚmpl_disconnectr¦  Ú
_init_drawr£  Úadd_callbackÚ_stepÚstartr*  s     r   r¥  zAnimation._start”  ss   € ð �9‰9×Ñ×%Ñ%Ô'Øà�	‰	×Ñ×'Ñ'¨×(;Ñ(;Ô<ð 	�‰Ôð 	×Ñ×&Ñ& t§z¡zÔ2Ø×Ñ×ÑÕ!r   c                 ó0  — | j                   r/| j                  j                  j                  | j                  «       | j                  j                  j                  | j
                  «       | j                  j                  | j                  «       d | _        y r#   )	r   r�  rž  r±  Ú
_resize_idr¨  r£  Úremove_callbackr´  r*  s     r   r§  zAnimation._stop§  sa   € à�:Š:Ø�I‰I×Ñ×+Ñ+¨D¯O©OÔ<Ø�	‰	×Ñ×'Ñ'¨¯©Ô7Ø×Ñ×)Ñ)¨$¯*©*Ô5Ø ˆÕr   )Úprogress_callbackc          
      óN  ‡ — ‰ g}|	�|j                  ˆ fd„|	D «       «       |D ]	  }d|_        Œ |€t        j                  d   }n2t	        |t
        «      s"t        d„ |||||fD «       «      rt        d«      ‚|
€i }
nt        |
«      }
|€t        ‰ d«      rd‰ j                  z  }t        j                  |d	«      }|d
k(  r‰ j                  j                  }i }|�||d<   |�||d<   |�||d<   |�||d<   t	        |t
        «      r	 t        |   } ||fi |¤Ž}t         j%                  dt'        |«      «       d|
v r&t         j#                  d«       |
j)                  d«       d„ }|j+                  ‰ j                  ||«      5  t-        j.                  ‰ j                  j0                  dd¬«      5  |j3                  «       sR|
j5                  dt        j                  d   «      }|dk(  r‰ j                  j7                  «       } ||«      |
d<   d|
d<   |D ]  }|j9                  «        Œ d}|D �cg c]  }t;        |dd«      ‘Œ }}d|v rd}nt=        |«      }t?        |D �cg c]  }|jA                  «       ‘Œ c}Ž D ]L  }t?        ||«      D ])  \  }}|jC                  |d¬«       |€Œ |||«       |dz  }Œ+  |jD                  di |
¤Ž ŒN 	 ddd«       ddd«       y# t        $ r  t        }t         j#                  d|«       Y �Œôw xY wc c}w c c}w # 1 sw Y   ŒHxY w# 1 sw Y   yxY w)aô  
        Save the animation as a movie file by drawing every frame.

        Parameters
        ----------
        filename : str
            The output filename, e.g., :file:`mymovie.mp4`.

        writer : `MovieWriter` or str, default: :rc:`animation.writer`
            A `MovieWriter` instance to use or a key that identifies a
            class to use, such as 'ffmpeg'.

        fps : int, optional
            Movie frame rate (per second).  If not set, the frame rate from the
            animation's frame interval.

        dpi : float, default: :rc:`savefig.dpi`
            Controls the dots per inch for the movie frames.  Together with
            the figure's size in inches, this controls the size of the movie.

        codec : str, default: :rc:`animation.codec`.
            The video codec to use.  Not all codecs are supported by a given
            `MovieWriter`.

        bitrate : int, default: :rc:`animation.bitrate`
            The bitrate of the movie, in kilobits per second.  Higher values
            means higher quality movies, but increase the file size.  A value
            of -1 lets the underlying movie encoder select the bitrate.

        extra_args : list of str or None, optional
            Extra command-line arguments passed to the underlying movie encoder. These
            arguments are passed last to the encoder, just before the output filename.
            The default, None, means to use :rc:`animation.[name-of-encoder]_args` for
            the builtin writers.

        metadata : dict[str, str], default: {}
            Dictionary of keys and values for metadata to include in
            the output file. Some keys that may be of use include:
            title, artist, genre, subject, copyright, srcform, comment.

        extra_anim : list, default: []
            Additional `Animation` objects that should be included
            in the saved movie file. These need to be from the same
            `.Figure` instance. Also, animation frames will
            just be simply combined, so there should be a 1:1 correspondence
            between the frames from the different animations.

        savefig_kwargs : dict, default: {}
            Keyword arguments passed to each `~.Figure.savefig` call used to
            save the individual frames.

        progress_callback : function, optional
            A callback function that will be called for every frame to notify
            the saving progress. It must have the signature ::

                def func(current_frame: int, total_frames: int) -> Any

            where *current_frame* is the current frame number and *total_frames* is the
            total number of frames to be saved. *total_frames* is set to None, if the
            total number of frames cannot be determined. Return values may exist but are
            ignored.

            Example code to write the progress to stdout::

                progress_callback = lambda i, n: print(f'Saving frame {i}/{n}')

        Notes
        -----
        *fps*, *codec*, *bitrate*, *extra_args* and *metadata* are used to
        construct a `.MovieWriter` instance and can only be passed if
        *writer* is a string.  If they are passed as non-*None* and *writer*
        is a `.MovieWriter`, a `RuntimeError` will be raised.
        Nc              3   óR   •K  — | ]  }|j                   ‰j                   u r|–— Œ  y ­wr#   )r�  )rX  Úanimr'   s     €r   r\  z!Animation.save.<locals>.<genexpr>þ  s(   øè ø€ ò 7 TØ#Ÿy™y¨D¯I©IÑ5ô !ñ 7ùs   ƒ$'Túanimation.writerc              3   ó$   K  — | ]  }|d u–— Œ
 y ­wr#   r.   )rX  Úargs     r   r\  z!Animation.save.<locals>.<genexpr>  s   è ø€ ò JØð ˜T”/ñ Jùs   ‚zâPassing in values for arguments fps, codec, bitrate, extra_args, or metadata is not supported when writer is an existing MovieWriter instance. These should instead be passed as arguments when creating the MovieWriter instance.Ú	_intervalç     @�@zsavefig.dpiÚfigurerI   rJ   ry   rF   z1MovieWriter %s unavailable; using Pillow instead.zAnimation.save using %sÚbbox_incheszŒWarning: discarding the 'bbox_inches' argument in 'savefig_kwargs' as it may cause frame size to vary, which is inappropriate for animation.c                 óx   — t        j                  | «      \  }}}}|t        j                  |||g«      z  dz   |z
  S )NrË   )ÚmcolorsÚto_rgbar   Úarray)ÚcolorÚrÚgÚbÚas        r   Ú_pre_composite_to_whitez/Animation.save.<locals>._pre_composite_to_whiteC  s<   € Ü Ÿ™¨Ó/‰JˆAˆq�!�QØ”r—x‘x  A q 	Ó*Ñ*¨QÑ.°Ñ2Ð2r   )Ú
_is_savingÚmanagerÚ	facecolorzsavefig.facecolorÚautoFÚtransparentr   Ú_save_count)rª  rË   r.   )#r  rœ  rG   rc   Ú
isinstancer«   Úanyr;   r$   rÁ   rÀ  rH   r�  r   Úwritersr×   rd   rk  re   rt   Úpopri   r   Ú_setattr_cmrž  rW   ÚgetÚget_facecolorr²  r¬  ÚsumÚzipÚnew_saved_frame_seqÚ_draw_next_framer[   )r'   ÚfilenameÚwriterrE   r   rI   rJ   ry   rF   Ú
extra_animrZ   r¹  Úall_animr¼  Úwriter_kwargsr+   rÍ  rÐ  Úframe_numberrÌ  Úsave_count_listÚtotal_framesÚdataÚds   `                       r   rð   zAnimation.save¯  s}  ø€ ðZ �6ˆØÐ!Ø�O‰Oó 7¨Zô 7ô 7ð ò 	*ˆDØ%)ˆDÕ"ð	*ð ˆ>Ü—\‘\Ð"4Ñ5‰FÜ˜V¤SÔ)Üñ JØ! 5¨'°:¸xÐHôJô Jäð  7ó 8ð 8ð Ð!Ø‰Nô " .Ó1ˆNàˆ;œ7 4¨Ô5à˜$Ÿ.™.Ñ(ˆCô �n‰n˜S -Ó0ˆØ�(Š?Ø—)‘)—-‘-ˆCàˆØÐØ%*ˆM˜'Ñ"ØÐØ'.ˆM˜)Ñ$ØÐ!Ø*4ˆM˜,Ñ'ØÐØ(0ˆM˜*Ñ%ô �fœcÔ"ð1Ü$ V™_�
ñ
   Ñ5 }Ñ5ˆFÜ�	‰	Ð+¬T°&«\Ô:à˜NÑ*Ü�L‰Lð Jô Kð ×Ñ˜}Ô-ò	3ð �m‰m˜DŸI™I x°Ó5ñ 	4Ü×Ñ §	¡	× 0Ñ 0¸TÈ4ÔPñ	4à×0Ñ0Ô2Ø*×.Ñ.¨{Ü/2¯|©|Ð<OÑ/PóR�	à Ò&Ø $§	¡	× 7Ñ 7Ó 9�IÙ.EÀiÓ.P�˜{Ñ+Ø05�˜}Ñ-à ò "�Ø—‘Õ!ð"àˆLð )1ö2Ø#$ô  ' q¨-¸Õ>ð 2ˆOð 2à�Ñ&Ø#‘ä" ?Ó3�Ü¸xÖH¸!˜a×3Ñ3Õ5ÒHÐIò 4�Ü" 8¨TÓ2ò *‘G�D˜!à×)Ñ)¨!°%Ð)Ô8Ø(Ñ4Ù)¨,¸ÔEØ$¨Ñ)™ð*ð "�×!Ñ!Ñ3 NÓ3ñ4÷+	4÷ 	4ð 	4øô7  ò 1Ü)�
Ü—‘ð (Ø)/÷1ð1üòT2ùò I÷+	4ð 	4ú÷ 	4ð 	4ús[   Ä	K Å?-LÆ,B LÈ,LÉ LÉL
É4.LÊ#$LËLË%LÌLÌ
LÌL	ÌLÌL$c                 ó†   — 	 t        | j                  «      }| j                  || j                  «       y# t        $ r Y yw xY w)z‰
        Handler for getting events. By default, gets the next frame in the
        sequence and hands the data off to be drawn.
        TF)Únextr¢  rÞ  r   ÚStopIteration)r'   rg   Ú	framedatas      r   r´  zAnimation._steph  s>   € ð	Ü˜TŸ^™^Ó,ˆIØ×!Ñ! )¨T¯Z©ZÔ8ØøÜò 	Ùð	ús   ‚14 ´	A ¿A c                 ó,   — t        | j                  «      S )z+Return a new sequence of frame information.)ÚiterÚ
_framedatar&   s    r   r¡  zAnimation.new_frame_seqw  s   € ô �D—O‘OÓ$Ð$r   c                 ó"   — | j                  «       S )z8Return a new sequence of saved/cached frame information.)r¡  r&   s    r   rÝ  zAnimation.new_saved_frame_seq|  s   € ð ×!Ñ!Ó#Ð#r   c                 ón   — | j                  ||«       | j                  |«       | j                  ||«       y r#   )Ú	_pre_drawÚ_draw_frameÚ
_post_draw©r'   rì  rª  s      r   rÞ  zAnimation._draw_next_frame�  s.   € ð 	�‰�y $Ô'Ø×Ñ˜Ô#Ø�‰˜	 4Õ(r   c                 ó   — d| _         y rÙ   )rœ  r&   s    r   r²  zAnimation._init_drawˆ  s   € ð "&ˆÕr   c                 ó@   — |r| j                  | j                  «       y y r#   )Ú_blit_clearÚ_drawn_artistsrõ  s      r   rò  zAnimation._pre_draw�  s    € ñ Ø×Ñ˜T×0Ñ0Õ1ð r   c                 ó   — t        d«      ‚)NzDNeeds to be implemented by subclasses to actually make an animation.r¨   )r'   rì  s     r   ró  zAnimation._draw_frame“  s   € ä!ð #Aó Bð 	Br   c                 ó    — |r(| j                   r| j                  | j                   «       y | j                  j                  j	                  «        y r#   )rù  Ú
_blit_drawr�  rž  Ú	draw_idlerõ  s      r   rô  zAnimation._post_draw˜  s7   € ñ �D×'Ò'Ø�O‰O˜D×/Ñ/Õ0à�I‰I×Ñ×&Ñ&Õ(r   c                 óø  — |D �ch c]  }|j                   ’Œ }}|D ]  }|j                  «       }| j                  j                  |t	        «       d f«      \  }}||k7  sŒB||j
                  j                  j                  |j                  «      f| j                  |<   Œ� |D ]  }|j                   j                  |«       Œ |D ]1  }|j
                  j                  j                  |j                  «       Œ3 y c c}w r#   )ÚaxesÚ	_get_viewÚ_blit_cacherÙ  ÚobjectrÂ  rž  Úcopy_from_bboxÚbboxÚdraw_artistrª  )r'   ÚartistsrÌ  Ú
updated_axÚaxÚcur_viewÚviewÚbgs           r   rü  zAnimation._blit_draw¢  sì   € ð '.Ö. �a—f“fÐ.ˆ
Ð.ð ò 	HˆBð —|‘|“~ˆHØ×'Ñ'×+Ñ+¨B´³¸4Ð0@ÓA‰HˆD�"Ø˜4Óà˜bŸi™i×.Ñ.×=Ñ=¸b¿g¹gÓFð(H�× Ñ  Ò$ð	Hð ò 	"ˆAØ�F‰F×Ñ˜qÕ!ð	"ð ò 	+ˆBØ�I‰I×Ñ×!Ñ! "§'¡'Õ*ñ	+ùò! /s   …C7c                 ó:  — |D �ch c]  }|j                   ’Œ }}|D ]i  }	 | j                  |   \  }}|j                  «       |k(  r&|j                  j
                  j                  |«       ŒO| j                  j                  |«       Œk y c c}w # t        $ r Y Œ}w xY wr#   )rÿ  r  r1   r   rÂ  rž  Úrestore_regionr×  )r'   r  rÌ  rÿ  r  r
  r  s          r   rø  zAnimation._blit_clear¸  s˜   € ð !(Ö(˜1�—“Ð(ˆÐ(Øò 	)ˆBðØ×+Ñ+¨BÑ/‘��bð �|‰|‹~ Ò%Ø—	‘	× Ñ ×/Ñ/°Õ3à× Ñ ×$Ñ$ RÕ(ñ	)ùò )øô ò Ùðús   …B	 BÂ	BÂBc                 óò   — t        «       | _        g | _        | j                  d | j                  «       | j                  «        | j                  j                  j                  d| j                  «      | _
        y )NÚresize_event)r$   r  rù  rô  r   r²  r�  rž  r¤  Ú
_on_resizer·  r&   s    r   r©  zAnimation._setup_blitÇ  sX   € ä›6ˆÔØ ˆÔà�‰˜˜dŸj™jÔ)ð
 	�‰ÔàŸ)™)×*Ñ*×6Ñ6°~Ø7;·±óHˆ�r   c                 óT  — | j                   j                  j                  | j                  «       | j                  j                  «        | j                  j                  «        | j                  «        | j                   j                  j                  d| j                  «      | _        y )Nrš  )r�  rž  r±  r·  r£  Ústopr  Úclearr²  r¤  Ú_end_redraw©r'   Úevents     r   r  zAnimation._on_resizeÖ  sv   € ð
 	�	‰	×Ñ×'Ñ'¨¯©Ô8Ø×Ñ×ÑÔ Ø×Ñ×ÑÔ Ø�‰ÔØŸ)™)×*Ñ*×6Ñ6°|Ø7;×7GÑ7GóIˆ�r   c                 ó$  — | j                  d d«       | j                  j                  «        | j                  j                  j                  | j                  «       | j                  j                  j                  d| j                  «      | _        y )NFr  )	rô  r£  rµ  r�  rž  r±  r·  r¤  r  r  s     r   r  zAnimation._end_redrawâ  sf   € ð 	�‰˜˜eÔ$Ø×Ñ×ÑÔ!Ø�	‰	×Ñ×'Ñ'¨¯©Ô8ØŸ)™)×*Ñ*×6Ñ6°~Ø7;·±óHˆ�r   c                 ó4  — d}t        | d«      �st        j                  |d«      }|dz  }t        «       5 }t	        |d«      }t
        t        j                  d      } |dt        j                  d   d	| j                  z  ¬
«      }| j                  t        |«      |¬«       t        j                  |j                  «       «      }ddd«       t        «      }||k\  rt        j                  d||«       n4|j!                  d«      | _         dj$                  j&                  Ž | _        t        | d«      rYddg}	t+        | dd«      r|	j-                  d«       |j%                  | j"                  | j(                  dj/                  |	«      ¬«      S y# 1 sw Y   ŒËxY w)a‚  
        Convert the animation to an HTML5 ``<video>`` tag.

        This saves the animation as an h264 video, encoded in base64
        directly into the HTML5 video tag. This respects :rc:`animation.writer`
        and :rc:`animation.bitrate`. This also makes use of the
        *interval* to control the speed, and uses the *repeat*
        parameter to decide whether to loop.

        Parameters
        ----------
        embed_limit : float, optional
            Limit, in MB, of the returned animation. No animation is created
            if the limit is exceeded.
            Defaults to :rc:`animation.embed_limit` = 20.0.

        Returns
        -------
        str
            An HTML5 video tag with the animation embedded as base64 encoded
            h264 video.
            If the *embed_limit* is exceeded, this returns the string
            "Video too large to embed."
        z�<video {size} {options}>
  <source type="video/mp4" src="data:video/mp4;base64,{video}">
  Your browser does not support the video tag.
</video>Ú_base64_videori  rj  ztemp.m4vr½  r|   rD   rÁ  )rI   rJ   rE   ©rà  Nz±Animation movie is %s bytes, exceeding the limit of %s. If you're sure you want a large animation embedded, set the animation.embed_limit rc parameter to a larger value (in MB).r~  zwidth="{}" height="{}"ÚcontrolsÚautoplayÚ_repeatFrï   ú )ÚvideoÚsizeÚoptionszVideo too large to embed.)rÁ   rG   rH   r   r   rÖ  rc   rÀ  rð   r«   r  r€  Ú
read_bytesrƒ  rd   rk  r‚  r  r¤   rU   Ú_video_sizer¬  rÍ   r]  )
r'   rp  Ú	VIDEO_TAGÚtmpdirrÏ   ÚWriterrà  Úvid64Úvid_lenr!  s
             r   Úto_html5_videozAnimation.to_html5_videoë  s�  € ð2ˆ	ô
 �t˜_Õ-äŸ.™.¨Ð6MÓNˆKð ˜;Ñ&ˆKô $Ó%ð 
>¨Ü˜F JÓ/�ô !¤§¡Ð.@Ñ!AÑB�Ù fÜ(+¯©Ð5HÑ(IØ$)¨D¯N©NÑ$:ô<�ð —	‘	œ#˜d›)¨F�	Ô3ä×*Ñ*¨4¯?©?Ó+<Ó=�÷
>ô ˜%“jˆGØ˜+Ò%Ü—‘ðð !(¨õ	6ð &+§\¡\°'Ó%:�Ô"Ø#BÐ#;×#BÑ#BØ×*Ñ*ð$,�Ô ô �4˜Ô)à! :Ð.ˆGô �t˜Y¨Ô.Ø—‘˜vÔ&à×#Ñ#¨$×*<Ñ*<Ø)-×)9Ñ)9Ø,/¯H©H°WÓ,=ð $ó ?ð ?ð /÷K
>ð 
>ús   µBFÆFc                 ó”  — |€t        | d«      rd| j                  z  }|€t        | dd«      rdnd}t        | d«      sjt        «       5 }t	        |d	«      }t        |||¬
«      }| j                  t        |«      |¬«       |j                  «       | _	        ddd«       | j                  S | j                  S # 1 sw Y   | j                  S xY w)a¶  
        Generate HTML representation of the animation.

        Parameters
        ----------
        fps : int, optional
            Movie frame rate (per second). If not set, the frame rate from
            the animation's frame interval.
        embed_frames : bool, optional
        default_mode : str, optional
            What to do when the animation ends. Must be one of ``{'loop',
            'once', 'reflect'}``. Defaults to ``'loop'`` if the *repeat*
            parameter is True, otherwise ``'once'``.

        Returns
        -------
        str
            An HTML representation of the animation embedded as a js object as
            produced with the `.HTMLWriter`.
        NrÀ  rë   r  Frï   rf  Ú_html_representationz	temp.html)rE   rl  rh  r  )
rÁ   rÀ  r¬  r   r   rc  rð   r«   Ú	read_textr+  )r'   rE   rl  rh  r%  rÏ   rà  s          r   Ú	to_jshtmlzAnimation.to_jshtml9  sÒ   € ð* ˆ;œ7 4¨Ô5à˜Ÿ™Ñ'ˆCð ÐÜ%,¨T°9Ø-2ô&4™6Ø9?ð ô �tÐ3Ô4ô $Ó%ð =¨Ü˜F KÓ0�Ü#¨Ø1=Ø1=ô?�ð —	‘	œ#˜d›)¨F�	Ô3Ø,0¯N©NÓ,<�Ô)÷=ð ×(Ñ(Ð(ˆt×(Ñ(Ð(÷=ð ×(Ñ(Ð(ús   ÁAB3Â3Cc                 ó~   — t         j                  d   }|dk(  r| j                  «       S |dk(  r| j                  «       S y)z#IPython display hook for rendering.zanimation.htmlÚhtml5ÚjshtmlN)rG   rc   r)  r-  )r'   r;  s     r   Ú_repr_html_zAnimation._repr_html_e  s@   € ä�l‰lÐ+Ñ,ˆØ�'Š>Ø×&Ñ&Ó(Ð(Ø�HŠ_Ø—>‘>Ó#Ð#ð r   c                 ó–   — | j                   j                  «        | j                  r#| j                  D ]  }|j	                  d«       Œ yy)zPause the animation.FN)r£  r  r   rù  Úset_animated©r'   Úartists     r   ÚpausezAnimation.pausem  sC   € à×Ñ×ÑÔ Ø�:Š:Ø×-Ñ-ò +�Ø×#Ñ# EÕ*ñ+ð r   c                 ó–   — | j                   j                  «        | j                  r#| j                  D ]  }|j	                  d«       Œ yy)zResume the animation.TN)r£  rµ  r   rù  r3  r4  s     r   ÚresumezAnimation.resumet  sC   € à×Ñ×ÑÔ!Ø�:Š:Ø×-Ñ-ò *�Ø×#Ñ# DÕ)ñ*ð r   ©NF)	NNNNNNNNNr#   )NTN)r=   r>   r?   r@   r(   rÃ   r¥  r§  rð   r´  r¡  rÝ  rÞ  r²  rò  ró  rô  rü  rø  r©  r  r  r)  r-  r1  r6  r8  r.   r   r   r˜  r˜  M  sš   „ ñóBò6ò"ò&!ð EIØFJØ ðw4à7;ôw4òrò%ò
$ò
)ò&ò
2òBò
)ò+ò,)òHò
IòHóL/ó\*)òX$ò+ó*r   r˜  c                   ó2   ‡ — e Zd ZdZ	 	 dˆ fd„	Zˆ fd„Zˆ xZS )ÚTimedAnimationa}  
    `Animation` subclass for time-based animation.

    A new frame is drawn every *interval* milliseconds.

    .. note::

        You must store the created Animation in a variable that lives as long
        as the animation should run. Otherwise, the Animation object will be
        garbage-collected and the animation stops.

    Parameters
    ----------
    fig : `~matplotlib.figure.Figure`
        The figure object used to get needed events, such as draw or resize.
    interval : int, default: 200
        Delay between frames in milliseconds.
    repeat_delay : int, default: 0
        The delay in milliseconds between consecutive animation runs, if
        *repeat* is True.
    repeat : bool, default: True
        Whether the animation repeats when the sequence of frames is completed.
    blit : bool, default: False
        Whether blitting is used to optimize drawing.
    c                 ó²   •— || _         |�|nd| _        || _        |€&|j                  j	                  | j                   ¬«      }t        ‰| �  |g|¢­d|i|¤Ž y )Nr   )rŽ  r£  )rÀ  Ú_repeat_delayr  rž  Ú	new_timerrv   r(   )	r'   rQ   rŽ  Úrepeat_delayÚrepeatr£  rg   rh   rz   s	           €r   r(   zTimedAnimation.__init__–  s_   ø€ à!ˆŒà-9Ð-E™\È1ˆÔØˆŒð ÐØŸ:™:×/Ñ/¸¿¹Ð/ÓHˆLÜ‰Ñ˜ÐI¸$ÒI¨<ÐIÀ&ÓIr   c                 óö  •— t        ‰| �  |Ž }|sÏ| j                  rA| j                  «        | j	                  «       | _        | j                  | j                  _        y| j                  «        | j                  r/| j                  j                  j                  | j                  «       | j                  j                  j                  | j                  «       d| _        y| j                   | j                  _        y)zHandler for getting events.TNF)rv   r´  r  r²  r¡  r¢  r=  r£  rŽ  r6  r   r�  rž  r±  r·  r¨  rÀ  )r'   rg   Ústill_goingrz   s      €r   r´  zTimedAnimation._step¢  s¸   ø€ ô ‘g‘m TÐ*ˆÙØ�|Š|à—‘Ô!Ø!%×!3Ñ!3Ó!5�”Ø-1×-?Ñ-?�×!Ñ!Ô*Øð —
‘
”Ø—:’:à—I‘I×$Ñ$×3Ñ3°D·O±OÔDØ—	‘	× Ñ ×/Ñ/°·±Ô?Ø$(�Ô!Øà%)§^¡^ˆ×ÑÔ"Ør   )éÈ   r   TN)r=   r>   r?   r@   r(   r´  r³   r´   s   @r   r;  r;  |  s"   ø„ ñð2 BFØ"õ
J÷ð r   r;  c                   ó8   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zd„ Zd„ Zˆ xZS )ÚArtistAnimationa�  
    `TimedAnimation` subclass that creates an animation by using a fixed
    set of `.Artist` objects.

    Before creating an instance, all plotting should have taken place
    and the relevant artists saved.

    .. note::

        You must store the created Animation in a variable that lives as long
        as the animation should run. Otherwise, the Animation object will be
        garbage-collected and the animation stops.

    Parameters
    ----------
    fig : `~matplotlib.figure.Figure`
        The figure object used to get needed events, such as draw or resize.
    artists : list
        Each list entry is a collection of `.Artist` objects that are made
        visible on the corresponding frame.  Other artists are made invisible.
    interval : int, default: 200
        Delay between frames in milliseconds.
    repeat_delay : int, default: 0
        The delay in milliseconds between consecutive animation runs, if
        *repeat* is True.
    repeat : bool, default: True
        Whether the animation repeats when the sequence of frames is completed.
    blit : bool, default: False
        Whether blitting is used to optimize drawing.
    c                 óH   •— g | _         || _        t        ‰| �  |g|¢­i |¤Ž y r#   )rù  rï  rv   r(   )r'   rQ   r  rg   rh   rz   s        €r   r(   zArtistAnimation.__init__á  s+   ø€ à ˆÔð "ˆŒÜ‰Ñ˜Ð.˜tÒ. vÓ.r   c                 ól  •— t         ‰| �  «        t        «       }| j                  «       D ]g  }|D ]`  }|j	                  d«       |j                  | j                  «       |j                  «       |vsŒB|j                  |j                  «       «       Œb Œi |D ]  }|j                  j                  «        Œ y r9  )rv   r²  Úsetr¡  Úset_visibler3  r   Ú
get_figureÚaddrž  rý  )r'   Úfigsr„  r5  rQ   rz   s        €r   r²  zArtistAnimation._init_drawê  s£   ø€ Ü‰ÑÔä‹uˆØ×#Ñ#Ó%ò 	2ˆAØò 2�Ø×"Ñ" 5Ô)Ø×#Ñ# D§J¡JÔ/à×$Ñ$Ó&¨dÒ2Ø—H‘H˜V×.Ñ.Ó0Õ1ñ2ð	2ð ò 	#ˆCØ�J‰J× Ñ Õ"ñ	#r   c                 ó„   — |r| j                  | j                  «       y| j                  D ]  }|j                  d«       Œ y)z#Clears artists from the last frame.FN)rø  rù  rI  )r'   rì  rª  r5  s       r   rò  zArtistAnimation._pre_drawú  s>   € áà×Ñ˜T×0Ñ0Õ1ð ×-Ñ-ò *�Ø×"Ñ" 5Õ)ñ*r   c                 óB   — || _         |D ]  }|j                  d«       Œ y rÙ   )rù  rI  )r'   r  r5  s      r   ró  zArtistAnimation._draw_frame  s+   € ð &ˆÔð ò 	%ˆFØ×Ñ˜tÕ$ñ	%r   )	r=   r>   r?   r@   r(   r²  rò  ró  r³   r´   s   @r   rE  rE  Á  s   ø„ ñô>/ô#ò *ö%r   rE  c                   óJ   ‡ — e Zd ZdZ	 	 d	ddœˆ fd„Zd„ Zd„ Zˆ fd„Zd„ Zˆ xZ	S )
ÚFuncAnimationa?  
    `TimedAnimation` subclass that makes an animation by repeatedly calling
    a function *func*.

    .. note::

        You must store the created Animation in a variable that lives as long
        as the animation should run. Otherwise, the Animation object will be
        garbage-collected and the animation stops.

    Parameters
    ----------
    fig : `~matplotlib.figure.Figure`
        The figure object used to get needed events, such as draw or resize.

    func : callable
        The function to call at each frame.  The first argument will
        be the next value in *frames*.   Any additional positional
        arguments can be supplied using `functools.partial` or via the *fargs*
        parameter.

        The required signature is::

            def func(frame, *fargs) -> iterable_of_artists

        It is often more convenient to provide the arguments using
        `functools.partial`. In this way it is also possible to pass keyword
        arguments. To pass a function with both positional and keyword
        arguments, set all arguments as keyword arguments, just leaving the
        *frame* argument unset::

            def func(frame, art, *, y=None):
                ...

            ani = FuncAnimation(fig, partial(func, art=ln, y='foo'))

        If ``blit == True``, *func* must return an iterable of all artists
        that were modified or created. This information is used by the blitting
        algorithm to determine which parts of the figure have to be updated.
        The return value is unused if ``blit == False`` and may be omitted in
        that case.

    frames : iterable, int, generator function, or None, optional
        Source of data to pass *func* and each frame of the animation

        - If an iterable, then simply use the values provided.  If the
          iterable has a length, it will override the *save_count* kwarg.

        - If an integer, then equivalent to passing ``range(frames)``

        - If a generator function, then must have the signature::

             def gen_function() -> obj

        - If *None*, then equivalent to passing ``itertools.count``.

        In all of these cases, the values in *frames* is simply passed through
        to the user-supplied *func* and thus can be of any type.

    init_func : callable, optional
        A function used to draw a clear frame. If not given, the results of
        drawing from the first item in the frames sequence will be used. This
        function will be called once before the first frame.

        The required signature is::

            def init_func() -> iterable_of_artists

        If ``blit == True``, *init_func* must return an iterable of artists
        to be re-drawn. This information is used by the blitting algorithm to
        determine which parts of the figure have to be updated.  The return
        value is unused if ``blit == False`` and may be omitted in that case.

    fargs : tuple or None, optional
        Additional arguments to pass to each call to *func*. Note: the use of
        `functools.partial` is preferred over *fargs*. See *func* for details.

    save_count : int, optional
        Fallback for the number of values from *frames* to cache. This is
        only used if the number of frames cannot be inferred from *frames*,
        i.e. when it's an iterator without length or a generator.

    interval : int, default: 200
        Delay between frames in milliseconds.

    repeat_delay : int, default: 0
        The delay in milliseconds between consecutive animation runs, if
        *repeat* is True.

    repeat : bool, default: True
        Whether the animation repeats when the sequence of frames is completed.

    blit : bool, default: False
        Whether blitting is used to optimize drawing.  Note: when using
        blitting, any animated artists will be drawn according to their zorder;
        however, they will be drawn on top of any previous artists, regardless
        of their zorder.

    cache_frame_data : bool, default: True
        Whether frame data is cached.  Disabling cache might be helpful when
        frames contain large objects.
    T)Úcache_frame_datac                óÂ  •‡ ‡— |r|‰ _         nd‰ _         |‰ _        |‰ _        |‰ _        ‰€t        j
                  ‰ _        nÍt        ‰«      r‰‰ _        nºt        j                  ‰«      rv|j                  dd«      r‰‰ _        ‰fˆ fd„	}	|	‰ _        n
ˆfd„‰ _        t        ‰d«      rgt        ‰«      ‰ _        |�Ut        j                  d|›dt        ‰«      ›d	�«       n/ˆfd
„‰ _        ‰‰ _        |�t        j                  d|›d‰›d	�«       ‰ j                  € |rt        j                  d‰›d|›d�«       d}|‰ _        g ‰ _        t%        ‰
‰ �L  |fi |¤Ž g ‰ _        y )Nr.   r@  Tc              3   óv   •K  — t        j                  ‰j                  d«      \  }‰_        |E d {  –—†  y 7 Œ­w)Nr}   )Ú	itertoolsÚteeÚ	_tee_from)ÚframesÚthisr'   s     €r   Úiter_framesz+FuncAnimation.__init__.<locals>.iter_framesŽ  s)   øè ø€ Ü+4¯=©=¸¿¹ÈÓ+KÑ(�D˜$œ.Ø#—O’Oús   ƒ.9±7²9c                  ó   •— t        ‰ «      S r#   )rî  ©rW  s   €r   rL  z(FuncAnimation.__init__.<locals>.<lambda>“  s   ø€ ¬¨f«€ r   Ú__len__z%You passed in an explicit save_count=z0 which is being ignored in favor of len(frames)=ú.c                  ó,   •— t        t        ‰ «      «      S r#   )rî  Úranger[  s   €r   rL  z(FuncAnimation.__init__.<locals>.<lambda>�  s   ø€ ¤T¬%°«-Ó%8€ r   z+ which is being ignored in favor of frames=zframes=ze which we can infer the length of, did not pass an explicit *save_count* and passed cache_frame_data=z§.  To avoid a possibly unbounded cache, frame data caching has been disabled. To suppress this warning either pass `cache_frame_data=False` or `save_count=MAX_FRAMES`.F)r�   Ú_funcÚ
_init_funcrÓ  rT  ÚcountÚ	_iter_genÚcallabler   ÚiterablerÙ  rV  rÁ   rƒ  r   rÇ   Ú_cache_frame_dataÚ	_save_seqrv   r(   )r'   rQ   ÚfuncrW  Ú	init_funcÚfargsÚ
save_countrQ  rh   rY  rz   s   `  `      €r   r(   zFuncAnimation.__init__u  s{  ú€ áØˆD�JàˆDŒJØˆŒ
Ø#ˆŒð
 &ˆÔð ˆ>Ü&Ÿ_™_ˆD�NÜ�fÔØ#ˆD�NÜ�[‰[˜Ô Ø�z‰z˜( DÔ)Ø!'�”Ø'-õ $ð "-�•ã!5�”Ü�v˜yÔ)Ü#& v£;�Ô ØÐ)Ü×&Ñ&Ø@°Z°Mð B(ä˜v›;˜.¨ð+õó 9ˆDŒNØ%ˆDÔØÐ%Ü×"Ñ"Ø<°°ð >3Ø+1¨)°1ð6ôð ×ÑÐ#Ñ(8Ü×ÑØ�6�+ð 0à.Ð0ð 1GðGôð  %Ðà!1ˆÔð ˆŒä‰Ñ˜Ñ' Ò'ð ˆ�r   c                 ó"   — | j                  «       S r#   )rc  r&   s    r   r¡  zFuncAnimation.new_frame_seqº  s   € à�~‰~ÓÐr   c                 ó&  ‡— | j                   r/t        | j                   «      | _        t        | j                  «      S | j                  €| j                  «       Šˆfd„} |«       S t        j                  | j                  «       | j                  «      S )Nc               3   óJ   •K  — 	 	 t        ‰ «      –— Œ# t        $ r Y y w xY w­wr#   )rê  rë  )r¢  s   €r   Úgenz.FuncAnimation.new_saved_frame_seq.<locals>.genË  s/   øè ø€ ðØ"Ü"& y£/Ò1ð #øä(ò Ùðüs   ƒ#… ”	 �#Ÿ  #)rg  r9   Ú_old_saved_seqrî  rÓ  r¡  rT  Úislice)r'   ro  r¢  s     @r   rÝ  z!FuncAnimation.new_saved_frame_seq¾  sz   ø€ ð �>Š>ô #' t§~¡~Ó"6ˆDÔÜ˜×+Ñ+Ó,Ð,à×ÑÐ'Ø ×.Ñ.Ó0�	ôñ “u�ä ×'Ñ'¨×(:Ñ(:Ó(<¸d×>NÑ>NÓOÐOr   c                 ó¾  •— t         ‰| �  «        | j                  €3	 t        | j	                  «       «      }| j                  |«       g | _        y | j                  «       | _	        | j                  rC| j                  €t        d«      ‚| j                  D ]  }|j                  | j                  «       Œ g | _        y # t
        $ r t        j                  d«       Y y w xY w)NzÙCan not start iterating the frames for the initial draw. This can be caused by passing in a 0 length sequence for *frames*.

If you passed *frames* as a generator it may be exhausted due to a previous display or save.z7The init_func must return a sequence of Artist objects.)rv   r²  ra  rê  r¡  rë  r­  r®  ró  rù  r   r;   r3  rg  )r'   rZ  rÌ  rz   s      €r   r²  zFuncAnimation._init_drawÕ  sÚ   ø€ Ü‰ÑÔð
 �?‰?Ð"ðÜ! $×"4Ñ"4Ó"6Ó7�
ð ×Ñ˜ZÔ(ð ˆ�ð #'§/¡/Ó"3ˆDÔØ�zŠzØ×&Ñ&Ð.Ü&ð (Eó Fð Fà×,Ñ,ò /�AØ—N‘N 4§:¡:Õ.ð/àˆ�øô+ !ò ô —‘ðMôñ ðús   �B; Â;CÃCc                 óP  — | j                   r:| j                  j                  |«       | j                  | j                   d  | _         | j                  |g| j
                  ¢­Ž | _        | j                  r¢t        d«      }	 t        | j                  «       | j                  D ](  }t        |t        j                  j                  «      rŒ(|‚ t        | j                  d„ ¬«      | _        | j                  D ]  }|j!                  | j                  «       Œ y y # t        $ r |d ‚w xY w)Nz@The animation function must return a sequence of Artist objects.c                 ó"   — | j                  «       S r#   )Ú
get_zorder)r   s    r   rL  z+FuncAnimation._draw_frame.<locals>.<lambda>  s   € °q·|±|³~€ r   )Úkey)rf  rg  rÍ   rÓ  r`  r�   rù  r   r;   rî  ru   rÔ  rG   r5  ÚArtistÚsortedr3  )r'   rì  r¡   rY  rÌ  s        r   ró  zFuncAnimation._draw_frameõ  s  € Ø×!Ò!à�N‰N×!Ñ! )Ô,Ø!Ÿ^™^¨T×-=Ñ-=Ð,=Ð,>Ð?ˆDŒNð )˜dŸj™j¨Ð@°T·Z±ZÒ@ˆÔà�:Š:äð  4ó 5ˆCð$ä�T×(Ñ(Ô)ð
 ×(Ñ(ò �Ü! !¤S§Z¡Z×%6Ñ%6Õ7Ø�Iðô #)¨×)<Ñ)<Ù-Eô#GˆDÔð ×(Ñ(ò +�Ø—‘˜tŸz™zÕ*ñ+ð% øô ò $Ø˜tÐ#ð$ús   ÂD ÄD%)NNNN)
r=   r>   r?   r@   r(   r¡  rÝ  r²  ró  r³   r´   s   @r   rP  rP    s:   ø„ ñeðL FJØ ðCØ6:öCòJ òPô.ö@+r   rP  c                 ó¢   — t         j                  d   dk(  r t        dt         j                  d   ›d�«      ‚dD ]  }|| v sŒt        d|›�«      ‚ y )Nra   rb   zmpl.rcParams['savefig.bbox']=z^ must not be 'tight' as it may cause frame size to vary, which is inappropriate for animation.)r   rÃ  r¤   z.grab_frame got an unexpected keyword argument )rG   rc   Ú
ValueErrorru   )rZ   r  s     r   r¥   r¥     sm   € Ü
‡|�|�NÑ# wÒ.ÜØ,Œs�|‰|˜NÑ+Ð-ð .Rð Ró
ð 	
ð .ò ˆØ�ÒÜØ@ÀÀÐFóð ñr   )>rk   r  rn   Úior   r   rT  rœ   Úpathlibr   r°   r‘   ÚsysÚtempfiler   r‘  r­  Únumpyr   ÚPILr   Ú
matplotlibrG   Úmatplotlib._animation_datar   r	   r
   r   r   r   Úmatplotlib.colorsÚcolorsrÅ  Ú	getLoggerr=   rd   ÚplatformÚCREATE_NO_WINDOWr”   r   r!   rÖ  ÚABCrB   rq   r¶   r/   r×   rò   r!  r-  r3  rF  rJ  rQ  r`  rc  r˜  r;  rE  rP  r¥   r.   r   r   ú<module>r‰     s  ðÛ 
Û Û ß %Û Û Ý Û Û Û 
Ý 'Û Û ã Ý ã ÷Bó Bç "Ý #à€w×Ñ˜Ó"€ð
 $'§<¡<°7Ò#:€J×ÒÀð ò!J÷H5Lñ 5Lñp Ó
€ôc˜#Ÿ'™'ô côLN8Ð%ô N8ôbd'�kô d'ðN 	×Ñ�(Óô3Ð&ó 3ó ð3÷F:+ñ :+ð| 	×Ñ�(Óô�:˜{ó ó ðð6 	×Ñ�-Ó ô ;�z ?ó  ;ó !ð ;÷H.ñ .ðd 	×Ñ�-Ó ô˜¨ó ó !ðð 	×ÑÐ$Ó%ô
A˜O¨_ó 
Aó &ð
Aò=ò4ð 	×Ñ�&Óôi#�ó i#ó ði#÷Xl*ñ l*ô^B�Yô BôJJ%�nô J%ôZD+�Nô D+óN
r   