Enabled adding end animation number with -n flag

This commit is contained in:
Grant Sanderson 2018-02-10 22:34:39 -08:00
parent 5e25ecd33c
commit b9ef9f6fc0
2 changed files with 13 additions and 1 deletions

View file

@ -89,6 +89,7 @@ def get_configuration():
"write_all" : args.write_all, "write_all" : args.write_all,
"output_name" : args.output_name, "output_name" : args.output_name,
"skip_to_animation_number" : args.skip_to_animation_number, "skip_to_animation_number" : args.skip_to_animation_number,
"end_after_animation_number" : None,
} }
if args.low_quality: if args.low_quality:
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
@ -102,7 +103,12 @@ def get_configuration():
stan = config["skip_to_animation_number"] stan = config["skip_to_animation_number"]
if stan is not None: 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["skip_animations"] = any([
config["show_last_frame"] and not config["write_to_movie"], config["show_last_frame"] and not config["write_to_movie"],
@ -221,6 +227,7 @@ def main():
"output_directory", "output_directory",
"save_pngs", "save_pngs",
"skip_to_animation_number", "skip_to_animation_number",
"end_after_animation_number",
] ]
]) ])

View file

@ -40,6 +40,7 @@ class Scene(Container):
"always_continually_update" : False, "always_continually_update" : False,
"random_seed" : 0, "random_seed" : 0,
"skip_to_animation_number" : None, "skip_to_animation_number" : None,
"end_after_animation_number" : None,
} }
def __init__(self, **kwargs): def __init__(self, **kwargs):
Container.__init__(self, **kwargs) # Perhaps allow passing in a non-empty *mobjects parameter? 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.skip_to_animation_number:
if self.num_plays + 1 == self.skip_to_animation_number: if self.num_plays + 1 == self.skip_to_animation_number:
self.skip_animations = False 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: if self.skip_animations:
kwargs["run_time"] = 0 kwargs["run_time"] = 0