mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Better convention for -n flag
This commit is contained in:
parent
b9ef9f6fc0
commit
9cfab5c2ed
2 changed files with 17 additions and 17 deletions
|
@ -68,7 +68,7 @@ def get_configuration():
|
|||
for short_arg, long_arg in optional_args:
|
||||
parser.add_argument(short_arg, long_arg, action = "store_true")
|
||||
parser.add_argument("-o", "--output_name")
|
||||
parser.add_argument("-n", "--skip_to_animation_number")
|
||||
parser.add_argument("-n", "--start_at_animation_number")
|
||||
args = parser.parse_args()
|
||||
except argparse.ArgumentError as err:
|
||||
print(str(err))
|
||||
|
@ -88,8 +88,8 @@ def get_configuration():
|
|||
"ignore_waits" : args.preview,
|
||||
"write_all" : args.write_all,
|
||||
"output_name" : args.output_name,
|
||||
"skip_to_animation_number" : args.skip_to_animation_number,
|
||||
"end_after_animation_number" : None,
|
||||
"start_at_animation_number" : args.start_at_animation_number,
|
||||
"end_at_animation_number" : None,
|
||||
}
|
||||
if args.low_quality:
|
||||
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
|
||||
|
@ -101,18 +101,18 @@ def get_configuration():
|
|||
config["camera_config"] = PRODUCTION_QUALITY_CAMERA_CONFIG
|
||||
config["frame_duration"] = PRODUCTION_QUALITY_FRAME_DURATION
|
||||
|
||||
stan = config["skip_to_animation_number"]
|
||||
stan = config["start_at_animation_number"]
|
||||
if stan is not None:
|
||||
if "," in stan:
|
||||
start, end = stan.split(",")
|
||||
config["skip_to_animation_number"] = int(start)
|
||||
config["end_after_animation_number"] = int(end)
|
||||
config["start_at_animation_number"] = int(start)
|
||||
config["end_at_animation_number"] = int(end)
|
||||
else:
|
||||
config["skip_to_animation_number"] = int(stan)
|
||||
config["start_at_animation_number"] = int(stan)
|
||||
|
||||
config["skip_animations"] = any([
|
||||
config["show_last_frame"] and not config["write_to_movie"],
|
||||
config["skip_to_animation_number"],
|
||||
config["start_at_animation_number"],
|
||||
])
|
||||
return config
|
||||
|
||||
|
@ -226,8 +226,8 @@ def main():
|
|||
"write_to_movie",
|
||||
"output_directory",
|
||||
"save_pngs",
|
||||
"skip_to_animation_number",
|
||||
"end_after_animation_number",
|
||||
"start_at_animation_number",
|
||||
"end_at_animation_number",
|
||||
]
|
||||
])
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ class Scene(Container):
|
|||
"name" : None,
|
||||
"always_continually_update" : False,
|
||||
"random_seed" : 0,
|
||||
"skip_to_animation_number" : None,
|
||||
"end_after_animation_number" : None,
|
||||
"start_at_animation_number" : None,
|
||||
"end_at_animation_number" : None,
|
||||
}
|
||||
def __init__(self, **kwargs):
|
||||
Container.__init__(self, **kwargs) # Perhaps allow passing in a non-empty *mobjects parameter?
|
||||
|
@ -407,18 +407,17 @@ class Scene(Container):
|
|||
if len(args) == 0:
|
||||
warnings.warn("Called Scene.play with no animations")
|
||||
return
|
||||
if self.skip_to_animation_number:
|
||||
if self.num_plays + 1 == self.skip_to_animation_number:
|
||||
if self.start_at_animation_number:
|
||||
if self.num_plays == self.start_at_animation_number:
|
||||
self.skip_animations = False
|
||||
if self.end_after_animation_number:
|
||||
if self.num_plays >= self.end_after_animation_number:
|
||||
if self.end_at_animation_number:
|
||||
if self.num_plays >= self.end_at_animation_number:
|
||||
self.skip_animations = True
|
||||
return self #Don't even both with the rest...
|
||||
if self.skip_animations:
|
||||
kwargs["run_time"] = 0
|
||||
|
||||
animations = self.compile_play_args_to_animation_list(*args)
|
||||
self.num_plays += 1
|
||||
|
||||
sync_animation_run_times_and_rate_funcs(*animations, **kwargs)
|
||||
moving_mobjects = self.get_moving_mobjects(*animations)
|
||||
|
@ -434,6 +433,7 @@ class Scene(Container):
|
|||
self.mobjects_from_last_animation = moving_mobjects
|
||||
self.clean_up_animations(*animations)
|
||||
self.continual_update(0)
|
||||
self.num_plays += 1
|
||||
return self
|
||||
|
||||
def clean_up_animations(self, *animations):
|
||||
|
|
Loading…
Add table
Reference in a new issue