animation.pyi 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import abc
  2. from collections.abc import Callable, Collection, Iterable, Sequence, Generator
  3. import contextlib
  4. from pathlib import Path
  5. from matplotlib.artist import Artist
  6. from matplotlib.backend_bases import TimerBase
  7. from matplotlib.figure import Figure
  8. from typing import Any
  9. subprocess_creation_flags: int
  10. def adjusted_figsize(w: float, h: float, dpi: float, n: int) -> tuple[float, float]: ...
  11. class MovieWriterRegistry:
  12. def __init__(self) -> None: ...
  13. def register(
  14. self, name: str
  15. ) -> Callable[[type[AbstractMovieWriter]], type[AbstractMovieWriter]]: ...
  16. def is_available(self, name: str) -> bool: ...
  17. def __iter__(self) -> Generator[str, None, None]: ...
  18. def list(self) -> list[str]: ...
  19. def __getitem__(self, name: str) -> type[AbstractMovieWriter]: ...
  20. writers: MovieWriterRegistry
  21. class AbstractMovieWriter(abc.ABC, metaclass=abc.ABCMeta):
  22. fps: int
  23. metadata: dict[str, str]
  24. codec: str
  25. bitrate: int
  26. def __init__(
  27. self,
  28. fps: int = ...,
  29. metadata: dict[str, str] | None = ...,
  30. codec: str | None = ...,
  31. bitrate: int | None = ...,
  32. ) -> None: ...
  33. outfile: str | Path
  34. fig: Figure
  35. dpi: float
  36. @abc.abstractmethod
  37. def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...) -> None: ...
  38. @property
  39. def frame_size(self) -> tuple[int, int]: ...
  40. @abc.abstractmethod
  41. def grab_frame(self, **savefig_kwargs) -> None: ...
  42. @abc.abstractmethod
  43. def finish(self) -> None: ...
  44. @contextlib.contextmanager
  45. def saving(
  46. self, fig: Figure, outfile: str | Path, dpi: float | None, *args, **kwargs
  47. ) -> Generator[AbstractMovieWriter, None, None]: ...
  48. class MovieWriter(AbstractMovieWriter):
  49. supported_formats: list[str]
  50. frame_format: str
  51. extra_args: list[str] | None
  52. def __init__(
  53. self,
  54. fps: int = ...,
  55. codec: str | None = ...,
  56. bitrate: int | None = ...,
  57. extra_args: list[str] | None = ...,
  58. metadata: dict[str, str] | None = ...,
  59. ) -> None: ...
  60. def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...) -> None: ...
  61. def grab_frame(self, **savefig_kwargs) -> None: ...
  62. def finish(self) -> None: ...
  63. @classmethod
  64. def bin_path(cls) -> str: ...
  65. @classmethod
  66. def isAvailable(cls) -> bool: ...
  67. class FileMovieWriter(MovieWriter):
  68. fig: Figure
  69. outfile: str | Path
  70. dpi: float
  71. temp_prefix: str
  72. fname_format_str: str
  73. def setup(
  74. self,
  75. fig: Figure,
  76. outfile: str | Path,
  77. dpi: float | None = ...,
  78. frame_prefix: str | Path | None = ...,
  79. ) -> None: ...
  80. def __del__(self) -> None: ...
  81. @property
  82. def frame_format(self) -> str: ...
  83. @frame_format.setter
  84. def frame_format(self, frame_format: str) -> None: ...
  85. class PillowWriter(AbstractMovieWriter):
  86. @classmethod
  87. def isAvailable(cls) -> bool: ...
  88. def setup(
  89. self, fig: Figure, outfile: str | Path, dpi: float | None = ...
  90. ) -> None: ...
  91. def grab_frame(self, **savefig_kwargs) -> None: ...
  92. def finish(self) -> None: ...
  93. class FFMpegBase:
  94. codec: str
  95. @property
  96. def output_args(self) -> list[str]: ...
  97. class FFMpegWriter(FFMpegBase, MovieWriter): ...
  98. class FFMpegFileWriter(FFMpegBase, FileMovieWriter):
  99. supported_formats: list[str]
  100. class ImageMagickBase:
  101. @classmethod
  102. def bin_path(cls) -> str: ...
  103. @classmethod
  104. def isAvailable(cls) -> bool: ...
  105. class ImageMagickWriter(ImageMagickBase, MovieWriter):
  106. input_names: str
  107. class ImageMagickFileWriter(ImageMagickBase, FileMovieWriter):
  108. supported_formats: list[str]
  109. @property
  110. def input_names(self) -> str: ...
  111. class HTMLWriter(FileMovieWriter):
  112. supported_formats: list[str]
  113. @classmethod
  114. def isAvailable(cls) -> bool: ...
  115. embed_frames: bool
  116. default_mode: str
  117. def __init__(
  118. self,
  119. fps: int = ...,
  120. codec: str | None = ...,
  121. bitrate: int | None = ...,
  122. extra_args: list[str] | None = ...,
  123. metadata: dict[str, str] | None = ...,
  124. embed_frames: bool = ...,
  125. default_mode: str = ...,
  126. embed_limit: float | None = ...,
  127. ) -> None: ...
  128. def setup(
  129. self,
  130. fig: Figure,
  131. outfile: str | Path,
  132. dpi: float | None = ...,
  133. frame_dir: str | Path | None = ...,
  134. ) -> None: ...
  135. def grab_frame(self, **savefig_kwargs): ...
  136. def finish(self) -> None: ...
  137. class Animation:
  138. frame_seq: Iterable[Artist]
  139. event_source: Any
  140. def __init__(
  141. self, fig: Figure, event_source: Any | None = ..., blit: bool = ...
  142. ) -> None: ...
  143. def __del__(self) -> None: ...
  144. def save(
  145. self,
  146. filename: str | Path,
  147. writer: AbstractMovieWriter | str | None = ...,
  148. fps: int | None = ...,
  149. dpi: float | None = ...,
  150. codec: str | None = ...,
  151. bitrate: int | None = ...,
  152. extra_args: list[str] | None = ...,
  153. metadata: dict[str, str] | None = ...,
  154. extra_anim: list[Animation] | None = ...,
  155. savefig_kwargs: dict[str, Any] | None = ...,
  156. *,
  157. progress_callback: Callable[[int, int], Any] | None = ...
  158. ) -> None: ...
  159. def new_frame_seq(self) -> Iterable[Artist]: ...
  160. def new_saved_frame_seq(self) -> Iterable[Artist]: ...
  161. def to_html5_video(self, embed_limit: float | None = ...) -> str: ...
  162. def to_jshtml(
  163. self,
  164. fps: int | None = ...,
  165. embed_frames: bool = ...,
  166. default_mode: str | None = ...,
  167. ) -> str: ...
  168. def _repr_html_(self) -> str: ...
  169. def pause(self) -> None: ...
  170. def resume(self) -> None: ...
  171. class TimedAnimation(Animation):
  172. def __init__(
  173. self,
  174. fig: Figure,
  175. interval: int = ...,
  176. repeat_delay: int = ...,
  177. repeat: bool = ...,
  178. event_source: TimerBase | None = ...,
  179. *args,
  180. **kwargs
  181. ) -> None: ...
  182. class ArtistAnimation(TimedAnimation):
  183. def __init__(self, fig: Figure, artists: Sequence[Collection[Artist]], *args, **kwargs) -> None: ...
  184. class FuncAnimation(TimedAnimation):
  185. def __init__(
  186. self,
  187. fig: Figure,
  188. func: Callable[..., Iterable[Artist]],
  189. frames: Iterable | int | Callable[[], Generator] | None = ...,
  190. init_func: Callable[[], Iterable[Artist]] | None = ...,
  191. fargs: tuple[Any, ...] | None = ...,
  192. save_count: int | None = ...,
  193. *,
  194. cache_frame_data: bool = ...,
  195. **kwargs
  196. ) -> None: ...