[BUG] DashedLine computes num_dashes only once (on init)
Opened this issue · 0 comments
hmeine commented
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.