Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed setting ``run_time`` of :class:`.Succession` after creating the animation object (#3003)

Benjamin Hackl3c172e2a8a07
diff --git a/manim/animation/composition.py b/manim/animation/composition.py
index 4c4f1db52..f3848b6a7 100644
--- a/manim/animation/composition.py
+++ b/manim/animation/composition.py
@@ -166,7 +166,7 @@ class Succession(AnimationGroup):
self.update_active_animation(self.active_index + 1)
def interpolate(self, alpha: float) -> None:
- current_time = self.rate_func(alpha) * self.run_time
+ current_time = self.rate_func(alpha) * self.max_end_time
while self.active_end_time is not None and current_time >= self.active_end_time:
self.next_animation()
if self.active_animation is not None and self.active_start_time is not None:
diff --git a/tests/module/animation/test_composition.py b/tests/module/animation/test_composition.py
index 9f2647455..73cc6b0d6 100644
--- a/tests/module/animation/test_composition.py
+++ b/tests/module/animation/test_composition.py
@@ -90,6 +90,26 @@ def test_succession_in_succession_timing():
assert nested_succession.active_animation is None
+def test_timescaled_succession():
+ s1, s2, s3 = Square(), Square(), Square()
+ anim = Succession(
+ FadeIn(s1, run_time=2),
+ FadeIn(s2),
+ FadeIn(s3),
+ )
+ anim.scene = MagicMock()
+ anim.run_time = 42
+ anim.begin()
+ anim.interpolate(0.2)
+ assert anim.active_index == 0
+ anim.interpolate(0.4)
+ assert anim.active_index == 0
+ anim.interpolate(0.6)
+ assert anim.active_index == 1
+ anim.interpolate(0.8)
+ assert anim.active_index == 2
+
+
def test_animationbuilder_in_group():
sqr = Square()
circ = Circle()