from manim import *
class InitScaffoldDemo(Scene):
    """manim init project：一条命令生成可渲染的项目骨架"""
    def construct(self):
        title = Text("manim init project 生成项目骨架", font_size=32).to_edge(UP, buff=0.42)
        self.play(Write(title))
        cmd = Text("$ manim init project my_proj -d", font="Consolas",
                   font_size=26, color=GREEN)
        cmd.next_to(title, DOWN, buff=0.42)
        self.play(FadeIn(cmd, shift=DOWN * 0.2))
        prompt = Text("Template (Axes, Default, MovingCamera) [Default]:",
                      font="Consolas", font_size=19, color=GREY_B)
        prompt.next_to(cmd, DOWN, buff=0.32)
        self.play(FadeIn(prompt, shift=DOWN * 0.15))
        rows = [("my_proj/", 0, BLUE_B), ("|-- main.py", 1, WHITE),
                ("`-- manim.cfg", 1, YELLOW)]
        tree = VGroup()
        for name, depth, color in rows:
            t = Text(name, font="Consolas", font_size=25, color=color)
            t.shift(RIGHT * depth * 0.85)
            tree.add(t)
        tree.arrange(DOWN, buff=0.2, aligned_edge=LEFT).next_to(prompt, DOWN, buff=0.42)
        self.play(LaggedStart(*[FadeIn(t, shift=RIGHT * 0.25) for t in tree],
                              lag_ratio=0.2))
        self.wait(0.4)
        tip = VGroup(
            Text("main.py 自带一个示例场景，生成即可直接渲染", font_size=21),
            Text("manim.cfg 的 [CLI] 段锁定本项目的默认画质与场景名", font_size=21),
            Text("-d 写出的 pixel_height=1920 / pixel_width=1080 是竖屏，横屏需互换",
                 font_size=20, color=RED),
        ).arrange(DOWN, buff=0.15, aligned_edge=LEFT).next_to(tree, DOWN, buff=0.4)
        if tip.width > 12.4:
            tip.scale_to_fit_width(12.4)
        self.play(LaggedStart(*[FadeIn(t, shift=UP * 0.15) for t in tip], lag_ratio=0.25))
        self.wait(1.8)