Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Move Scene.update_skipping_status()

Devin Neal2555bc7b6ac3
diff --git a/manim/renderer/cairo_renderer.py b/manim/renderer/cairo_renderer.py
index 71a7fd7ff..96c0fbb0e 100644
--- a/manim/renderer/cairo_renderer.py
+++ b/manim/renderer/cairo_renderer.py
@@ -1,6 +1,7 @@
import numpy as np
from .. import file_writer_config
from ..utils.iterables import list_update
+from ..utils.exceptions import EndSceneEarlyException
class CairoRenderer:
@@ -60,3 +61,19 @@ class CairoRenderer:
The shape of the array is height x width x 3
"""
return np.array(self.camera.pixel_array)
+
+ def update_skipping_status(self):
+ """
+ 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
+ raises an EndSceneEarlyException if they don't correspond.
+ """
+ if file_writer_config["from_animation_number"]:
+ if self.scene.num_plays < file_writer_config["from_animation_number"]:
+ file_writer_config["skip_animations"] = True
+ if file_writer_config["upto_animation_number"]:
+ if self.scene.num_plays > file_writer_config["upto_animation_number"]:
+ file_writer_config["skip_animations"] = True
+ raise EndSceneEarlyException()
diff --git a/manim/scene/scene.py b/manim/scene/scene.py
index cf612d848..73264db56 100644
--- a/manim/scene/scene.py
+++ b/manim/scene/scene.py
@@ -1,7 +1,7 @@
"""Basic canvas for animations."""
-__all__ = ["Scene", "EndSceneEarlyException"]
+__all__ = ["Scene"]
import inspect
@@ -25,6 +25,7 @@ from ..utils.iterables import list_update
from ..utils.hashing import get_hash_from_play_call, get_hash_from_wait_call
from ..utils.family import extract_mobject_family_members
from ..renderer.cairo_renderer import CairoRenderer
+from ..utils.exceptions import EndSceneEarlyException
class Scene(Container):
@@ -732,22 +733,6 @@ class Scene(Container):
return animations
- def update_skipping_status(self):
- """
- 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
- raises an EndSceneEarlyException if they don't correspond.
- """
- if file_writer_config["from_animation_number"]:
- if self.num_plays < file_writer_config["from_animation_number"]:
- file_writer_config["skip_animations"] = True
- if file_writer_config["upto_animation_number"]:
- if self.num_plays > file_writer_config["upto_animation_number"]:
- file_writer_config["skip_animations"] = True
- raise EndSceneEarlyException()
-
def begin_animations(self, animations):
"""
This method begins the list of animations that is passed,
@@ -821,7 +806,7 @@ class Scene(Container):
def cached_play(self, *args, **kwargs):
self.revert_to_original_skipping_status()
- self.update_skipping_status()
+ self.renderer.update_skipping_status()
animations = self.compile_play_args_to_animation_list(*args, **kwargs)
self.add_mobjects_from_animations(animations)
if file_writer_config["skip_animations"]:
@@ -1078,7 +1063,3 @@ class Scene(Container):
"""
self.renderer.update_frame(ignore_skipping=True)
self.camera.get_image().show()
-
-
-class EndSceneEarlyException(Exception):
- pass
diff --git a/manim/utils/exceptions.py b/manim/utils/exceptions.py
new file mode 100644
index 000000000..0326f46df
--- /dev/null
+++ b/manim/utils/exceptions.py
@@ -0,0 +1,2 @@
+class EndSceneEarlyException(Exception):
+ pass