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] DashedLine computes num_dashes only once (on init) #3989

Open
hmeine opened this issue Oct 30, 2024 · 0 comments
Open

[BUG] DashedLine computes num_dashes only once (on init) #3989

hmeine opened this issue Oct 30, 2024 · 0 comments

Comments

@hmeine
Copy link

hmeine commented Oct 30, 2024

Description of bug / unexpected behavior

I am animating a DashedLine, using put_start_and_end_on() in an updater. This stretches the dashes, making them inconsistent with other DashedLines, when the length changes.

Expected behavior

I would like to have consistent dash geometries among all my dashed lines, so the number of dashes would have to be recomputed when I change the line length. I would be fine with calling an extra method in my updater, but right now the code in __init__ does not lend itself to being copied into an updater.

How to reproduce the issue

Code for reproducing the problem
class MovingDots(Scene):
    def construct(self):
        d1,d2=Dot(color=BLUE),Dot(color=GREEN)
        dg=VGroup(d1,d2).arrange(RIGHT,buff=1)
        l1=DashedLine(d1.get_center(),d2.get_center()).set_color(RED)
        x=ValueTracker(0)
        y=ValueTracker(0)
        d1.add_updater(lambda z: z.set_x(x.get_value()))
        d2.add_updater(lambda z: z.set_y(y.get_value()))
        l1.add_updater(lambda z: z.put_start_and_end_on(d1.get_center(),d2.get_center()))
        self.add(d1,d2,l1)
        self.play(x.animate.set_value(5))
        self.play(y.animate.set_value(4))
        self.wait()

Additional media files

Images/GIFs
MovingDots.mp4

Additional comments

My DashedLine has a number of properties, making it less attractive to use .become than in the above example. But I am new to manim, so maybe I am overlooking something.

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

No branches or pull requests

1 participant