from manim import *
FONT = "STLiti"
class Demo(Scene):
    def construct(self):
        head = Text("文本渐变着色", font=FONT, font_size=36, color=YELLOW).to_edge(UP, buff=0.5)
        bar = Line(LEFT * 6.6, RIGHT * 6.6, color=BLUE).next_to(head, DOWN, buff=0.12)
        self.play(FadeIn(head), Create(bar), run_time=0.6)
        texts = VGroup(
            Text("hello world").set_color_by_gradient((RED, GREEN)),
            Text("你好，世界").set_color_by_gradient((YELLOW, BLUE)),
            Text("渐变色文本").set_color_by_gradient((BLUE, RED)),
        ).arrange(DOWN, buff=0.55)
        forms = VGroup(
            MathTex(r"a^2 + b^2 = c^2").set_color_by_gradient((RED, GREEN)),
            MathTex(r"E = mc^2").set_color_by_gradient((YELLOW, BLUE)),
            MathTex(r"e^{i\pi} + 1 = 0").set_color_by_gradient((BLUE, RED)),
        ).arrange(DOWN, buff=0.55)
        Group(texts, forms).arrange(RIGHT, buff=2.0).shift(DOWN * 0.5)
        for i in range(3):
            self.play(FadeIn(texts[i]), FadeIn(forms[i]), run_time=0.6)
        self.wait(3.2)
