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

Better Transform for Vdicts #3802

Open
thomasahle opened this issue Jun 10, 2024 · 0 comments
Open

Better Transform for Vdicts #3802

thomasahle opened this issue Jun 10, 2024 · 0 comments
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)

Comments

@thomasahle
Copy link

Description of proposed feature

It would be useful if using Transform on VDicts matched items according to their keys. Basically this:

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:

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.

@thomasahle thomasahle added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant