mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Add presenter mode to scenes with -p option
This commit is contained in:
parent
33d2894c16
commit
9a9cc8bdac
3 changed files with 27 additions and 10 deletions
|
@ -65,6 +65,12 @@ def parse_cli():
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Show window in full screen",
|
help="Show window in full screen",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-p", "--presenter_mode",
|
||||||
|
action="store_true",
|
||||||
|
help="scene will stay paused during wait calls until "
|
||||||
|
"space bar or right arrow is hit, like a slide show"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-g", "--save_pngs",
|
"-g", "--save_pngs",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
@ -306,6 +312,7 @@ def get_configuration(args):
|
||||||
"start_at_animation_number": args.start_at_animation_number,
|
"start_at_animation_number": args.start_at_animation_number,
|
||||||
"end_at_animation_number": None,
|
"end_at_animation_number": None,
|
||||||
"preview": not write_file,
|
"preview": not write_file,
|
||||||
|
"presenter_mode": args.presenter_mode,
|
||||||
"leave_progress_bars": args.leave_progress_bars,
|
"leave_progress_bars": args.leave_progress_bars,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ def get_scene_config(config):
|
||||||
"end_at_animation_number",
|
"end_at_animation_number",
|
||||||
"leave_progress_bars",
|
"leave_progress_bars",
|
||||||
"preview",
|
"preview",
|
||||||
|
"presenter_mode",
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Scene(object):
|
||||||
"end_at_animation_number": None,
|
"end_at_animation_number": None,
|
||||||
"leave_progress_bars": False,
|
"leave_progress_bars": False,
|
||||||
"preview": True,
|
"preview": True,
|
||||||
|
"presenter_mode": False,
|
||||||
"linger_after_completion": True,
|
"linger_after_completion": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ class Scene(object):
|
||||||
# Items associated with interaction
|
# Items associated with interaction
|
||||||
self.mouse_point = Point()
|
self.mouse_point = Point()
|
||||||
self.mouse_drag_point = Point()
|
self.mouse_drag_point = Point()
|
||||||
|
self.hold_on_wait = not self.presenter_mode
|
||||||
|
|
||||||
# Much nicer to work with deterministic scenes
|
# Much nicer to work with deterministic scenes
|
||||||
if self.random_seed is not None:
|
if self.random_seed is not None:
|
||||||
|
@ -485,16 +487,21 @@ class Scene(object):
|
||||||
def wait(self, duration=DEFAULT_WAIT_TIME, stop_condition=None):
|
def wait(self, duration=DEFAULT_WAIT_TIME, stop_condition=None):
|
||||||
self.update_mobjects(dt=0) # Any problems with this?
|
self.update_mobjects(dt=0) # Any problems with this?
|
||||||
self.lock_static_mobject_data()
|
self.lock_static_mobject_data()
|
||||||
time_progression = self.get_wait_time_progression(duration, stop_condition)
|
if self.presenter_mode and not self.skip_animations:
|
||||||
last_t = 0
|
while self.hold_on_wait:
|
||||||
for t in time_progression:
|
self.update_frame(dt=1 / self.camera.frame_rate)
|
||||||
dt = t - last_t
|
self.hold_on_wait = True
|
||||||
last_t = t
|
else:
|
||||||
self.update_frame(dt)
|
time_progression = self.get_wait_time_progression(duration, stop_condition)
|
||||||
self.emit_frame()
|
last_t = 0
|
||||||
if stop_condition is not None and stop_condition():
|
for t in time_progression:
|
||||||
time_progression.close()
|
dt = t - last_t
|
||||||
break
|
last_t = t
|
||||||
|
self.update_frame(dt)
|
||||||
|
self.emit_frame()
|
||||||
|
if stop_condition is not None and stop_condition():
|
||||||
|
time_progression.close()
|
||||||
|
break
|
||||||
self.unlock_mobject_data()
|
self.unlock_mobject_data()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -615,6 +622,8 @@ class Scene(object):
|
||||||
self.camera.frame.to_default_state()
|
self.camera.frame.to_default_state()
|
||||||
elif char == "q":
|
elif char == "q":
|
||||||
self.quit_interaction = True
|
self.quit_interaction = True
|
||||||
|
elif char == " ":
|
||||||
|
self.hold_on_wait = False
|
||||||
|
|
||||||
def on_resize(self, width: int, height: int):
|
def on_resize(self, width: int, height: int):
|
||||||
self.camera.reset_pixel_shape(width, height)
|
self.camera.reset_pixel_shape(width, height)
|
||||||
|
|
Loading…
Add table
Reference in a new issue