Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions manim/animation/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ def interpolate_submobject(
def _get_bounds(self, alpha: float) -> tuple[float, float]:
raise NotImplementedError("Please use Create or ShowPassingFlash")

def update_mobjects(self, dt: float) -> None:
if self.suspend_mobject_updating:
dt = 0
super().update_mobjects(dt)


class Create(ShowPartial):
"""Incrementally show a VMobject.
Expand Down
20 changes: 19 additions & 1 deletion tests/module/animation/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from manim import AddTextLetterByLetter, Text
from manim import RIGHT, AddTextLetterByLetter, Create, Dot, Text


def test_non_empty_text_creation():
Expand Down Expand Up @@ -32,3 +32,21 @@ def test_run_time_for_non_empty_text(config):
expected_run_time = np.max((1 / config.frame_rate, run_time_per_char)) * len(s.text)
anim = AddTextLetterByLetter(s, time_per_char=run_time_per_char)
assert anim.run_time == expected_run_time


def test_create_suspends_mobject_updaters():
"""Ensure Create honors suspend_mobject_updating for time-based updaters."""
control = Dot()
control_animation = Create(control, suspend_mobject_updating=True)
control_animation.begin()
control_animation.interpolate(0.5)

dot = Dot()
dot.add_updater(lambda mobject, dt: mobject.shift(RIGHT * dt))

animation = Create(dot, suspend_mobject_updating=True)
animation.begin()
animation.update_mobjects(1)
animation.interpolate(0.5)

assert np.allclose(dot.get_center(), control.get_center())
Loading