Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Manim adding simple label updaters in loop

$
0
0

I have two lists of MObjects: elements and labels.I need to add an updater for every label to stay inside corresponding element.

So this is what I do:

self.elements: list[Circle] = []self.labels: list[Tex] = []for i in range(5):    angle = i * (360 / num_elements)    point = self.circle.point_at_angle(angle*DEGREES)    element = Circle(.75, WHITE, fill_opacity=1)    element.move_to(point)    self.elements.append(element)    label = Tex(f'$\\mathbf{i+1}$', color=BLACK, font_size=70)    label.move_to(point)    label.add_updater(lambda mob: mob.move_to(element))    self.labels.append(label)

The problem is that all labels stick to last element:

enter image description here

How do I fix this problem?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>