from manim import *
import numpy as np
class ComplexHomoDemo(Scene):
    def construct(self):
        title = Text("ComplexHomotopy：复平面上的连续形变", font="STLiti", font_size=30).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        plane = ComplexPlane(x_range=[-4, 4, 1], y_range=[-3, 3, 1], x_length=8, y_length=5).shift(DOWN * 0.2)
        self.play(Create(plane), run_time=1.0)
        def hom(z, t):
            return z + 0.35 * t * np.sin(z)
        self.play(ComplexHomotopy(hom, plane), run_time=2.8)
        note = Text("t 从 0 到 1，复函数把每个点连续搬到新位置", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(1.5)
