'manim set_z_index with value_tracker
The value_tracker seems to not take into account the z.index for a small amount of time at the end when changing its values and I don't really understand why. I've deliberately added lots of set_z_index(1) to try and solve it but nothing did. Here is a sort of minimalist example of the problem:
from manim import *
class RatioHF(MovingCameraScene):
def bar_mouvante(self, x_position, y_position, pourcentage_homme):
rectangle_de_base = \
Rectangle(height=1, width=4,
stroke_color=BLACK).move_to([x_position, y_position, 0]).set_fill(PINK, opacity=0.8)
remplissage_de_base = \
Rectangle(height=1, width=2,
stroke_color=BLACK).move_to([x_position-1, y_position, 0]).set_fill(BLUE, opacity=0.8)
tracker = ValueTracker(0.5).set_z_index(1)
pourcentage_de_base = DecimalNumber(0.5, color=BLACK).move_to(remplissage_de_base.get_critical_point(LEFT) +
np.array([0.5, 0, 0])).set_z_index(1)
pourcentage_de_base.add_updater(lambda m: m.set_value(tracker.get_value())).set_z_index(1)
self.play(FadeIn(rectangle_de_base, remplissage_de_base, pourcentage_de_base))
self.play(
AnimationGroup(
remplissage_de_base.animate.become(
Rectangle(height=remplissage_de_base.height,
width=pourcentage_homme*4,
stroke_color=BLACK).align_to(rectangle_de_base, LEFT+UP).set_fill(BLUE, opacity=0.8)
),
tracker.animate.set_value(pourcentage_homme).set_z_index(1)
)
)
self.wait()
def construct(self):
self.wait()
self.bar_mouvante(0, 0, 0.8)
self.wait()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
