mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Merge pull request #116 from 3b1b/camera-performance
Better convention for -n flag
This commit is contained in:
commit
755f678df0
2 changed files with 17 additions and 17 deletions
|
@ -68,7 +68,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")
|
parser.add_argument("-n", "--start_at_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))
|
||||||
|
@ -88,8 +88,8 @@ def get_configuration():
|
||||||
"ignore_waits" : args.preview,
|
"ignore_waits" : args.preview,
|
||||||
"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,
|
"start_at_animation_number" : args.start_at_animation_number,
|
||||||
"end_after_animation_number" : None,
|
"end_at_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
|
||||||
|
@ -101,18 +101,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"]
|
stan = config["start_at_animation_number"]
|
||||||
if stan is not None:
|
if stan is not None:
|
||||||
if "," in stan:
|
if "," in stan:
|
||||||
start, end = stan.split(",")
|
start, end = stan.split(",")
|
||||||
config["skip_to_animation_number"] = int(start)
|
config["start_at_animation_number"] = int(start)
|
||||||
config["end_after_animation_number"] = int(end)
|
config["end_at_animation_number"] = int(end)
|
||||||
else:
|
else:
|
||||||
config["skip_to_animation_number"] = int(stan)
|
config["start_at_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"],
|
||||||
config["skip_to_animation_number"],
|
config["start_at_animation_number"],
|
||||||
])
|
])
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
@ -226,8 +226,8 @@ def main():
|
||||||
"write_to_movie",
|
"write_to_movie",
|
||||||
"output_directory",
|
"output_directory",
|
||||||
"save_pngs",
|
"save_pngs",
|
||||||
"skip_to_animation_number",
|
"start_at_animation_number",
|
||||||
"end_after_animation_number",
|
"end_at_animation_number",
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Scene(Container):
|
||||||
"name" : None,
|
"name" : None,
|
||||||
"always_continually_update" : False,
|
"always_continually_update" : False,
|
||||||
"random_seed" : 0,
|
"random_seed" : 0,
|
||||||
"skip_to_animation_number" : None,
|
"start_at_animation_number" : None,
|
||||||
"end_after_animation_number" : None,
|
"end_at_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?
|
||||||
|
@ -407,18 +407,17 @@ class Scene(Container):
|
||||||
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.start_at_animation_number:
|
||||||
if self.num_plays + 1 == self.skip_to_animation_number:
|
if self.num_plays == self.start_at_animation_number:
|
||||||
self.skip_animations = False
|
self.skip_animations = False
|
||||||
if self.end_after_animation_number:
|
if self.end_at_animation_number:
|
||||||
if self.num_plays >= self.end_after_animation_number:
|
if self.num_plays >= self.end_at_animation_number:
|
||||||
self.skip_animations = True
|
self.skip_animations = True
|
||||||
return self #Don't even both with the rest...
|
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
|
||||||
|
|
||||||
animations = self.compile_play_args_to_animation_list(*args)
|
animations = self.compile_play_args_to_animation_list(*args)
|
||||||
self.num_plays += 1
|
|
||||||
|
|
||||||
sync_animation_run_times_and_rate_funcs(*animations, **kwargs)
|
sync_animation_run_times_and_rate_funcs(*animations, **kwargs)
|
||||||
moving_mobjects = self.get_moving_mobjects(*animations)
|
moving_mobjects = self.get_moving_mobjects(*animations)
|
||||||
|
@ -434,6 +433,7 @@ class Scene(Container):
|
||||||
self.mobjects_from_last_animation = moving_mobjects
|
self.mobjects_from_last_animation = moving_mobjects
|
||||||
self.clean_up_animations(*animations)
|
self.clean_up_animations(*animations)
|
||||||
self.continual_update(0)
|
self.continual_update(0)
|
||||||
|
self.num_plays += 1
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def clean_up_animations(self, *animations):
|
def clean_up_animations(self, *animations):
|
||||||
|
|
Loading…
Add table
Reference in a new issue