mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-22 21:17:19 +08:00

* test: re-add opencv-python * chore(dev): move to Rye instead of PDM * try fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: build backend * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: string quotes? * small fixes * upgrade typing * fix(ci): rye install on Windows * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(ci): typos * fix * fix(ci): actually use right python version * fix(deps): manimgl * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix docs * another fix * cleanup * make sure to use trusted publisher * chore(docs): remove PDM --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
from pathlib import Path
|
|
from typing import Any, ClassVar, Optional
|
|
|
|
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:
|
|
return self.camera_config["background_color"].hex # type: ignore
|
|
|
|
@property
|
|
def _resolution(self) -> tuple[int, int]:
|
|
return self.camera_config["pixel_width"], self.camera_config["pixel_height"]
|
|
|
|
@property
|
|
def _partial_movie_files(self) -> list[Path]:
|
|
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: ClassVar[dict[str, Any]] = {
|
|
"camera_class": ThreeDCamera,
|
|
}
|
|
pass
|