from manim import *
class WriteAllDemo(Scene):
    """-a / --write_all：一个文件里所有场景一起渲染"""
    def construct(self):
        title = Text("-a 一次渲染文件里所有场景", font_size=32).to_edge(UP, buff=0.4)
        self.play(Write(title))
        names = ["Intro", "Demo", "Outro"]
        cards = VGroup()
        for i, n in enumerate(names):
            box = RoundedRectangle(corner_radius=0.1, width=3.05, height=1.5,
                                   stroke_color=TEAL, stroke_width=2,
                                   fill_color=TEAL, fill_opacity=0.1)
            cls = Text("class " + n + "(Scene)", font="Consolas", font_size=16, color=TEAL)
            inner = VGroup(cls).move_to(box.get_center())
            cards.add(VGroup(box, inner))
        cards.arrange(RIGHT, buff=0.4).next_to(title, DOWN, buff=0.7)
        self.play(LaggedStart(*[FadeIn(c, shift=UP * 0.2) for c in cards], lag_ratio=0.2))
        self.wait(0.4)
        # 不用 -a：只出一个
        solo = VGroup(
            Text("不加 -a：只渲染你指定的那个场景", font_size=20, color=GREY_B),
            Text("manim -ql f.py Demo  ->  Demo.mp4", font="Consolas",
                 font_size=18, color=GREY_B),
        ).arrange(DOWN, buff=0.1, aligned_edge=LEFT)
        # 加 -a：三个都出
        allthree = VGroup(
            Text("加 -a：三个场景全部渲染", font_size=20, color=GREEN),
            VGroup(Text("manim -ql f.py -a  ->  3 ", font="Consolas",
                        font_size=18, color=GREEN),
                   Text("个 mp4", font_size=18, color=GREEN)).arrange(RIGHT, buff=0.04),
        ).arrange(DOWN, buff=0.1, aligned_edge=LEFT)
        cmps = VGroup(solo, allthree).arrange(DOWN, buff=0.4, aligned_edge=LEFT)
        cmps.next_to(cards, DOWN, buff=0.75)
        self.play(FadeIn(solo, shift=RIGHT * 0.15))
        self.wait(0.3)
        self.play(FadeIn(allthree, shift=RIGHT * 0.15))
        self.wait(0.3)
        outs = VGroup(*[Text(n + ".mp4", font="Consolas", font_size=17, color=GREEN)
                        .next_to(cards[i], DOWN, buff=0.16) for i, n in enumerate(names)])
        self.play(LaggedStart(*[FadeIn(o, shift=DOWN * 0.2) for o in outs], lag_ratio=0.25))
        self.wait(0.4)
        tail = Text("注意：-a 只按场景类名排序执行，不保证你想要的先后", font_size=19,
                    color=YELLOW)
        tail.next_to(cmps, DOWN, buff=0.45)
        self.play(FadeIn(tail, shift=UP * 0.12))
        self.wait(1.6)