from manim import *
class CharTransformDemo(Scene):
    def construct(self):
        title = Text("逐个字符变换：Hello 变为 Manim", font="STLiti", font_size=30).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        text = VGroup(*[Text(ch, font_size=64, color=PURPLE) for ch in "Hello"])
        text.arrange(RIGHT, buff=0.08)
        colors = [RED, ORANGE, BLUE, GREEN, YELLOW]
        sizes = [60, 44, 36, 44, 60]
        new_text = VGroup(*[Text(ch, font_size=sizes[i], color=colors[i])
                            for i, ch in enumerate("Manim")])
        new_text.arrange(RIGHT, buff=0.16)
        self.play(FadeIn(text), run_time=0.8)
        self.play(FadeTransformPieces(text, new_text), run_time=2.2)
        note = Text("把目标文本拆成单字符 VGroup，就能逐字变换", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(2.0)
