Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions manim/renderer/cairo_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
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__(
Expand Down Expand Up @@ -138,7 +143,6 @@ def update_frame( # TODO Description in Docstring
ignore_skipping

**kwargs

"""
if self.skip_animations and not ignore_skipping:
return
Expand All @@ -160,20 +164,18 @@ def render(self, scene, time, moving_mobjects):
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
----------
Expand Down Expand Up @@ -203,10 +205,7 @@ def freeze_current_frame(self, duration: float):
)

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()

Expand All @@ -223,7 +222,7 @@ def save_static_frame_data(
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
-------
Expand Down Expand Up @@ -276,4 +275,4 @@ def scene_finished(self, scene: Scene) -> None:
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())
5 changes: 2 additions & 3 deletions manim/renderer/opengl_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ def get_texture_id(self, path):
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
Expand Down Expand Up @@ -506,7 +505,7 @@ def scene_finished(self, scene):
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"]:
Expand Down
7 changes: 3 additions & 4 deletions manim/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,17 +483,16 @@ def write_frame(
)

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}")
else:
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
----------
Expand Down
Loading