Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Rename `SceneFileWriter.save_final_image()` to `save_image()` (#4378)

F. Muenkelf69f2545d9b2
diff --git a/manim/renderer/cairo_renderer.py b/manim/renderer/cairo_renderer.py
index 351203a87..93be76803 100644
--- a/manim/renderer/cairo_renderer.py
+++ b/manim/renderer/cairo_renderer.py
@@ -26,8 +26,13 @@ __all__ = ["CairoRenderer"]
class CairoRenderer:
"""A renderer using Cairo.
- num_plays : Number of play() functions in the scene.
- time: time elapsed since initialisation of scene.
+ Attributes
+ ----------
+ num_plays : int
+ Number of play() functions in the scene.
+
+ time : float
+ Time elapsed since initialisation of scene.
"""
def __init__(
@@ -138,7 +143,6 @@ class CairoRenderer:
ignore_skipping
**kwargs
-
"""
if self.skip_animations and not ignore_skipping:
return
@@ -160,20 +164,18 @@ class CairoRenderer:
self.add_frame(self.get_frame())
def get_frame(self) -> PixelArray:
- """
- Gets the current frame as NumPy array.
+ """Gets the current frame as NumPy array.
Returns
-------
np.array
NumPy array of pixel values of each pixel in screen.
- The shape of the array is height x width x 3
+ The shape of the array is height x width x 3.
"""
return np.array(self.camera.pixel_array)
def add_frame(self, frame: np.ndarray, num_frames: int = 1):
- """
- Adds a frame to the video_file_stream
+ """Adds a frame to the video_file_stream
Parameters
----------
@@ -203,10 +205,7 @@ class CairoRenderer:
)
def show_frame(self):
- """
- Opens the current frame in the Default Image Viewer
- of your system.
- """
+ """Opens the current frame in the Default Image Viewer of your system."""
self.update_frame(ignore_skipping=True)
self.camera.get_image().show()
@@ -223,7 +222,7 @@ class CairoRenderer:
scene
The scene played.
static_mobjects
- Static mobjects of the scene. If None, self.static_image is set to None
+ Static mobjects of the scene. If None, self.static_image is set to None.
Returns
-------
@@ -276,4 +275,4 @@ class CairoRenderer:
if config["save_last_frame"]:
self.static_image = None
self.update_frame(scene)
- self.file_writer.save_final_image(self.camera.get_image())
+ self.file_writer.save_image(self.camera.get_image())
diff --git a/manim/renderer/opengl_renderer.py b/manim/renderer/opengl_renderer.py
index 76ecdad54..15fc6e885 100644
--- a/manim/renderer/opengl_renderer.py
+++ b/manim/renderer/opengl_renderer.py
@@ -403,8 +403,7 @@ class OpenGLRenderer:
return self.path_to_texture_id[repr(path)]
def update_skipping_status(self) -> None:
- """
- This method is used internally to check if the current
+ """This method is used internally to check if the current
animation needs to be skipped or not. It also checks if
the number of animations that were played correspond to
the number of animations that need to be played, and
@@ -506,7 +505,7 @@ class OpenGLRenderer:
if self.should_save_last_frame():
config.save_last_frame = True
self.update_frame(scene)
- self.file_writer.save_final_image(self.get_image())
+ self.file_writer.save_image(self.get_image())
def should_save_last_frame(self):
if config["save_last_frame"]:
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index 257e4301c..1e0d02f7e 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -483,7 +483,7 @@ class SceneFileWriter:
)
def output_image(
- self, image: Image.Image, target_dir: StrPath, ext: str, zero_pad: bool
+ self, image: Image.Image, target_dir: StrPath, ext: str, zero_pad: int
) -> None:
if zero_pad:
image.save(f"{target_dir}{str(self.frame_count).zfill(zero_pad)}{ext}")
@@ -491,9 +491,8 @@ class SceneFileWriter:
image.save(f"{target_dir}{self.frame_count}{ext}")
self.frame_count += 1
- def save_final_image(self, image: Image.Image) -> None:
- """The name is a misnomer. This method saves the image
- passed to it as an in the default image directory.
+ def save_image(self, image: Image.Image) -> None:
+ """This method saves the image passed to it in the default image directory.
Parameters
----------