ó
    {ñ:iš ã                   ó¶  • S SK r S SKrS SKrS SKJrJr  S SKrS SKrS SKJ	r	  S SK
r
S SKrS SKrS SKJr  S SKrS SKrS SKrS SKJr  S SKrS SKJrJrJrJr  S SKJrJr  S SKJr   \RB                  " \"5      r#\RH                  S:X  a  \RJ                  OS r&S	 r' " S
 S5      r(\(" 5       r) " S S\ RT                  5      r+ " S S\+5      r, " S S\,5      r-\)R]                  S5       " S S\+5      5       r/ " S S5      r0\)R]                  S5       " S S\0\,5      5       r1\)R]                  S5       " S S\0\-5      5       r2 " S S5      r3\)R]                  S5       " S  S!\3\,5      5       r4\)R]                  S"5       " S# S$\3\-5      5       r5S% r6S& r7\)R]                  S'5       " S( S)\-5      5       r8 " S* S+5      r9 " S, S-\95      r: " S. S/\:5      r; " S0 S1\:5      r<S2 r=g)3é    N)ÚBytesIOÚTextIOWrapper)ÚPath)ÚTemporaryDirectory)ÚImage)ÚDISPLAY_TEMPLATEÚINCLUDED_FRAMESÚ
JS_INCLUDEÚSTYLE_INCLUDE)Ú_apiÚcbookÚwin32c                 ó„   • S n[        X-  U-  5      U-  U-  n[        X-  U-  5      U-  U-  nU" XRU5      U" XbU5      4$ )zô
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                 óª  • [        X-  5      U-  S:w  a¾  [        [        R                  " U [        R                  5      U-  5      U-  S:X  a'  [        R                  " U [        R                  5      n U $ [        [        R                  " U [        R                  * 5      U-  5      U-  S:X  a&  [        R                  " U [        R                  * 5      n U $ )Nr   )ÚintÚnpÚ	nextafterÚinf)ÚxÚdpiÚns      ÚW/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/matplotlib/animation.pyÚcorrect_roundoffÚ*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        sW   € ò.ô ˆq‰w˜‰{Ó˜aÑ #Ñ%€DÜˆq‰w˜‰{Ó˜aÑ #Ñ%€DÙ˜D qÓ)Ñ+;¸DÀqÓ+IÐIÐIr   c                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚMovieWriterRegistryéD   z<Registry of available writer classes by human readable name.c                 ó"   • [        5       U l        g ©N)ÚdictÚ_registered©Úselfs    r   Ú__init__ÚMovieWriterRegistry.__init__G   s   € Ü›6ˆÕr   c                 ó   ^ ^• UU 4S jnU$ )zz
Decorator for registering a class under a name.

Example use::

    @registry.register(name)
    class Foo:
        pass
c                 ó&   >• U TR                   T'   U $ r%   ©r'   )Ú
writer_clsÚnamer)   s    €€r   ÚwrapperÚ-MovieWriterRegistry.register.<locals>.wrapperT   s   ø€ Ø%/ˆD×Ñ˜TÑ"ØÐr   © )r)   r0   r1   s   `` r   ÚregisterÚMovieWriterRegistry.registerJ   s   ù€ ö	ð ˆr   c                 ób   •  U R                   U   nUR                  5       $ ! [         a     gf = f)ze
Check if given writer is available by name.

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

Returns
-------
bool
F)r'   ÚKeyErrorÚisAvailable)r)   r0   Úclss      r   Úis_availableÚ MovieWriterRegistry.is_availableY   s:   € ð	Ø×"Ñ" 4Ñ(ˆCð �‰Ó Ð øô ó 	Ùð	ús   ‚! ¡
.­.c              #   ój   #   • U R                    H  nU R                  U5      (       d  M  Uv •  M!     g7f)z-Iterate over names of available writer class.N)r'   r:   ©r)   r0   s     r   Ú__iter__ÚMovieWriterRegistry.__iter__k   s+   é € à×$Ô$ˆDØ× Ñ  ×&Ó&Ø”
ò %ùs   ‚$3ª	3c                 ó
   • / U Q$ )z%Get a list of available MovieWriters.r3   r(   s    r   ÚlistÚMovieWriterRegistry.listq   s   € à�ˆwˆr   c                 ój   • U R                  U5      (       a  U R                  U   $ [        SU S35      e)z,Get an available writer class from its name.zRequested MovieWriter (z) not available)r:   r'   ÚRuntimeErrorr=   s     r   Ú__getitem__ÚMovieWriterRegistry.__getitem__u   s9   € à×Ñ˜T×"Ñ"Ø×#Ñ# DÑ)Ð)ÜÐ4°T°F¸/ÐJÓKÐKr   r.   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r*   r4   r:   r>   rA   rE   Ú__static_attributes__r3   r   r   r"   r"   D   s$   † ÙFò"òò!ò$òõLr   r"   c                   óÌ   • \ rS rSrSrSS jr\R                  SS j5       r\	S 5       r
S r\R                  S 5       r\R                  S	 5       r\R                  S
 5       rSrg)ÚAbstractMovieWriteré   al  
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                 ó˜   • Xl         Ub  UO0 U l        [        R                  " US5      U l        [        R                  " US5      U l        g )Nzanimation.codecúanimation.bitrate)ÚfpsÚmetadataÚmplÚ
_val_or_rcÚcodecÚbitrate)r)   rR   rS   rV   rW   s        r   r*   ÚAbstractMovieWriter.__init__’   s;   € ØŒØ$,Ñ$8™¸bˆŒÜ—^’^ EÐ+<Ó=ˆŒ
Ü—~’~ gÐ/BÓCˆ�r   c                 óž   • [        U5      R                  R                  SS9  X l        Xl        Uc  U R                  R
                  nX0l        g)ag  
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)   r_   r^   r   s       r   ÚsetupÚAbstractMovieWriter.setup˜   s@   € ô  	ˆW‹×Ñ×$Ñ$¨DÐ$Ñ1ØŒØŒØ‰;Ø—(‘(—,‘,ˆCØ�r   c                 ó–   • U R                   R                  5       u  p[        XR                  -  5      [        X R                  -  5      4$ )z7A tuple ``(width, height)`` in pixels of a movie frame.)r_   Úget_size_inchesr   r   )r)   r   r   s      r   Ú
frame_sizeÚAbstractMovieWriter.frame_size¯   s9   € ð �x‰x×'Ñ'Ó)‰ˆÜ�1—x‘x‘<Ó ¤# a¯(©(¡lÓ"3Ð3Ð3r   c                 ó   • g)zz
Whether this writer supports transparency.

Writers may consult output file type and codec to determine this at runtime.
Fr3   r(   s    r   Ú_supports_transparencyÚ*AbstractMovieWriter._supports_transparencyµ   s   € ð r   c                 ó   • g)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.
Nr3   ©r)   Úsavefig_kwargss     r   Ú
grab_frameÚAbstractMovieWriter.grab_frame½   ó   � r   c                 ó   • g)ú,Finish any processing for writing the movie.Nr3   r(   s    r   ÚfinishÚAbstractMovieWriter.finishÌ   rn   r   c              /   óL  #   • [         R                  S   S:X  a  [        R                  S5        U R                  " XU/UQ70 UD6  [         R
                  " SS05          U v •  U R                  5          SSS5        g! U R                  5         f = f! , (       d  f       g= f7f)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)rT   ÚrcParamsÚ_logÚinfor`   Ú
rc_contextrq   )r)   r_   r^   r   ÚargsÚkwargss         r   ÚsavingÚAbstractMovieWriter.savingÐ   s„   é € ô �<‰<˜Ñ'¨7Ó2Ü�I‰Ið #ô $ð
 	�
Š
�3 Ð6 tÒ6¨vÒ6Ü�^Š^˜^¨TÐ2Õ3ðØ’
à—‘•÷	 4Ð3øð —‘•ú÷	 4Õ3üs6   ‚AB$ÁBÁ A>Á$BÁ5	B$Á>BÂBÂ
B!ÂB$)rW   rV   r   r_   rR   rS   r^   )é   NNNr%   )rG   rH   rI   rJ   rK   r*   ÚabcÚabstractmethodr`   Úpropertyrd   rg   rl   rq   Ú
contextlibÚcontextmanagerr|   rL   r3   r   r   rN   rN      sŽ   † ñô$Dð 	×Ñóó ðð, ñ4ó ð4ò
ð 	×Ññó ðð 	×Ññ;ó ð;ð ×Ññó ór   rN   c                   óˆ   ^ • \ rS rSrSrS/r  SU 4S jjrS rSU 4S jjrS r	S r
S	 rS
 r\S 5       r\S 5       rSrU =r$ )ÚMovieWriteréå   a¯  
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                 ó’   >• [        U 5      [        L a  [        S5      e[        TU ]  XUUS9  U R
                  S   U l        X@l        g)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.)rR   rS   rV   rW   r   N)Útyper…   Ú	TypeErrorÚsuperr*   Úsupported_formatsÚframe_formatÚ
extra_args)r)   rR   rV   rW   rŽ   rS   Ú	__class__s         €r   r*   ÚMovieWriter.__init__   sX   ø€ ô. �‹:œÒ$ô
 ð%ó&ð &ô 	‰Ñ˜S¸5Ø!(ð 	ñ 	*à ×2Ñ2°1Ñ5ˆÔØ$�r   c                 ó€  • U R                   S:X  ao  U R                  R                  5       u  p[        XU R                  S5      u  p4X4X44:w  a1  U R                  R                  X4SS9  [        R                  SXX45        OU R                  R                  5       u  p4[        R                  " S/U R                  Q76   X44$ )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)
rV   r_   rc   r    r   Úset_size_inchesrw   rx   Údebugrd   )r)   ÚwoÚhor   r   s        r   Ú_adjust_frame_sizeÚMovieWriter._adjust_frame_size%  s¤   € Ø�:‰:˜ÓØ—X‘X×-Ñ-Ó/‰FˆBÜ# B¨D¯H©H°aÓ8‰DˆAØˆx˜A˜6Ó!Ø—‘×(Ñ(¨°tÐ(Ñ<Ü—	‘	ð 4Ø57¸QôCøð —8‘8×+Ñ+Ó-‰DˆAÜ�
Š
Ð4ÐG°t·±ÓGØˆtˆr   c                 ó|   >• [         TU ]  XUS9  U R                  5       u  U l        U l        U R                  5         g ©N)r   )r‹   r`   r™   Ú_wÚ_hÚ_run©r)   r_   r^   r   r�   s       €r   r`   ÚMovieWriter.setup2  s5   ø€ ä‰‰�c¨ˆÑ,Ø×2Ñ2Ó4ÑˆŒ�”ð 	�	‰	�r   c                 óÖ   • U R                  5       n[        R                  S[        R                  " U5      5        [
        R                  n[
        R                  " XX"[        S9U l	        g )Nz%MovieWriter._run: running command: %s)ÚstdinÚstdoutÚstderrÚcreationflags)
Ú_argsrw   rx   r   Ú_pformat_subprocessÚ
subprocessÚPIPEÚPopenÚsubprocess_creation_flagsÚ_proc)r)   Úcommandrª   s      r   rŸ   ÚMovieWriter._run:  sO   € ð —*‘*“,ˆÜ�	‰	Ð9Ü×+Ò+¨GÓ4ô	6ä�‰ˆÜ×%Ò%Ø¨Ü3ñ5ˆ�
r   c                 óÖ  • U R                   R                  5       u  p[        [        U5      5      R	                  5       n[        [        U5      5      R	                  5       nU(       aP  [
        R                  U R                   R                  (       a  [        R                  O[        R                  SU5        U(       aP  [
        R                  U R                   R                  (       a  [        R                  O[        R                  SU5        U R                   R                  (       a@  [        R                  " U R                   R                  U R                   R                  X5      eg)rp   zMovieWriter stdout:
%szMovieWriter stderr:
%sN)r­   Úcommunicater   r   Úreadrw   ÚlogÚ
returncodeÚloggingÚWARNINGÚDEBUGr©   ÚCalledProcessErrorrz   )r)   ÚoutÚerrs      r   rq   ÚMovieWriter.finishF  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§¡¸óBð Bð !r   c                 ó4  • [        U5        [        R                  S5        U R                  R	                  U R
                  U R                  5        U R                  R                  " U R                  R                  4U R                  U R                  S.UD6  g )Nz'MovieWriter.grab_frame: Grabbing frame.©Úformatr   )Ú_validate_grabframe_kwargsrw   r–   r_   r•   r�   rž   Úsavefigr­   r£   r�   r   rj   s     r   rl   ÚMovieWriter.grab_frameX  so   € ä" >Ô2Ü�
‰
Ð<Ô=ð 	�‰× Ñ  §¡¨$¯'©'Ô2à�‰×Ò˜Ÿ™×)Ñ)ð 	9°$×2CÑ2CØ!ŸX™Xñ	9Ø)7ó	9r   c                 ó   • [        S5      $ )z9Assemble list of encoder-specific command-line arguments.z)args needs to be implemented by subclass.©ÚNotImplementedErrorr(   s    r   r§   ÚMovieWriter._argsc  s   € ä"Ð#NÓOÐOr   c                 óN   • [        [        R                  U R                     5      $ )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.
)ÚstrrT   rv   Ú	_exec_key©r9   s    r   Úbin_pathÚMovieWriter.bin_pathg  s   € ô ”3—<‘< §¡Ñ.Ó/Ð/r   c                 óN   • [         R                  " U R                  5       5      SL$ )z<Return whether a MovieWriter subclass is actually available.N)ÚshutilÚwhichrÊ   rÉ   s    r   r8   ÚMovieWriter.isAvailablep  s   € ô �|Š|˜CŸL™L›NÓ+°4Ð7Ð7r   )rž   r­   r�   rŽ   r�   )r~   NNNNr%   )rG   rH   rI   rJ   rK   rŒ   r*   r™   r`   rŸ   rq   rl   r§   ÚclassmethodrÊ   r8   rL   Ú__classcell__©r�   s   @r   r…   r…   å   sf   ø† ñð0  ˜ÐàCGØ÷#%òJ÷ò
5òBò$	9òPð ñ0ó ð0ð ñ8ó ö8r   r…   c                   óˆ   ^ • \ rS rSrSrU 4S jrSS jrS r\S 5       r	\	R                  S 5       r	S rS	 rU 4S
 jrSrU =r$ )ÚFileMovieWriteriv  zq
`MovieWriter` for writing to individual files and stitching at the end.

This must be sub-classed to be useful.
c                 óV   >• [         TU ]  " U0 UD6  [        R                  S   U l        g )Nzanimation.frame_format)r‹   r*   rT   rv   r�   )r)   rz   r{   r�   s      €r   r*   ÚFileMovieWriter.__init__|  s'   ø€ Ü‰Ò˜$Ð) &Ò)ÜŸL™LÐ)AÑBˆÕr   c                 ó”  • [        U5      R                  R                  SS9  Xl        X l        Uc  U R                  R
                  nX0l        U R                  5         Uc>  [        5       U l        [        [        U R                  R                  S5      5      U l        OSU l        X@l        SU l        [        5       U l        SU l        g)aS  
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.
TrZ   NÚtmpr   z
%s%%07d.%s)r   r\   r]   r_   r^   r   r™   r   Ú_tmpdirrÇ   r0   Útemp_prefixÚ_frame_counterrA   Ú_temp_pathsÚfname_format_str)r)   r_   r^   r   Úframe_prefixs        r   r`   ÚFileMovieWriter.setup€  s¡   € ô( 	ˆW‹×Ñ×$Ñ$¨DÐ$Ñ1ØŒØŒØ‰;Ø—(‘(—,‘,ˆCØŒØ×ÑÔ!àÑÜ-Ó/ˆDŒLÜ"¤4¨¯©×(9Ñ(9¸5Ó#AÓBˆDÕàˆDŒLØ+ÔØˆÔÜ›6ˆÔØ ,ˆÕr   c                 ó€   • [        U S5      (       a-  U R                  (       a  U R                  R                  5         g g g )NrÙ   )ÚhasattrrÙ   Úcleanupr(   s    r   Ú__del__ÚFileMovieWriter.__del__¦  s-   € Ü�4˜×#Ñ#¨¯¯Ø�L‰L× Ñ Õ"ð )5Ð#r   c                 ó   • U R                   $ )zk
Format (png, jpeg, etc.) to use for saving the frames, which can be
decided by the individual subclasses.
)Ú_frame_formatr(   s    r   r�   ÚFileMovieWriter.frame_formatª  s   € ð ×!Ñ!Ð!r   c           	      óÚ   • XR                   ;   a  Xl        g [        R                  " SU< S[	        U 5      R
                   SU R                   S    S35        U R                   S   U l        g )NzIgnoring file format z which is not supported by z; using r   z	 instead.)rŒ   ræ   r   Úwarn_externalr‰   rG   )r)   r�   s     r   r�   rç   ²  sn   € à×1Ñ1Ó1Ø!-Õä×ÒØ'¨Ñ'7ð 8 Ü $ T£
× 3Ñ 3Ð4°HØ×)Ñ)¨!Ñ,Ð-¨Yð8ô9ð "&×!7Ñ!7¸Ñ!:ˆDÕr   c                 óL   • U R                   U R                  U R                  4-  $ r%   )rÝ   rÚ   r�   r(   s    r   Ú_base_temp_nameÚFileMovieWriter._base_temp_name½  s&   € ð ×$Ñ$¨×(8Ñ(8¸$×:KÑ:KÐ'LÑLÐLr   c                 ó¼  • [        U5        [        U R                  5       U R                  -  5      nU R                  R                  U5        U =R                  S-  sl        [        R                  SU R                  U5        [        US5       nU R                  R                  " U4U R                  U R                  S.UD6  S S S 5        g ! , (       d  f       g = f)Né   z8FileMovieWriter.grab_frame: Grabbing frame %d to path=%sÚwbr½   )r¿   r   rë   rÛ   rÜ   Úappendrw   r–   Úopenr_   rÀ   r�   r   )r)   rk   ÚpathÚsinks       r   rl   ÚFileMovieWriter.grab_frameÂ  s°   € ô 	# >Ô2Ü�D×(Ñ(Ó*¨T×-@Ñ-@Ñ@ÓAˆØ×Ñ×Ñ Ô%Ø×Ò˜qÑ ÕÜ�
‰
ÐMØ×&Ñ&¨ô	.ä�$˜Ô Ø�H‰H×Ò˜Tð /¨$×*;Ñ*;ÀÇÁñ /Ø-ò/÷ ×Öús   Â5CÃ
Cc                 ó~  >•  U R                  5         [        TU ]	  5         U R                  (       a;  [        R                  SU R                  5        U R                  R                  5         g g ! U R                  (       a;  [        R                  SU R                  5        U R                  R                  5         f f = f)Nú'MovieWriter: clearing temporary path=%s)rŸ   r‹   rq   rÙ   rw   r–   râ   )r)   r�   s    €r   rq   ÚFileMovieWriter.finishÏ  s‚   ø€ ð	'Ø�I‰IŒKÜ‰G‰NÔà�|�|Ü—
‘
Ø=¸t¿|¹|ôð —‘×$Ñ$Õ&ð	 øˆt�|�|Ü—
‘
Ø=¸t¿|¹|ôð —‘×$Ñ$Õ&ð	 ús   ƒA. Á.AB<)
rÛ   ræ   rÜ   rÙ   r   r_   rÝ   r�   r^   rÚ   ©NN)rG   rH   rI   rJ   rK   r*   r`   rã   r�   r�   Úsetterrë   rl   rq   rL   rÑ   rÒ   s   @r   rÔ   rÔ   v  s\   ø† ñõ
Cô$-òL#ð ñ"ó ð"ð ×Ññ;ó ð;òMò
/÷'ó 'r   rÔ   Úpillowc                   óN   ^ • \ rS rSrS r\S 5       rSU 4S jjrS rS r	Sr
U =r$ )	ÚPillowWriteriÝ  c                 ó   • g©NTr3   r(   s    r   rg   Ú#PillowWriter._supports_transparencyß  s   € Ør   c                 ó   • grþ   r3   rÉ   s    r   r8   ÚPillowWriter.isAvailableâ  ó   € àr   c                 ó0   >• [         TU ]  XUS9  / U l        g rœ   )r‹   r`   Ú_framesr    s       €r   r`   ÚPillowWriter.setupæ  s   ø€ Ü‰‰�c¨ˆÑ,Øˆ�r   c           	      ó²  • [        U5        [        5       nU R                  R                  " U40 0 UESU R                  S.ED6  [
        R                  " SU R                  UR                  5       SSSS5      nUR                  5       S   S   S:  a  U R                  R                  U5        g U R                  R                  UR                  S	5      5        g )
Nr‡   r½   ÚRGBAÚrawr   rî   é   éÿ   ÚRGB)r¿   r   r_   rÀ   r   r   Ú
frombufferrd   Ú	getbufferÚ
getextremar  rð   Úconvert)r)   rk   ÚbufÚims       r   rl   Ú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           	      óž   • U R                   S   R                  U R                  SU R                   SS  [        SU R                  -  5      SS9  g )Nr   Trî   éè  )Úsave_allÚappend_imagesÚdurationÚloop)r  Úsaver^   r   rR   r(   s    r   rq   ÚPillowWriter.finishù  sE   € Ø�‰�Q‰×ÑØ�L‰L 4°t·|±|ÀAÀBÐ7GÜ˜ §¡™Ó)°ð 	ò 	3r   )r  r%   )rG   rH   rI   rJ   rg   rÐ   r8   r`   rl   rq   rL   rÑ   rÒ   s   @r   rü   rü   Ý  s0   ø† òð ñó ð÷ò3÷3ð 3r   rü   c                   ó6   • \ rS rSrSrSrSrS r\S 5       r	Sr
g)	Ú
FFMpegBasei  zv
Mixin class for FFMpeg output.

This is a base class for the concrete `FFMpegWriter` and `FFMpegFileWriter`
classes.
zanimation.ffmpeg_pathzanimation.ffmpeg_argsc                 ól   • [        U R                  5      R                  nUS;   a  gU R                  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   r^   ÚsuffixrV   ©r)   r9  s     r   rg   Ú!FFMpegBase._supports_transparency  s:   € Ü�d—l‘lÓ#×*Ñ*ˆØÐAÓAØð �z‰zð >ñ >ð 	>r   c                 ó   • / n[        U R                  5      R                  nUS;   a  USS  U l        OUR	                  SU R                  /5        U R
                  b  U R
                  O[        R                  U R                     nU R                  S:X  a  SU;  a  UR	                  SS/5        OSU R                  S:X  a  SU;  a  UR	                  SS	/5        O)U R                  S
:X  a  SU;  a  UR	                  / SQ5        U R                  S:”  a   UR	                  SSU R                  -  /5        U R                  R                  5        H  u  pEUR	                  SU SU 3/5        M     UR	                  U5        USU R                  /-   $ )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]rB  z[alpha]r   z-bz%dkz	-metadataÚ=z-y)r   r^   r9  rV   ÚextendrŽ   rT   rv   Ú	_args_keyrW   rS   Úitems)r)   rz   r9  rŽ   ÚkÚvs         r   Úoutput_argsÚFFMpegBase.output_args  sc  € àˆÜ�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×'Ñ'Ö)‰DˆAØ�K‰K˜¨¨¨1¨Q¨C jÐ1Ö2ñ *à�‰�JÔà�t˜TŸ\™\Ð*Ñ*Ð*r   )rV   N)rG   rH   rI   rJ   rK   rÈ   rE  rg   r�   rI  rL   r3   r   r   r  r    s,   † ñð (€IØ'€Iò>ð ñ +ó ó +r   r  Úffmpegc                   ó   • \ rS rSrSrS rSrg)ÚFFMpegWriteri?  a\  
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                 ó  • U R                  5       SSSSSSU R                  -  SU R                  S[        U R                  5      /n[
        R                  5       [        R                  :”  a  USS	/-  nUS
S/U R                  -   -  nU$ )Nú-fr6  r=  z-sú%dx%dr>  ú
-framerateú	-loglevelÚerrorú-izpipe:)
rÊ   rd   r�   rÇ   rR   rw   ÚgetEffectiveLevelrµ   r·   rI  ©r)   rz   s     r   r§   ÚFFMpegWriter._argsK  s…   € ð —‘“  z°9¸jØ�g §¡Ñ/°¸T×=NÑ=NØœc $§(¡(›mð-ˆô ×!Ñ!Ó#¤g§m¡mÓ3Ø�[ 'Ð*Ñ*ˆDØ��w� $×"2Ñ"2Ñ2Ñ2ˆØˆr   r3   N)rG   rH   rI   rJ   rK   r§   rL   r3   r   r   rM  rM  ?  s   † ñ	õr   rM  Úffmpeg_filec                   ó&   • \ rS rSrSr/ SQrS rSrg)ÚFFMpegFileWriteri[  aa  
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  r‡   c           	      óœ  • / nU R                   S;   a  USSSSSSU R                  -  SS	/-  nUS
[        U R                  5      SU R	                  5       /-  nU R
                  (       d  US[        U R                  5      /-  n[        R                  5       [        R                  :”  a  USS/-  nU R                  5       /UQU R                  Q$ )N>   r  r‡   rO  Úimage2r=  r6  z-video_sizerP  z-pixel_formatr‡   rQ  rT  z	-frames:vrR  rS  )r�   rd   rÇ   rR   rë   rÙ   rÛ   rw   rU  rµ   r·   rÊ   rI  rV  s     r   r§   Ú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   r3   N)rG   rH   rI   rJ   rK   rŒ   r§   rL   r3   r   r   rZ  rZ  [  s   † ñ	ò ?Ðõ;r   rZ  c                   ó`   ^ • \ rS rSrSrSrSrS rS r\	U 4S j5       r
\	U 4S j5       rS	rU =r$ )
ÚImageMagickBasei€  zï
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                 óJ   • [        U R                  5      R                  nUS;   $ )Nr  )r   r^   r9  r:  s     r   rg   Ú&ImageMagickBase._supports_transparencyŒ  s"   € Ü�d—l‘lÓ#×*Ñ*ˆØÐEÑEÐEr   c                 ó^  • U R                   S:X  a  SOU R                   nU R                  b  U R                  O[        R                  U R                     nU R                  5       SSU R                  -  SSS[        SU R                  -  5      S	S
U SU R                   3/
UQU R                  P$ )Nr  r‡   z-sizez%ix%iz-depthÚ8z-delayéd   z-loopÚ0Ú:)r�   rŽ   rT   rv   rE  rÊ   rd   rÇ   rR   Úinput_namesr^   )r)   ÚfmtrŽ   s      r   r§   Ú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                 óp   >• [         TU ]  5       nUS:X  a   [        R                  " S5      R                  nU$ )Nr  Úmagick)r‹   rÊ   rT   Ú_get_executable_infoÚ
executable)r9   Úbinpathr�   s     €r   rÊ   ÚImageMagickBase.bin_path   s3   ø€ ä‘'Ñ"Ó$ˆØ�iÓÜ×.Ò.¨xÓ8×CÑCˆGØˆr   c                 ó�   >•  [         TU ]  5       $ ! [        R                   a   n[        R                  SU5         S nAgS nAff = f)Nz"ImageMagick unavailable due to: %sF)r‹   r8   rT   ÚExecutableNotFoundErrorrw   r–   )r9   Ú_enfr�   s     €r   r8   ÚImageMagickBase.isAvailable§  s>   ø€ ð	Ü‘7Ñ&Ó(Ð(øÜ×*Ñ*ó 	ä�J‰JÐ;¸TÔBÜûð	ús   ƒ ‘A¥A Á Ar3   )rG   rH   rI   rJ   rK   rÈ   rE  rg   r§   rÐ   rÊ   r8   rL   rÑ   rÒ   s   @r   ra  ra  €  sG   ø† ñð )€IØ(€IòFò
ð  ôó ðð ôó ör   ra  Úimagemagickc                   ó   • \ rS rSrSrSrSrg)ÚImageMagickWriteri²  zw
Pipe-based animated gif writer.

Frames are streamed directly to ImageMagick via a pipe and written
in a single pass.
Ú-r3   N)rG   rH   rI   rJ   rK   ri  rL   r3   r   r   rx  rx  ²  s   † ñð ƒKr   rx  Úimagemagick_filec                   ó2   • \ rS rSrSr/ SQr\" S 5      rSrg)ÚImageMagickFileWriteri¿  zw
File-based animated gif writer.

Frames are written to temporary files on disk and then stitched
together at the end.
r[  c                 ó8   • U R                    SU R                   3$ )Nz*.)rÚ   r�   r(   s    r   Ú<lambda>ÚImageMagickFileWriter.<lambda>Ê  s   € ˜×(Ñ(Ð)¨¨D×,=Ñ,=Ð+>Ñ?r   r3   N)	rG   rH   rI   rJ   rK   rŒ   r�   ri  rL   r3   r   r   r|  r|  ¿  s   † ñò ?ÐÙÙ?óAƒKr   r|  c                 ó.   • [         R                  " U UUS9$ )N)ÚNframesÚ	frame_dirr�   )r	   r¾   )Úframe_countr�   r‚  s      r   Ú_included_framesr„  Ï  s   € Ü×!Ò!¨+Ø,5Ø/;ñ=ð =r   c                 ój   ^^• TS:X  a  SmSmSSR                  UU4S j[        U 5       5       5      -   $ )z7frame_list should be a list of base64-encoded png filesÚsvgzsvg+xmlz,  frames[{0}] = "data:image/{1};base64,{2}"
Ú
Ú c           	   3   ón   >#   • U  H*  u  pTR                  UTUR                  S S5      5      v •  M,     g7f)r‡  z\
N)r¾   Úreplace)Ú.0ÚiÚ
frame_datar�   Útemplates      €€r   Ú	<genexpr>Ú#_embedded_frames.<locals>.<genexpr>Û  s7   øé € ð 4â2‰MˆAð 	�‰˜˜<¨×);Ñ);¸DÀ&Ó)I×JÐJÚ2ùs   ƒ25)ÚjoinÚ	enumerate)Ú
frame_listr�   rŽ  s    `@r   Ú_embedded_framesr”  Õ  s?   ù€ à�uÓà ˆØ>€HØ�"—'‘'õ 4ä& zÔ2ó4ó 4ñ 4ð 4r   Úhtmlc                   óp   ^ • \ rS rSrSr/ SQr\S 5       r   S
U 4S jjrSU 4S jjr	U 4S jr
S rS	rU =r$ )Ú
HTMLWriterià  z(Writer for JavaScript-based HTML movies.)r'  r\  r,  r†  c                 ó   • grþ   r3   rÉ   s    r   r8   ÚHTMLWriter.isAvailableæ  r  r   c	                 ó>  >• U(       a  [         R                  S5        SnX`l        UR                  5       U l        [
        R                  " / SQU R                  S9  [        R                  " US5      U l	        U =R                  S-  sl	        [        T	U ]-  XX4U5        g )NzHTMLWriter ignores 'extra_args'r3   )r  ÚonceÚreflect)Údefault_modeúanimation.embed_limité   )rw   ÚwarningÚembed_framesÚlowerr�  r   Úcheck_in_listrT   rU   Ú_bytes_limitr‹   r*   )
r)   rR   rV   rW   rŽ   rS   r¡  r�  Úembed_limitr�   s
            €r   r*   ÚHTMLWriter.__init__ê  sƒ   ø€ ö Ü�L‰LÐ:Ô;Øˆ
Ø(ÔØ(×.Ñ.Ó0ˆÔÜ×ÒÒ6Ø(,×(9Ñ(9ò	;ô  ŸNšN¨;Ð8OÓPˆÔà×Ò˜[Ñ(Õä‰Ñ˜ W¸(ÕCr   c                 óJ  >• [        U5      n[        R                  " SS/UR                  S9  / U l        SU l        SU l        U R                  (       d7  Uc  UR                  UR                  S-   5      nUR                  SSS9  US	-  nOS n[        TU ]1  XX55        SU l        g )
Nz.htmlz.htm)Úoutfile_extensionr   Fr  T)ÚparentsÚexist_okÚframe)r   r   r£  r9  Ú_saved_framesÚ_total_bytesÚ
_hit_limitr¡  Ú	with_nameÚstemÚmkdirr‹   r`   Ú_clear_temp)r)   r_   r^   r   r‚  rÞ   r�   s         €r   r`   ÚHTMLWriter.setupý  s™   ø€ Ü�w“-ˆÜ×Ò˜G VÐ,ÀÇÁÒOàˆÔØˆÔØˆŒà× × ØÑ Ø#×-Ñ-¨g¯l©l¸YÑ.FÓG�	Ø�O‰O D°4ˆOÑ8Ø$ wÑ.‰LàˆLä‰‰�c CÔ6Ø ˆÕr   c                 ór  >• [        U5        U R                  (       Ga
  U R                  (       a  g [        5       nU R                  R
                  " U4U R                  U R                  S.UD6  [        R                  " UR                  5       5      R                  S5      nU =R                  [        U5      -  sl        U R                  U R                  :¼  a3  [        R!                  SU R                  U R                  5        SU l        g U R"                  R%                  U5        g [&        TU ]P  " S0 UD6$ )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.Tr3   )r¿   r¡  r®  r   r_   rÀ   r�   r   Úbase64ÚencodebytesÚgetvalueÚdecoder­  Úlenr¤  rw   r   r¬  rð   r‹   rl   )r)   rk   ÚfÚ	imgdata64r�   s       €r   rl   ÚHTMLWriter.grab_frame  s÷   ø€ Ü" >Ô2Ø××Ðà��ØÜ“	ˆAØ�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                 óp  • U R                   (       a6  [        U R                  U R                  5      n[	        U R                  5      nOe[	        U R
                  5      n[        X R                  U R
                  S   R                  R                  U R                  R                  5      5      n[        SSSS9nSX0R                  S-   '   SU R                  -  n[        U R                  S5       nUR                  [        [         -   5        UR                  ["        R$                  " S
[&        R(                  " 5       R*                  UUUS.UD65        S S S 5        U R,                  (       a;  [.        R1                  S	U R,                  5        U R,                  R3                  5         g g ! , (       d  f       N[= f)Nr   rˆ  )Úonce_checkedÚloop_checkedÚreflect_checkedÚcheckedÚ_checkedr  r   )Úidr�  Úfill_framesÚintervalrö   r3   )r¡  r”  r¬  r�   rº  rÜ   r„  r\   Úrelative_tor^   r&   r�  rR   rñ   Úwriter
   r   r   r¾   ÚuuidÚuuid4ÚhexrÙ   rw   r–   râ   )r)   rÅ  rƒ  Ú	mode_dictrÆ  Úofs         r   rq   ÚHTMLWriter.finish(  s\  € à××Ü*¨4×+=Ñ+=Ø+/×+<Ñ+<ó>ˆKä˜d×0Ñ0Ó1‰Kô ˜d×.Ñ.Ó/ˆKÜ*Ø×.Ñ.Ø× Ñ  Ñ#×*Ñ*×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'Æ'
F5)r¤  r²  r®  r¬  r­  r�  r¡  )é   NNNNFr  Nrø   )rG   rH   rI   rJ   rK   rŒ   rÐ   r8   r*   r`   rl   rq   rL   rÑ   rÒ   s   @r   r—  r—  à  sE   ø† á2â6Ðàñó ðð EIØAGØ!÷D÷&!õ&8÷0"#ð "#r   r—  c                   óÀ   • \ rS rSrSrSS jrS rS rS r   SSS.S	 jjr	S
 r
S rS rS rS rS rS rS rS rS rS rS rS rSS jrS S jrS rS rS rSrg)!Ú	AnimationiM  a~  
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                 ó   • SU l         Xl        U=(       a    UR                  R                  U l        U R                  5       U l        X l        UR                  R                  SU R                  5      U l
        U R                  R                  R                  SU R                  5      U l        U R                  (       a  U R                  5         g g )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)   r_   rÜ  Úblits       r   r*   Ú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                 óV   • [        U SS5      (       d  [        R                  " S5        g g )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ã   ÚAnimation.__del__Š  s(   € Ü�tÐ0°$×7Ñ7Ü�MŠMð!õð 8r   c                 óT  • U R                   R                  R                  5       (       a  gU R                   R                  R                  U R                  5        U R                  5         U R                  R                  U R                  5        U R                  R                  5         g)zs
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ÚstartrV  s     r   rÞ  ÚAnimation._start”  sv   € ð �9‰9×Ñ×%Ñ%×'Ñ'Øà�	‰	×Ñ×'Ñ'¨×(;Ñ(;Ô<ð 	�‰Ôð 	×Ñ×&Ñ& t§z¡zÔ2Ø×Ñ×ÑÕ!r   c                 ó:  • U R                   (       a/  U R                  R                  R                  U R                  5        U R                  R                  R                  U R
                  5        U R                  R                  U R                  5        S U l        g r%   )	rÙ  rÖ  r×  rì  Ú
_resize_idrá  rÜ  Úremove_callbackrï  rV  s     r   rà  ÚAnimation._stop§  sa   € à�:�:Ø�I‰I×Ñ×+Ñ+¨D¯O©OÔ<Ø�	‰	×Ñ×'Ñ'¨¯©Ô7Ø×Ñ×)Ñ)¨$¯*©*Ô5Ø ˆÕr   )Úprogress_callbackc          
      ó¼  ^ • T /nU	b  UR                  U 4S jU	 5       5        U H
  nSUl        M     Uc  [        R                  S   nO:[	        U[
        5      (       d%  [        S X5XgU4 5       5      (       a  [        S5      eU
c  0 n
O[        U
5      n
Uc   [        T S5      (       a  ST R                  -  n[        R                  " US	5      nUS
:X  a  T R                  R                  n0 nUb  X^S'   Ub  XnS'   Ub  X~S'   Ub  XŽS'   [	        U[
        5      (       a   [        U   nU" U40 UD6n[         R%                  S['        U5      5        SU
;   a&  [         R#                  S5        U
R)                  S5        S nUR+                  T R                  X5         [,        R.                  " T R                  R0                  SSS9   UR3                  5       (       dS  U
R5                  S[        R                  S   5      nUS:X  a  T R                  R7                  5       nU" U5      U
S'   SU
S'   U H  nUR9                  5         M     SnU Vs/ s H  n[;        USS5      PM     nnSU;   a  SnO[=        U5      n[?        U Vs/ s H  nURA                  5       PM     sn6  HN  n[?        UU5       H)  u  nnURC                  USS9  Uc  M  U" UU5        US-  nM+     URD                  " S0 U
D6  MP     SSS5        SSS5        g! [         a     [        n[         R#                  SU5         GNf = fs  snf s  snf ! , (       d  f       NN= f! , (       d  f       g= f)a4  
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   ó^   >#   • U  H"  nUR                   TR                   L d  M  Uv •  M$     g 7fr%   )rÖ  )r‹  Úanimr)   s     €r   r�  Ú!Animation.save.<locals>.<genexpr>þ  s(   øé € ð 7ªZ TØ#Ÿy™y¨D¯I©IÐ5÷ !™DªZùs   ƒ-¤	-Túanimation.writerc              3   ó*   #   • U  H	  nUS Lv •  M     g 7fr%   r3   )r‹  Úargs     r   r�  rú    s   é € ð JÚH�cð ˜T•/ÚHù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ÚfigurerV   rW   rŽ   rS   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                 óv   • [         R                  " U 5      u  pp4U[        R                  " XU/5      -  S-   U-
  $ )Nrî   )ÚmcolorsÚto_rgbar   Úarray)ÚcolorÚrÚgÚbÚas        r   Ú_pre_composite_to_whiteÚ/Animation.save.<locals>._pre_composite_to_whiteC  s6   € Ü Ÿš¨Ó/‰JˆA�!Ø”r—x’x  q 	Ó*Ñ*¨QÑ.°Ñ2Ð2r   )Ú
_is_savingÚmanagerÚ	facecolorzsavefig.facecolorÚautoFÚtransparentr   Ú_save_count)rã  rî   r3   )#rD  rÕ  rT   rv   Ú
isinstancerÇ   ÚanyrD   r&   rá   rþ  rU   rÖ  r   Úwritersrü   rw   r   rx   r‰   Úpopr|   r   Ú_setattr_cmr×  rg   ÚgetÚget_facecolorrí  ræ  ÚsumÚzipÚnew_saved_frame_seqÚ_draw_next_framerl   )r)   ÚfilenameÚwriterrR   r   rV   rW   rŽ   rS   Ú
extra_animrk   rö  Úall_animrù  Úwriter_kwargsr/   r  r  Úframe_numberr
  Úsave_count_listÚtotal_framesÚdataÚds   `                       r   r  ÚAnimation.save¯  se  ø€ ðZ �6ˆØÑ!Ø�O‰Oô 7©Zó 7ô 7ó ˆDØ%)ˆDÖ"ñ ð ‰>Ü—\‘\Ð"4Ñ5‰FÜ˜V¤S×)Ñ)Üñ JØ!¨'¸xÑHóJ÷ Jñ Jäð  7ó 8ð 8ð Ñ!Ø‰Nô " .Ó1ˆNà‰;œ7 4¨×5Ñ5à˜$Ÿ.™.Ñ(ˆCô �nŠn˜S -Ó0ˆØ�(‹?Ø—)‘)—-‘-ˆCàˆØÑØ%*˜'Ñ"ØÑØ'.˜)Ñ$ØÑ!Ø*4˜,Ñ'ØÑØ(0˜*Ñ%ô �fœc×"Ñ"ð1Ü$ V™_�
ñ
   Ñ5 }Ñ5ˆFÜ�	‰	Ð+¬T°&«\Ô:à˜NÓ*Ü�L‰Lð Jô Kð ×Ñ˜}Ô-ò	3ð �m‰m˜DŸI™I xÕ5Ü×Ò §	¡	× 0Ñ 0¸TÈ4ÓPØ×0Ñ0×2Ñ2Ø*×.Ñ.¨{Ü/2¯|©|Ð<OÑ/PóR�	à Ó&Ø $§	¡	× 7Ñ 7Ó 9�IÙ.EÀiÓ.P�˜{Ñ+Ø05�˜}Ñ-ã �Ø—‘Ö!ñ !àˆLñ )1ó2Ú(0 1ô  ' q¨-¸Ö>Ù(0ð ð 2à�Ó&Ø#‘ä" ?Ó3�Ü¹xÓHºx¸!˜a×3Ñ3Ö5¹xÑHÓI�Ü" 8¨TÖ2‘G�D˜!à×)Ñ)¨!°%Ð)Ñ8Ø(Ó4Ù)¨,¸ÔEØ$¨Ñ)šñ  3ð ×!Ò!Ñ3 NÔ3ñ J÷) Q÷ 6Ð5øô7  ó 1Ü)�
Ü—‘ð (Ø)/÷1ð1üòT2ùò I÷) QÕPú÷ 6Õ5ús[   Ä	L Æ+MÇBL<ÉL2É%L<ÊL7Ê*L<Ë(L<Ë4MÌ&L/Ì.L/Ì2
L<Ì<
M
	ÍMÍ
Mc                 ó†   •  [        U R                  5      nU R                  X R                  5        g! [         a     gf = f)zq
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)   rz   Ú	framedatas      r   rï  ÚAnimation._steph  s<   € ð	Ü˜TŸ^™^Ó,ˆIØ×!Ñ! )¯Z©ZÔ8ØøÜó 	Ùð	ús   ‚03 ³
A ¿A c                 ó,   • [        U R                  5      $ )z+Return a new sequence of frame information.)ÚiterÚ
_framedatar(   s    r   rÚ  ÚAnimation.new_frame_seqw  s   € ô �D—O‘OÓ$Ð$r   c                 ó"   • U R                  5       $ )z8Return a new sequence of saved/cached frame information.)rÚ  r(   s    r   r  ÚAnimation.new_saved_frame_seq|  s   € ð ×!Ñ!Ó#Ð#r   c                 ój   • U R                  X5        U R                  U5        U R                  X5        g r%   )Ú	_pre_drawÚ_draw_frameÚ
_post_draw©r)   r,  rã  s      r   r  ÚAnimation._draw_next_frame�  s*   € ð 	�‰�yÔ'Ø×Ñ˜Ô#Ø�‰˜	Õ(r   c                 ó   • SU l         g rþ   )rÕ  r(   s    r   rí  ÚAnimation._init_drawˆ  s   € ð "&ˆÕr   c                 óJ   • U(       a  U R                  U R                  5        g g r%   )Ú_blit_clearÚ_drawn_artistsr8  s      r   r5  ÚAnimation._pre_draw�  s    € ö Ø×Ñ˜T×0Ñ0Õ1ð r   c                 ó   • [        S5      e)NzDNeeds to be implemented by subclasses to actually make an animation.rÃ   )r)   r,  s     r   r6  ÚAnimation._draw_frame“  s   € ä!ð #Aó Bð 	Br   c                 ó´   • U(       a-  U R                   (       a  U R                  U R                   5        g U R                  R                  R	                  5         g r%   )r>  Ú
_blit_drawrÖ  r×  Ú	draw_idler8  s      r   r7  ÚAnimation._post_draw˜  s7   € ö �D×'×'Ø�O‰O˜D×/Ñ/Õ0à�I‰I×Ñ×&Ñ&Õ(r   c                 ó  • U Vs1 s H  o"R                   iM     nnU H  nUR                  5       nU R                  R                  U[	        5       S 45      u  pgXV:w  d  MB  XTR
                  R                  R                  UR                  5      4U R                  U'   M�     U H  nUR                   R                  U5        M      U H2  nUR
                  R                  R                  UR                  5        M4     g s  snf r%   )ÚaxesÚ	_get_viewÚ_blit_cacher  Úobjectr   r×  Úcopy_from_bboxÚbboxÚdraw_artistrã  )r)   Úartistsr
  Ú
updated_axÚaxÚcur_viewÚviewÚbgs           r   rC  ÚAnimation._blit_draw¢  sÔ   € ñ '.Ó.¢g —f”f¡gˆ
Ð.ó ˆBð —|‘|“~ˆHØ×'Ñ'×+Ñ+¨B´³¸4Ð0@ÓA‰HˆDØÕàŸi™i×.Ñ.×=Ñ=¸b¿g¹gÓFð(H�× Ñ  Ó$ñ ó ˆAØ�F‰F×Ñ˜qÖ!ñ ó ˆBØ�I‰I×Ñ×!Ñ! "§'¡'Ö*ò ùò! /s   …C>c                 óH  • U Vs1 s H  o"R                   iM     nnU Hk  n U R                  U   u  pVUR                  5       U:X  a'  UR                  R
                  R                  U5        MP  U R                  R                  U5        Mm     g s  snf ! [         a     M‚  f = fr%   )rG  rI  r7   rH  r   r×  Úrestore_regionr  )r)   rN  r
  rG  rP  rR  rS  s          r   r=  ÚAnimation._blit_clear¸  s�   € ñ !(Ó(¢˜1—”¡ˆÐ(ÛˆBðØ×+Ñ+¨BÑ/‘�ð �|‰|‹~ Ó%Ø—	‘	× Ñ ×/Ñ/°Ö3à× Ñ ×$Ñ$ RÖ(ò ùò )øô ó Úðús   …B¢BÂ
B!Â B!c                 óò   • [        5       U l        / U l        U R                  S U R                  5        U R                  5         U R                  R                  R                  SU R                  5      U l
        g )NÚresize_event)r&   rI  r>  r7  rÙ  rí  rÖ  r×  rÝ  Ú
_on_resizeró  r(   s    r   râ  ÚAnimation._setup_blitÇ  sX   € ä›6ˆÔØ ˆÔà�‰˜˜dŸj™jÔ)ð
 	�‰ÔàŸ)™)×*Ñ*×6Ñ6°~Ø7;·±óHˆ�r   c                 óT  • U R                   R                  R                  U R                  5        U R                  R                  5         U R                  R                  5         U R                  5         U R                   R                  R                  SU R                  5      U l        g )NrÓ  )rÖ  r×  rì  ró  rÜ  ÚstoprI  Úclearrí  rÝ  Ú_end_redraw©r)   Úevents     r   rZ  ÚAnimation._on_resizeÖ  sv   € ð
 	�	‰	×Ñ×'Ñ'¨¯©Ô8Ø×Ñ×ÑÔ Ø×Ñ×ÑÔ Ø�‰ÔØŸ)™)×*Ñ*×6Ñ6°|Ø7;×7GÑ7GóIˆ�r   c                 ó$  • U R                  S S5        U R                  R                  5         U R                  R                  R                  U R                  5        U R                  R                  R                  SU R                  5      U l        g )NFrY  )	r7  rÜ  rð  rÖ  r×  rì  ró  rÝ  rZ  r`  s     r   r_  ÚAnimation._end_redrawâ  sf   € ð 	�‰˜˜eÔ$Ø×Ñ×ÑÔ!Ø�	‰	×Ñ×'Ñ'¨¯©Ô8ØŸ)™)×*Ñ*×6Ñ6°~Ø7;·±óHˆ�r   c                 óL  • Sn[        U S5      (       Gd  [        R                  " US5      nUS-  n[        5        n[	        US5      n[
        [        R                  S      nU" S[        R                  S   S	U R                  -  S
9nU R                  [        U5      US9  [        R                  " UR                  5       5      nSSS5        [        W5      nX�:¼  a  [        R                  SX�5        O4UR!                  S5      U l        SR$                  " WR&                  6 U l        [        U S5      (       a[  SS/n	[+        U SS5      (       a  U	R-                  S5        UR%                  U R"                  U R(                  SR/                  U	5      S9$ g! , (       d  f       NÖ= f)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_videorž  rŸ  ztemp.m4vrû  r’   rQ   rÿ  )rV   rW   rR   ©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á   rT   rU   r   r   r  rv   rþ  r  rÇ   r¶  r·  Ú
read_bytesrº  rw   r   r¹  rf  r¾   rd   Ú_video_sizeræ  rð   r‘  )
r)   r¥  Ú	VIDEO_TAGÚtmpdirrò   ÚWriterr  Úvid64Úvid_lenrn  s
             r   Úto_html5_videoÚ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Ø×*Ñ*ð$,�Ô ô �4˜×)Ñ)à! :Ð.ˆGô �t˜Y¨×.Ñ.Ø—‘˜vÔ&à×#Ñ#¨$×*<Ñ*<Ø)-×)9Ñ)9Ø,/¯H©H°WÓ,=ð $ð ?ð ?ð /÷K &Õ%ús   »B
FÆ
F#c                 ó´  • Uc   [        U S5      (       a  SU R                  -  nUc  [        U SS5      (       a  SOSn[        U S5      (       dd  [        5        n[	        US	5      n[        UUUS
9nU R                  [        U5      US9  UR                  5       U l	        SSS5        U R                  $ U R                  $ ! , (       d  f       U R                  $ = f)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  rj  Fr  r›  Ú_html_representationz	temp.html)rR   r¡  r�  rg  )
rá   rþ  ræ  r   r   r—  r  rÇ   Ú	read_textry  )r)   rR   r¡  r�  rr  rò   r  s          r   Ú	to_jshtmlÚAnimation.to_jshtml9  sÛ   € ð* ‰;œ7 4¨×5Ñ5à˜Ÿ™Ñ'ˆCð ÑÜ%,¨T°9Ø-2÷&4ñ &4™6Ø9?ð ô �tÐ3×4Ñ4ô $Ô%¨Ü˜F KÓ0�Ü#¨Ø1=Ø1=ñ?�ð —	‘	œ#˜d›)¨F�	Ñ3Ø,0¯N©NÓ,<�Ô)÷ &ð ×(Ñ(Ð(ˆt×(Ñ(Ð(÷ &Ô%ð ×(Ñ(Ð(ús   ÁAB>Â>
Cc                 ó‚   • [         R                  S   nUS:X  a  U R                  5       $ US:X  a  U R                  5       $ g)z#IPython display hook for rendering.zanimation.htmlÚhtml5ÚjshtmlN)rT   rv   rv  r{  )r)   rj  s     r   Ú_repr_html_ÚAnimation._repr_html_e  s@   € ä�l‰lÐ+Ñ,ˆØ�'‹>Ø×&Ñ&Ó(Ð(Ø�H‹_Ø—>‘>Ó#Ð#ð r   c                 ó¤   • U R                   R                  5         U R                  (       a%  U R                   H  nUR	                  S5        M     gg)zPause the animation.FN)rÜ  r]  rÙ  r>  Úset_animated©r)   Úartists     r   ÚpauseÚAnimation.pausem  s>   € à×Ñ×ÑÔ Ø�:�:Ø×-Ô-�Ø×#Ñ# EÖ*ò .ð r   c                 ó¤   • U R                   R                  5         U R                  (       a%  U R                   H  nUR	                  S5        M     gg)zResume the animation.TN)rÜ  rð  rÙ  r>  rƒ  r„  s     r   ÚresumeÚAnimation.resumet  s>   € à×Ñ×ÑÔ!Ø�:�:Ø×-Ô-�Ø×#Ñ# DÖ)ò .ð r   )rf  rÙ  rI  rá  rÕ  r>  rÖ  rß  ry  ró  rp  rÜ  rÛ  ©NF)	NNNNNNNNNr%   )NTN)rG   rH   rI   rJ   rK   r*   rã   rÞ  rà  r  rï  rÚ  r  r  rí  r5  r6  r7  rC  r=  râ  rZ  r_  rv  r{  r€  r†  r‰  rL   r3   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                   ó@   ^ • \ rS rSrSr  SU 4S jjrU 4S jrSrU =r$ )ÚTimedAnimationi|  a-  
`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                 ó®   >• X l         Ub  UOSU l        X@l        Uc#  UR                  R	                  U R                   S9n[
        TU ]  " U/UQ7SU0UD6  g )Nr   )rÆ  rÜ  )rþ  Ú_repeat_delayrj  r×  Ú	new_timerr‹   r*   )	r)   r_   rÆ  Úrepeat_delayÚrepeatrÜ  rz   r{   r�   s	           €r   r*   ÚTimedAnimation.__init__–  s[   ø€ à!Œà-9Ñ-E™\È1ˆÔØŒð ÑØŸ:™:×/Ñ/¸¿¹Ð/ÐHˆLÜ‰Ò˜ÐI¸$ÒI¨<ÐIÀ&ÓIr   c                 ó  >• [         TU ]  " U6 nU(       dÙ  U R                  (       aA  U R                  5         U R	                  5       U l        U R                  U R                  l        gU R                  5         U R                  (       a/  U R                  R                  R                  U R                  5        U R                  R                  R                  U R                  5        SU l        gU R                   U R                  l        g)zHandler for getting events.TNF)r‹   rï  rj  rí  rÚ  rÛ  r�  rÜ  rÆ  r†  rÙ  rÖ  r×  rì  ró  rá  rþ  )r)   rz   Ústill_goingr�   s      €r   rï  ÚTimedAnimation._step¢  s¸   ø€ ô ‘g’m TÐ*ˆÞØ�|�|à—‘Ô!Ø!%×!3Ñ!3Ó!5�”Ø-1×-?Ñ-?�×!Ñ!Ô*Øð —
‘
”Ø—:—:à—I‘I×$Ñ$×3Ñ3°D·O±OÔDØ—	‘	× Ñ ×/Ñ/°·±Ô?Ø$(�Ô!Øà%)§^¡^ˆ×ÑÔ"Ør   )rþ  rj  r�  rÜ  rÛ  )éÈ   r   TN)	rG   rH   rI   rJ   rK   r*   rï  rL   rÑ   rÒ   s   @r   r�  r�  |  s"   ø† ñð2 BFØ"÷
J÷ó r   r�  c                   óD   ^ • \ rS rSrSrU 4S jrU 4S jrS rS rSr	U =r
$ )ÚArtistAnimationiÁ  a,  
`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   >• / U l         X l        [        TU ]  " U/UQ70 UD6  g r%   )r>  r0  r‹   r*   )r)   r_   rN  rz   r{   r�   s        €r   r*   ÚArtistAnimation.__init__á  s)   ø€ à ˆÔð "ŒÜ‰Ò˜Ð.˜tÒ. vÓ.r   c                 ó~  >• [         TU ]  5         [        5       nU R                  5        Hm  nU Hd  nUR	                  S5        UR                  U R                  5        UR                  5       U;  d  ME  UR                  UR                  5       5        Mf     Mo     U H  nUR                  R                  5         M     g r‹  )r‹   rí  ÚsetrÚ  Úset_visiblerƒ  rÙ  Ú
get_figureÚaddr×  rD  )r)   Úfigsr»  r…  r_   r�   s        €r   rí  ÚArtistAnimation._init_drawê  s”   ø€ Ü‰ÑÔä‹uˆØ×#Ñ#Ö%ˆAÛ�Ø×"Ñ" 5Ô)Ø×#Ñ# D§J¡JÔ/à×$Ñ$Ó&¨dÕ2Ø—H‘H˜V×.Ñ.Ó0Ö1ó ñ &ó ˆCØ�J‰J× Ñ Ö"ò r   c                 ó’   • U(       a  U R                  U R                  5        gU R                   H  nUR                  S5        M     g)z#Clears artists from the last frame.FN)r=  r>  rž  )r)   r,  rã  r…  s       r   r5  ÚArtistAnimation._pre_drawú  s9   € æà×Ñ˜T×0Ñ0Õ1ð ×-Ô-�Ø×"Ñ" 5Ö)ò .r   c                 óD   • Xl         U H  nUR                  S5        M     g rþ   )r>  rž  )r)   rN  r…  s      r   r6  ÚArtistAnimation._draw_frame  s$   € ð &Ôó ˆFØ×Ñ˜tÖ$ò r   )r>  r0  )rG   rH   rI   rJ   rK   r*   rí  r5  r6  rL   rÑ   rÒ   s   @r   r™  r™  Á  s!   ø† ñõ>/õ#ò *÷%ð %r   r™  c                   óZ   ^ • \ rS rSrSr  SSS.U 4S jjjrS rS rU 4S jrS	 r	S
r
U =r$ )ÚFuncAnimationi  a  
`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                ó$  >^ ^• U(       a  UT l         OST l         UT l        UT l        UT l        Tc  [        R
                  T l        Oî[        T5      (       a  TT l        OÖ[        R                  " T5      (       a‡  UR                  SS5      (       a  TT l        T4U 4S jjn	U	T l        OU4S jT l        [        TS5      (       a;  [        T5      T l        Ub(  [        R                  " SU< S[        T5      < S	35        O4U4S
 jT l        TT l        Ub  [        R                  " SU< ST< S	35        T R                  c(  U(       a!  [        R                  " ST< SU< S35        SnUT l        / T l        [$        T
T ]L  " U40 UD6  / T l        g )Nr3   r’  Tc              3   óx   >#   • [         R                  " TR                  S5      u  nTl        U S h  v•N   g  N7f)Nr“   )Ú	itertoolsÚteeÚ	_tee_from)ÚframesÚthisr)   s     €r   Úiter_framesÚ+FuncAnimation.__init__.<locals>.iter_framesŽ  s(   øé € Ü+4¯=ª=¸¿¹ÈÓ+KÑ(�D˜$œ.Ø#—O“Oùs   ƒ/:²8³:c                  ó   >• [        T 5      $ r%   )r/  ©r¯  s   €r   r~  Ú(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 5      5      $ r%   )r/  Úranger´  s   €r   r~  rµ  �  s   ø€ ¤T¬%°«-Ô%8r   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  r¬  ÚcountÚ	_iter_genÚcallabler   Úiterabler  r®  rá   rº  r   ré   Ú_cache_frame_dataÚ	_save_seqr‹   r*   )r)   r_   Úfuncr¯  Ú	init_funcÚfargsÚ
save_countr©  r{   r±  r�   s   `  `      €r   r*   Ú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                 ó"   • U R                  5       $ r%   )r½  r(   s    r   rÚ  ÚFuncAnimation.new_frame_seqº  s   € à�~‰~ÓÐr   c                 ó6  ^• U R                   (       a/  [        U R                   5      U l        [        U R                  5      $ U R                  c  U R                  5       mU4S jnU" 5       $ [        R                  " U R                  5       U R                  5      $ )Nc               3   óN   >#   •   [        T 5      v •  M  ! [         a     g f = f7fr%   )r*  r+  )rÛ  s   €r   ÚgenÚ.FuncAnimation.new_saved_frame_seq.<locals>.genË  s.   øé € ðØ"Ü"& y£/Ò1ñ #øä(ó Ùðüs   ƒ%… •
"Ÿ%¡"¢%)rÁ  rA   Ú_old_saved_seqr/  r  rÚ  r¬  Úislice)r)   rË  rÛ  s     @r   r  Ú!FuncAnimation.new_saved_frame_seq¾  sz   ø€ ð �>�>ô #' t§~¡~Ó"6ˆDÔÜ˜×+Ñ+Ó,Ð,à×ÑÑ'Ø ×.Ñ.Ó0�	õñ “u�ä ×'Ò'¨×(:Ñ(:Ó(<¸d×>NÑ>NÓOÐOr   c                 óÆ  >• [         TU ]  5         U R                  c,   [        U R	                  5       5      nU R                  U5        OlU R                  5       U l	        U R                  (       aF  U R                  c  [        S5      eU R                   H  nUR                  U R                  5        M      / U l        g ! [
         a    [        R                  " S5         g f = f)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.)r‹   rí  r»  r*  rÚ  r+  rç  rè  r6  r>  rÙ  rD   rƒ  rÁ  )r)   r�  r
  r�   s      €r   rí  Ú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                 ór  • U R                   (       a:  U R                  R                  U5        U R                  U R                  * S  U l        U R                  " U/U R
                  Q76 U l        U R                  (       a¨  [        S5      n [        U R                  5        U R                   H.  n[        U[        R                  R                  5      (       a  M.  Ue   [        U R                  S S9U l        U R                   H  nUR!                  U R                  5        M      g g ! [         a    US ef = f)Nz@The animation function must return a sequence of Artist objects.c                 ó"   • U R                  5       $ r%   )Ú
get_zorder)r   s    r   r~  Ú+FuncAnimation._draw_frame.<locals>.<lambda>  s
   € °q·|±|´~r   )Úkey)rÀ  rÁ  rð   r  rº  r§   r>  rÙ  rD   r/  rŠ   r  rT   r…  ÚArtistÚsortedrƒ  )r)   r,  rº   rŒ  r
  s        r   r6  ÚFuncAnimation._draw_frameõ  s  € Ø×!×!à�N‰N×!Ñ! )Ô,Ø!Ÿ^™^¨T×-=Ñ-=Ð,=Ð,>Ð?ˆDŒNð #Ÿjšj¨Ð@°T·Z±ZÒ@ˆÔà�:�:äð  4ó 5ˆCð$ä�T×(Ñ(Ô)ð
 ×(Ô(�Ü! !¤S§Z¡Z×%6Ñ%6×7Ó7Ø�Iñ )ô #)¨×)<Ñ)<Ù-Eñ#GˆDÔð ×(Ô(�Ø—‘˜tŸz™zÖ*ò )ð% øô ó $Ø˜tÐ#ð$ús   ÂD( Ä(D6)
r§   rÀ  r>  rº  r»  r½  rÍ  r  rÁ  r®  )NNNN)rG   rH   rI   rJ   rK   r*   rÚ  r  rí  r6  rL   rÑ   rÒ   s   @r   r¨  r¨    sE   ø† ñeðL FJØ ðCØ6:÷Cñ CòJ òPõ.÷@+ð +r   r¨  c                 ó®   • [         R                  S   S:X  a!  [        S[         R                  S   < S35      eS H  nX;   d  M
  [        SU< 35      e   g )Nrt   ru   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 )rT   rv   Ú
ValueErrorrŠ   )rk   rG  s     r   r¿   r¿     sf   € Ü
‡|�|�NÑ# wÓ.ÜØ,Œs�|‰|˜NÑ+Ñ-ð .Rð Ró
ð 	
ó .ˆØÕÜØ@ÀÁÐFóð ò .r   )>r   r¶  r‚   Úior   r   r¬  rµ   Úpathlibr   rÍ   r©   ÚsysÚtempfiler   rÉ  rç  Únumpyr   ÚPILr   Ú
matplotlibrT   Úmatplotlib._animation_datar   r	   r
   r   r   r   Úmatplotlib.colorsÚcolorsr  Ú	getLoggerrG   rw   ÚplatformÚCREATE_NO_WINDOWr¬   r    r"   r  ÚABCrN   r…   rÔ   r4   rü   r  rM  rZ  ra  rx  r|  r„  r”  r—  rÑ  r�  r™  r¨  r¿   r3   r   r   Ú<module>rê     s  ðÛ 
Û Û ß %Û Û Ý Û Û Û 
Ý 'Û Û ã Ý ã ÷Bó Bç "Ý #à×Ò˜Ó"€ð
 $'§<¡<°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   