from manim import *
class FadeColorDemo(Scene):
    def construct(self):
        title = Text("FadeToColor：图形颜色平滑渐变", font="STLiti", font_size=30).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        square = Square(side_length=2.2, color=BLUE, stroke_width=9)
        self.play(FadeIn(square), run_time=0.6)
        self.play(FadeToColor(square, YELLOW), run_time=1.1)
        self.play(FadeToColor(square, RED), run_time=1.1)
        self.play(FadeToColor(square, GREEN), run_time=1.1)
        note = Text("同一对象依次渐变到黄、红、绿", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(1.2)
