from manim import *
import numpy as np
class CoordMorphDemo(Scene):
    def construct(self):
        title = Text("ReplacementTransform：曲线形态转换", font="STLiti", font_size=28).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        axes = Axes(x_range=[-3, 3, 1], y_range=[-1, 5, 1], x_length=8, y_length=4,
                    axis_config={"include_tip": True}).shift(DOWN * 0.3)
        g1 = axes.plot(lambda x: 0.5 * x**2, x_range=[-2.5, 2.5], color=BLUE, stroke_width=7)
        g2 = axes.plot(lambda x: 2 * np.cos(x), x_range=[-2.5, 2.5], color=GREEN, stroke_width=7)
        self.play(Create(axes), Create(g1), run_time=1.2)
        self.play(ReplacementTransform(g1, g2), run_time=2.0)
        self.wait(2.2)
