Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Enabled adding end animation number with -n flag

Grant Sandersonb9ef9f6fc012
diff --git a/extract_scene.py b/extract_scene.py
index 825f0ea10..ea34fa060 100644
--- a/extract_scene.py
+++ b/extract_scene.py
@@ -89,6 +89,7 @@ def get_configuration():
"write_all" : args.write_all,
"output_name" : args.output_name,
"skip_to_animation_number" : args.skip_to_animation_number,
+ "end_after_animation_number" : None,
}
if args.low_quality:
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
@@ -102,7 +103,12 @@ def get_configuration():
stan = config["skip_to_animation_number"]
if stan is not None:
- config["skip_to_animation_number"] = int(stan)
+ if "," in stan:
+ start, end = stan.split(",")
+ config["skip_to_animation_number"] = int(start)
+ config["end_after_animation_number"] = int(end)
+ else:
+ config["skip_to_animation_number"] = int(stan)
config["skip_animations"] = any([
config["show_last_frame"] and not config["write_to_movie"],
@@ -221,6 +227,7 @@ def main():
"output_directory",
"save_pngs",
"skip_to_animation_number",
+ "end_after_animation_number",
]
])
diff --git a/scene/scene.py b/scene/scene.py
index 4c72897c6..625145f46 100644
--- a/scene/scene.py
+++ b/scene/scene.py
@@ -40,6 +40,7 @@ class Scene(Container):
"always_continually_update" : False,
"random_seed" : 0,
"skip_to_animation_number" : None,
+ "end_after_animation_number" : None,
}
def __init__(self, **kwargs):
Container.__init__(self, **kwargs) # Perhaps allow passing in a non-empty *mobjects parameter?
@@ -409,6 +410,10 @@ class Scene(Container):
if self.skip_to_animation_number:
if self.num_plays + 1 == self.skip_to_animation_number:
self.skip_animations = False
+ if self.end_after_animation_number:
+ if self.num_plays >= self.end_after_animation_number:
+ self.skip_animations = True
+ return self #Don't even both with the rest...
if self.skip_animations:
kwargs["run_time"] = 0