1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| from manim import * class OutputFileDemo(Scene): """-o / --output_file:自定义输出文件名""" def construct(self): title = Text("-o 自定义输出文件名,路径结构不变", font_size=31).to_edge(UP, buff=0.4) self.play(Write(title)) def tree_block(flag, scene_name, file_name, color, tag): head = Text(flag, font_size=22, color=color) lines = [ ("media/", 0, GREY_B), ("|-- videos/", 1, GREY_B), ("| `-- my_file/", 2, GREY_B), ("| `-- 480p15/", 3, GREY_B), ("| `-- " + file_name, 4, color), ("`-- images/", 1, GREY_B), ] body = VGroup() for txt, depth, c in lines: t = Text(txt, font="Consolas", font_size=18, color=c) t.shift(RIGHT * depth * 0.42) body.add(t) body.arrange(DOWN, buff=0.08, aligned_edge=LEFT) note = Text(tag, font_size=18, color=color) return VGroup(head, body, note).arrange(DOWN, buff=0.22, aligned_edge=LEFT) left = tree_block("默认", "MyScene", "MyScene.mp4", BLUE_B, "文件名 = 场景类名") right = tree_block("加 -o demo", "MyScene", "demo.mp4", GREEN_B, "文件名 = 你给的名字") pair = VGroup(left, right).arrange(RIGHT, buff=1.6, aligned_edge=UP) pair.next_to(title, DOWN, buff=0.5) self.play(FadeIn(left, shift=UP * 0.2)) self.play(FadeIn(right, shift=UP * 0.2)) self.wait(0.5) codes = VGroup( Text("manim -qh demo.py MyScene", font="Consolas", font_size=19, color=BLUE_B), Text("manim -qh demo.py MyScene -o demo", font="Consolas", font_size=19, color=GREEN_B), Text("带扩展名会覆盖推断:-o demo.mp4 / -o demo.png", font_size=18, color=YELLOW), ).arrange(DOWN, buff=0.14, aligned_edge=LEFT).next_to(pair, DOWN, buff=0.55) self.play(LaggedStart(*[FadeIn(c, shift=RIGHT * 0.15) for c in codes], lag_ratio=0.25)) self.wait(1.8)
|