From c9b6ee57a83bc0d67f14de35318ba08cac4cf133 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 10 Dec 2024 19:21:16 -0600 Subject: [PATCH] Make default_wait_time a piece of scene configuration --- manimlib/constants.py | 4 ---- manimlib/default_config.yml | 4 ++-- manimlib/scene/scene.py | 9 ++++++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manimlib/constants.py b/manimlib/constants.py index c71663e2e2..65e1e4eca4 100644 --- a/manimlib/constants.py +++ b/manimlib/constants.py @@ -34,10 +34,6 @@ DEFAULT_MOBJECT_TO_MOBJECT_BUFFER: float = GLOBAL_CONFIG["sizes"]["default_mobject_to_mobject_buff"] -# In seconds -DEFAULT_WAIT_TIME: float = GLOBAL_CONFIG["default_wait_time"] - - # Standard vectors ORIGIN: Vect3 = np.array([0., 0., 0.]) UP: Vect3 = np.array([0., 1., 0.]) diff --git a/manimlib/default_config.yml b/manimlib/default_config.yml index 8a5d5961ad..8f0f598e17 100644 --- a/manimlib/default_config.yml +++ b/manimlib/default_config.yml @@ -58,6 +58,8 @@ scene: # but defaults can be set here show_animation_progress: False leave_progress_bars: False + # How long does a scene pause on Scene.wait calls + default_wait_time: 1.0 style: tex_template: "default" font: "Consolas" @@ -142,8 +144,6 @@ colors: light_pink: "#DC75CD" green_screen: "#00FF00" orange: "#FF862F" -# How long does a scene pause on Scene.wait calls -default_wait_time: 1.0 # What command to use for ffmpeg ffmpeg_bin: "ffmpeg" universal_import_line: "from manimlib import *" diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index 4a4c67f2f7..06150b198c 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -18,7 +18,6 @@ from manimlib.config import get_camera_config from manimlib.config import get_file_writer_config from manimlib.constants import ARROW_SYMBOLS -from manimlib.constants import DEFAULT_WAIT_TIME from manimlib.event_handler import EVENT_DISPATCHER from manimlib.event_handler.event_type import EventType from manimlib.logger import log @@ -80,14 +79,16 @@ def __init__( show_animation_progress: bool = False, leave_progress_bars: bool = False, presenter_mode: bool = False, + default_wait_time: float = 1.0, ): self.skip_animations = skip_animations self.always_update_mobjects = always_update_mobjects self.start_at_animation_number = start_at_animation_number self.end_at_animation_number = end_at_animation_number + self.show_animation_progress = show_animation_progress self.leave_progress_bars = leave_progress_bars self.presenter_mode = presenter_mode - self.show_animation_progress = show_animation_progress + self.default_wait_time = default_wait_time self.camera_config = merge_dicts_recursively( get_camera_config(), # Global default @@ -593,11 +594,13 @@ def play( def wait( self, - duration: float = DEFAULT_WAIT_TIME, + duration: Optional[float] = None, stop_condition: Callable[[], bool] = None, note: str = None, ignore_presenter_mode: bool = False ): + if duration is None: + duration = self.default_wait_time self.pre_play() self.update_mobjects(dt=0) # Any problems with this? if self.presenter_mode and not self.skip_animations and not ignore_presenter_mode: