ManimCommunity / ManimCommunity/manim
Better Transform for Vdicts
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## Description of proposed feature
It would be useful if using Transform on VDicts matched items according to their keys. Basically this:
```python
def transform_vdicts(scene, vdict1, vdict2, run_time=1):
k1 = vdict1.submob_dict.keys()
k2 = vdict2.submob_dict.keys()
transforms = []
for key in k1 - k2:
transforms.append(FadeOut(vdict1[key]))
for key in k2 - k1:
transforms.append(Create(vdict2[key]))
for key in k1 & k2:
transforms.append(Transform(vdict1[key], vdict2[key]))
scene.play(*transforms, run_time=run_time)
```
Right now, I think, Transform just looks at the _order_ of the items, ignoring the keys. Basically it converts the Vdict into a Vgroup.
## How can the new feature be used?
I have a graph, and I store each edge in a vdict:
```python
def graph_to_vdict(G):
vdict = VDict()
pos = nx.shell_layout(G)
for u, v in G.edges:
vdict[i, j] = Line(start=pos[u], end=pos[v])
```
If I have a graph, and add/remove some edges, it's important for the Line objects to be matched up with the same mobjects as before. Otherwise everything will move around unnecessarily.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Transform and VDict entry points, then trace how VDict items are currently converted or matched during animation. Compare the behavior with the proposed key-based matching for shared, added, and removed keys. Done means unchanged keys use the corresponding mobjects while additions are created and removals fade out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100