ManimCommunity / ManimCommunity/manim

Code Transform Animation applies to the entire code instead of the changed lines

Open
#4,103 11 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

## unexpected behavior
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
https://github.com/user-attachments/assets/d161622f-e72a-483a-852d-c978c11f9ce9

### 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**:
```py
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()
```

## System specifications
- **Manim version**: [v0.18.1]
- **Python version**: [3.10.3]
- **Operating system**: [Window 11]

Contributor guide

Open the contributing guide

Research direction

Reproduce the provided CodeAnimation example with Manim v0.18.1, focusing on the Code object and Transform(rendered_code1, rendered_code2). Trace how the two code blocks are matched during the transform. Done means unchanged lines remain stable while newly added or modified lines receive the animation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.