from manim import *
class HomoDemo(Scene):
    def construct(self):
        title = Text("Homotopy：圆形按同伦函数收缩", font="STLiti", font_size=30).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        ref = Circle(radius=2.2, color=GREY_D, stroke_width=2)
        circle = Circle(radius=2.2, color=BLUE, stroke_width=9)
        self.play(FadeIn(ref), FadeIn(circle), run_time=0.8)
        def homotopy(x, y, z, t):
            return (x * (1 - t), y * (1 - t), z)
        self.play(Homotopy(homotopy, circle), run_time=2.6)
        note = Text("灰圈是初始位置；t=1 时所有点收缩到原点", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(1.8)
