mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-07-18 17:04:38 +08:00

* refactor(lib): change how manim API is imported * chore(lib): delete old files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip: moving all commands * adding animations * fix tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix mypy * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * trying to fix docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip: docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make it work * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * wip test * tests are working * improving docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix index * docs: nicer shift * docs: nicer quickstart example * fix tests * change tests * move coverage to test workflow * fix(tests): remove resolve * strict resolve * change local path test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * documented changes * cleanup docs * cleanup files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): set type --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
77 lines
2.2 KiB
Python
77 lines
2.2 KiB
Python
from pathlib import Path
|
|
from typing import Any, List, Optional, Tuple
|
|
|
|
from manimlib import Scene, ThreeDCamera
|
|
from manimlib.utils.file_ops import get_sorted_integer_files
|
|
|
|
from .base import BaseSlide
|
|
|
|
|
|
class Slide(BaseSlide, Scene): # type: ignore[misc]
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
kwargs.setdefault("file_writer_config", {}).update(
|
|
skip_animations=True,
|
|
break_into_partial_movies=True,
|
|
write_to_movie=True,
|
|
)
|
|
|
|
kwargs["preview"] = False # Avoid opening a preview window
|
|
super().__init__(*args, **kwargs)
|
|
|
|
@property
|
|
def _frame_height(self) -> float:
|
|
return self.camera.frame.get_height() # type: ignore
|
|
|
|
@property
|
|
def _frame_width(self) -> float:
|
|
return self.camera.frame.get_width() # type: ignore
|
|
|
|
@property
|
|
def _background_color(self) -> str:
|
|
"""Returns the scene's background color."""
|
|
return self.camera_config["background_color"].hex # type: ignore
|
|
|
|
@property
|
|
def _resolution(self) -> Tuple[int, int]:
|
|
"""Returns the scene's resolution used during rendering."""
|
|
return self.camera_config["pixel_width"], self.camera_config["pixel_height"]
|
|
|
|
@property
|
|
def _partial_movie_files(self) -> List[Path]:
|
|
"""Returns a list of partial movie files, a.k.a animations."""
|
|
|
|
kwargs = {
|
|
"remove_non_integer_files": True,
|
|
"extension": self.file_writer.movie_file_extension,
|
|
}
|
|
return [
|
|
Path(file)
|
|
for file in get_sorted_integer_files(
|
|
self.file_writer.partial_movie_directory, **kwargs
|
|
)
|
|
]
|
|
|
|
@property
|
|
def _show_progress_bar(self) -> bool:
|
|
return True
|
|
|
|
@property
|
|
def _leave_progress_bar(self) -> bool:
|
|
return self.leave_progress_bars # type: ignore
|
|
|
|
@property
|
|
def _start_at_animation_number(self) -> Optional[int]:
|
|
return self.start_at_animation_number # type: ignore
|
|
|
|
def run(self, *args: Any, **kwargs: Any) -> None:
|
|
"""MANIMGL renderer."""
|
|
super().run(*args, **kwargs)
|
|
self._save_slides(use_cache=False)
|
|
|
|
|
|
class ThreeDSlide(Slide):
|
|
CONFIG = {
|
|
"camera_class": ThreeDCamera,
|
|
}
|
|
pass
|