from manim import *
class CurveDemo(Scene):
    def construct(self):
        title = Text("MoveAlongPath：沿函数曲线移动一个点", font="STLiti", font_size=32).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        axes = Axes(x_range=[-3, 3, 1], y_range=[0, 6, 1], x_length=8, y_length=4.0,
                    axis_config={"include_tip": True}).shift(UP * 0.2)
        graph = axes.plot(lambda x: x**2, x_range=[-2.35, 2.35], color=GREEN, stroke_width=5)
        dot = Dot(color=YELLOW, radius=0.13).move_to(graph.get_start())
        self.play(Create(axes), Create(graph), FadeIn(dot), run_time=1.0)
        self.play(MoveAlongPath(dot, graph), run_time=3.6, rate_func=linear)
        note = Text("点沿 y = x² 的曲线路径匀速前进", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(1.2)
