Skip to content
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

[Bug] Code class's Animation applies to the entire code instead of the changed lines #2302

Closed
Mindev27 opened this issue Jan 13, 2025 · 2 comments
Labels

Comments

@Mindev27
Copy link

Describe the bug

When using Manim's Code object to animate code changes, animations are applied to the entire code block, even if only a single line is added.

Video

CodeAnimation.mp4

Expected behavior

The animation should be applied only to the newly added or modified line of code.

Actual behavior

The animation is applied to the entire code block, including unchanged lines, making it unclear which part of the code was modified.

Code:

from manim import *

class CodeAnimation(Scene):
    def construct(self):
        code1 = '''from manim import *

class Animation(Scene):
    def construct(self):
    
        square = Square(side_length=2.0, color=RED)
        
        self.play(Create(square))
        self.wait()
'''

        code2 = '''from manim import *

class Animation(Scene):
    def construct(self):
    
        square = Square(side_length=2.0, color=RED)
        
        square.shift(LEFT * 2)
        
        self.play(Create(square))
        self.wait()
'''

        rendered_code1 = Code(
            code=code1,
            tab_width=4,
            background="window",
            language="Python",
            font="Monospace",
            style="one-dark",
            line_spacing=1
        )
        
        rendered_code2 = Code(
            code=code2,
            tab_width=4,
            background="window",
            language="Python",
            font="Monospace",
            style="one-dark",
            line_spacing=1
        )

        self.play(Write(rendered_code1))
        self.wait()
        
        self.play(Transform(rendered_code1, rendered_code2))
        self.wait()

Environment

  • Manim version: [v0.18.1]
  • Python version: [3.10.3]
  • Operating system: [Window 11]
@Mindev27 Mindev27 added the bug label Jan 13, 2025
@Mindev27
Copy link
Author

I'll create fix PR soon :)

@Mindev27
Copy link
Author

I mistakenly created this issue in the wrong repository, so I have created a new one in the correct repository.
👉 New Issue Link
I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant