from manim import *
class LifeDemo(Scene):
    def construct(self):
        title = Text("ShrinkToCenter：生命值方块收缩消失", font="STLiti", font_size=28).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        frame = Rectangle(width=5, height=1.2, color=GREY_B, stroke_width=3)
        life = Rectangle(width=4.6, height=0.9, color=RED, fill_opacity=0.7, stroke_width=3)
        self.play(FadeIn(frame), FadeIn(life), run_time=0.8)
        self.play(ShrinkToCenter(life), run_time=2.0)
        note = Text("对象向自身中心缩小直到不可见，灰框是血条外框", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(2.0)
