mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Merge pull request #75 from 3b1b/fourier-work
Enable -n command on extract_scene.py to skip to a given animation in a scene
This commit is contained in:
commit
15a832acec
2 changed files with 18 additions and 3 deletions
|
@ -66,6 +66,7 @@ def get_configuration():
|
||||||
for short_arg, long_arg in optional_args:
|
for short_arg, long_arg in optional_args:
|
||||||
parser.add_argument(short_arg, long_arg, action = "store_true")
|
parser.add_argument(short_arg, long_arg, action = "store_true")
|
||||||
parser.add_argument("-o", "--output_name")
|
parser.add_argument("-o", "--output_name")
|
||||||
|
parser.add_argument("-n", "--skip_to_animation_number")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
except argparse.ArgumentError as err:
|
except argparse.ArgumentError as err:
|
||||||
print(str(err))
|
print(str(err))
|
||||||
|
@ -85,6 +86,7 @@ def get_configuration():
|
||||||
"quiet" : args.quiet or args.write_all,
|
"quiet" : args.quiet or args.write_all,
|
||||||
"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,
|
||||||
}
|
}
|
||||||
if args.low_quality or args.preview:
|
if args.low_quality or args.preview:
|
||||||
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
|
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
|
||||||
|
@ -96,12 +98,18 @@ def get_configuration():
|
||||||
config["camera_config"] = PRODUCTION_QUALITY_CAMERA_CONFIG
|
config["camera_config"] = PRODUCTION_QUALITY_CAMERA_CONFIG
|
||||||
config["frame_duration"] = PRODUCTION_QUALITY_FRAME_DURATION
|
config["frame_duration"] = PRODUCTION_QUALITY_FRAME_DURATION
|
||||||
|
|
||||||
|
stan = config["skip_to_animation_number"]
|
||||||
|
if stan is not None:
|
||||||
|
config["skip_to_animation_number"] = int(stan)
|
||||||
|
|
||||||
#By default, write to file
|
#By default, write to file
|
||||||
actions = ["write_to_movie", "preview", "show_last_frame"]
|
actions = ["write_to_movie", "preview", "show_last_frame"]
|
||||||
if not any([config[key] for key in actions]):
|
if not any([config[key] for key in actions]):
|
||||||
config["write_to_movie"] = True
|
config["write_to_movie"] = True
|
||||||
config["skip_animations"] = config["show_last_frame"] and not config["write_to_movie"]
|
config["skip_animations"] = any([
|
||||||
|
config["show_last_frame"] and not config["write_to_movie"],
|
||||||
|
config["skip_to_animation_number"],
|
||||||
|
])
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def handle_scene(scene, **config):
|
def handle_scene(scene, **config):
|
||||||
|
@ -203,7 +211,8 @@ def main():
|
||||||
"write_to_movie",
|
"write_to_movie",
|
||||||
"save_frames",
|
"save_frames",
|
||||||
"output_directory",
|
"output_directory",
|
||||||
"save_pngs"
|
"save_pngs",
|
||||||
|
"skip_to_animation_number",
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Scene(object):
|
||||||
"name" : None,
|
"name" : None,
|
||||||
"always_continually_update" : False,
|
"always_continually_update" : False,
|
||||||
"random_seed" : 0,
|
"random_seed" : 0,
|
||||||
|
"skip_to_animation_number" : None,
|
||||||
}
|
}
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
digest_config(self, kwargs)
|
digest_config(self, kwargs)
|
||||||
|
@ -59,6 +60,7 @@ class Scene(object):
|
||||||
self.construct(*self.construct_args)
|
self.construct(*self.construct_args)
|
||||||
if self.write_to_movie:
|
if self.write_to_movie:
|
||||||
self.close_movie_pipe()
|
self.close_movie_pipe()
|
||||||
|
print("Played a total of %d animations"%self.num_plays)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""
|
"""
|
||||||
|
@ -389,9 +391,13 @@ class Scene(object):
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
warnings.warn("Called Scene.play with no animations")
|
warnings.warn("Called Scene.play with no animations")
|
||||||
return
|
return
|
||||||
|
if self.skip_to_animation_number:
|
||||||
|
if self.num_plays + 1 == self.skip_to_animation_number:
|
||||||
|
self.skip_animations = False
|
||||||
if self.skip_animations:
|
if self.skip_animations:
|
||||||
kwargs["run_time"] = 0
|
kwargs["run_time"] = 0
|
||||||
|
|
||||||
|
|
||||||
animations = self.compile_play_args_to_animation_list(*args)
|
animations = self.compile_play_args_to_animation_list(*args)
|
||||||
self.num_plays += 1
|
self.num_plays += 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue