mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Merge cd10cdbdc1 into 0e83f4b09a
This commit is contained in:
commit
f7f85200c9
2 changed files with 24 additions and 1 deletions
|
|
@ -136,6 +136,11 @@ class ShowPartial(Animation):
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
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():
|
||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue