Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 29, 2022
Merged
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
2 changes: 1 addition & 1 deletion manim/animation/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def next_animation(self) -> None:
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:
Expand Down
20 changes: 20 additions & 0 deletions tests/module/animation/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down