ManimCommunity / ManimCommunity/manim

NumberAnimation appear stacked on top of each other

Open
#3,522 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

Hello everyone,

I am trying to transform a list of numbers into each other.
I am doing this by first looping through the numbers and adding them to textanimation and later grouping them
into an animationgroup and finally playing the group. The reason i wanna do it this way, is because eventually
I would like to create function out of this that just returns the animationgroup. However, I am getting a
strange behaviour from this, where all numbers are stacked on top of each other instead of transforming from
one into the other. If I run it the usually way with self.play() it works as expected. Is there something I am missing?

Below the code:

from manim import *

class NumberAnimation(Scene):
def construct(self):
# Example list of numbers
numbers = [1, 2, 3, 4, 5]

# List to store animations
textAnimation = []

# Create the initial Tex object
current_text = Tex(str(numbers[0]), font_size=48)
self.add(current_text)

# Iterate through the numbers and create ReplacementTransform animations
for number in numbers[1:]:
next_text = Tex(str(number), font_size=48)
animation = ReplacementTransform(current_text, next_text)
#self.play(animation) THIS WORKS AS EXPECTED
textAnimation.append(animation)
current_text = next_text

# Create an AnimationGroup
textAnimationGroup = AnimationGroup(*textAnimation, lag_ratio=1)

# Play the AnimationGroup
self.play(textAnimationGroup)

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named; start by running the provided NumberAnimation.construct example and compare the AnimationGroup behavior with the working self.play(animation) case. Done should include a documented explanation of the differing behavior and a verified reproduction or regression test if a project change is required.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.