A "no operation" animation. Parameters ---------- run_time The amount of time that should pass. stop_condition A function without positional arguments that evaluates to a boolean. The function is evaluated after every new frame has been rendered. Play
| 582 | |
| 583 | |
| 584 | class Wait(Animation): |
| 585 | """A "no operation" animation. |
| 586 | |
| 587 | Parameters |
| 588 | ---------- |
| 589 | run_time |
| 590 | The amount of time that should pass. |
| 591 | stop_condition |
| 592 | A function without positional arguments that evaluates to a boolean. |
| 593 | The function is evaluated after every new frame has been rendered. |
| 594 | Playing the animation stops after the return value is truthy, or |
| 595 | after the specified ``run_time`` has passed. |
| 596 | frozen_frame |
| 597 | Controls whether or not the wait animation is static, i.e., corresponds |
| 598 | to a frozen frame. If ``False`` is passed, the render loop still |
| 599 | progresses through the animation as usual and (among other things) |
| 600 | continues to call updater functions. If ``None`` (the default value), |
| 601 | the :meth:`.Scene.play` call tries to determine whether the Wait call |
| 602 | can be static or not itself via :meth:`.Scene.should_mobjects_update`. |
| 603 | kwargs |
| 604 | Keyword arguments to be passed to the parent class, :class:`.Animation`. |
| 605 | """ |
| 606 | |
| 607 | def __init__( |
| 608 | self, |
| 609 | run_time: float = 1, |
| 610 | stop_condition: Callable[[], bool] | None = None, |
| 611 | frozen_frame: bool | None = None, |
| 612 | rate_func: Callable[[float], float] = linear, |
| 613 | **kwargs, |
| 614 | ): |
| 615 | if stop_condition and frozen_frame: |
| 616 | raise ValueError("A static Wait animation cannot have a stop condition.") |
| 617 | |
| 618 | self.duration: float = run_time |
| 619 | self.stop_condition = stop_condition |
| 620 | self.is_static_wait: bool = frozen_frame |
| 621 | super().__init__(None, run_time=run_time, rate_func=rate_func, **kwargs) |
| 622 | # quick fix to work in opengl setting: |
| 623 | self.mobject.shader_wrapper_list = [] |
| 624 | |
| 625 | def begin(self) -> None: |
| 626 | pass |
| 627 | |
| 628 | def finish(self) -> None: |
| 629 | pass |
| 630 | |
| 631 | def clean_up_from_scene(self, scene: Scene) -> None: |
| 632 | pass |
| 633 | |
| 634 | def update_mobjects(self, dt: float) -> None: |
| 635 | pass |
| 636 | |
| 637 | def interpolate(self, alpha: float) -> None: |
| 638 | pass |
| 639 | |
| 640 | |
| 641 | class Add(Animation): |
no outgoing calls