mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-07-15 00:52:15 +08:00
Merge branch 'main' into reorganize
This commit is contained in:
@ -4,7 +4,6 @@ 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
|
||||
|
||||
@ -12,42 +11,40 @@ 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,
|
||||
subdivide_output=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
|
||||
return float(self.camera.get_frame_height())
|
||||
|
||||
@property
|
||||
def _frame_width(self) -> float:
|
||||
return self.camera.frame.get_width() # type: ignore
|
||||
return float(self.camera.get_frame_width())
|
||||
|
||||
@property
|
||||
def _background_color(self) -> str:
|
||||
return self.camera_config["background_color"].hex # type: ignore
|
||||
rgba = self.camera.background_rgba
|
||||
r = int(255 * rgba[0])
|
||||
g = int(255 * rgba[1])
|
||||
b = int(255 * rgba[2])
|
||||
if rgba[3] == 1.0:
|
||||
return f"#{r:02x}{g:02x}{b:02x}"
|
||||
|
||||
a = int(255 * rgba[3])
|
||||
return f"#{r:02x}{g:02x}{b:02x}{a:02x}"
|
||||
|
||||
@property
|
||||
def _resolution(self) -> tuple[int, int]:
|
||||
return self.camera_config["pixel_width"], self.camera_config["pixel_height"]
|
||||
return self.camera.get_pixel_width(), self.camera.get_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
|
||||
)
|
||||
]
|
||||
partial_movie_directory = self.file_writer.partial_movie_directory
|
||||
extension = self.file_writer.movie_file_extension
|
||||
return sorted(partial_movie_directory.glob(f"*{extension}"))
|
||||
|
||||
@property
|
||||
def _show_progress_bar(self) -> bool:
|
||||
@ -64,7 +61,11 @@ class Slide(BaseSlide, Scene): # type: ignore[misc]
|
||||
def run(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""MANIMGL renderer."""
|
||||
super().run(*args, **kwargs)
|
||||
self._save_slides(use_cache=False)
|
||||
self._save_slides(
|
||||
use_cache=False,
|
||||
flush_cache=self.flush_cache,
|
||||
skip_reversing=self.skip_reversing,
|
||||
)
|
||||
|
||||
|
||||
class ThreeDSlide(Slide):
|
||||
|
Reference in New Issue
Block a user