from manim import *
class SpeedGroupDemo(Scene):
    def construct(self):
        title = Text("ChangeSpeed：动画组里各元素不同速度", font="STLiti", font_size=30).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        l1 = Line(LEFT * 3, RIGHT * 3, stroke_width=8, color=BLUE).shift(UP * 1.2)
        l2 = Line(LEFT * 3, RIGHT * 3, stroke_width=8, color=RED).shift(DOWN * 1.2)
        self.play(FadeIn(l1), FadeIn(l2), run_time=0.6)
        self.play(ChangeSpeed(AnimationGroup(l1.animate(run_time=2.5).set_color(YELLOW),
                                             l2.animate(run_time=2.5).set_color(GREEN)),
                              speedinfo={0.25: 0.4, 0.6: 2, 1: 0.6}, rate_func=linear))
        note = Text("整组共享一条变速曲线，仍是同时开始同时结束", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(2.4)
