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

After become(), colors of the two VMobjects are linked #3505

Closed
regnarg opened this issue Dec 7, 2023 · 1 comment · Fixed by #3508
Closed

After become(), colors of the two VMobjects are linked #3505

regnarg opened this issue Dec 7, 2023 · 1 comment · Fixed by #3508
Assignees
Labels
issue:bug Something isn't working... For use in issues

Comments

@regnarg
Copy link

regnarg commented Dec 7, 2023

Description of bug / unexpected behavior

After calling a.become(b), where a and b are both VMobjects, their colors become linked. Changing color of a (e.g. with set_stroke also changes color of b and vice versa.

Expected behavior

After become() call, the two Mobjects should be independent and should change colors independently.

How to reproduce the issue

Code for reproducing the problem
from manim import *

class PromoScene(Scene):
    def construct(self):
        a = Circle()
        b = Square()
        self.add(a)
        self.add(b)
        b.become(a)
        b.shift(1*RIGHT)
        b.set_stroke(YELLOW, opacity=1)
        self.wait(1)

Additional media files

Images/GIFs Result I get:

got

Expected:

expected

@regnarg
Copy link
Author

regnarg commented Dec 7, 2023

This seems to fix the issue:

diff '--color=auto' -rubp manim.orig/mobject/types/vectorized_mobject.py manim/mobject/types/vectorized_mobject.py
--- manim.orig/mobject/types/vectorized_mobject.py	2023-12-07 18:55:34.234530207 +0100
+++ manim/mobject/types/vectorized_mobject.py	2023-12-07 18:55:39.241205514 +0100
@@ -1692,7 +1692,7 @@ class VMobject(Mobject):
                 interpolate(getattr(mobject1, attr), getattr(mobject2, attr), alpha),
             )
             if alpha == 1.0:
-                setattr(self, attr, getattr(mobject2, attr))
+                setattr(self, attr, copy.deepcopy(getattr(mobject2, attr)))
 
     def pointwise_become_partial(
         self,

@regnarg regnarg changed the title After become(), colors of the two Mobjects are linked After become(), colors of the two VMobjects are linked Dec 7, 2023
@MrDiver MrDiver self-assigned this Dec 8, 2023
@MrDiver MrDiver added the issue:bug Something isn't working... For use in issues label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue:bug Something isn't working... For use in issues
Projects
Status: 🆕 New
2 participants