from manim import *
import numpy as np
def head(cn, en):
    t = Text(cn, font="STLiti", font_size=27).to_edge(UP)
    s = Text(en, font="Consolas", font_size=20, color=YELLOW).next_to(t, DOWN, buff=0.10)
    return VGroup(t, s)
def foot(cn):
    return Text(cn, font="STLiti", font_size=20, color=YELLOW).to_edge(DOWN)
class ChangeSpeedBasic(Scene):
    def construct(self):
        self.add(head("ChangeSpeed：先加速后减速", "speedinfo / rate_func"))
        line = Line(UP * 2.2, DOWN * 2.2, color=GREY_B).shift(LEFT * 3)
        line2 = line.copy().shift(RIGHT * 6)
        fast = Dot(color=RED, radius=0.16).move_to(line.get_start())
        slow = Dot(color=BLUE, radius=0.16).move_to(line2.get_start())
        self.add(line, line2, fast, slow)
        anim = VGroup(fast, slow).animate.shift(DOWN * 4.4)
        self.play(anim, run_time=3.2, rate_func=rush_into)
        self.wait(0.3)
        self.play(ChangeSpeed(Wait(2.2), speedinfo={0: 0.3, 0.7: 1.8, 1: 0.2}))
        self.play(FadeIn(foot("speedinfo 以字典描述时间缩放，不改变总时长")), run_time=0.4)
        self.wait(1.0)
