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
| from manim import * class SaveLastFrameDemo(Scene): """-s / --save_last_frame:跳过视频编码,只导出最后一帧""" def construct(self): title = Text("-s 只导出最后一帧,不编码视频", font_size=32).to_edge(UP, buff=0.4) self.play(Write(title)) left = VGroup(*[Rectangle(width=1.15, height=0.78, stroke_color=BLUE, stroke_width=2, fill_color=BLUE, fill_opacity=0.15) for _ in range(3)]).arrange(RIGHT, buff=0.12) left_label = Text("默认:逐帧 → mp4", font_size=21, color=BLUE_B) left_tag = Text("480p15/xxx.mp4", font="Consolas", font_size=17, color=GREY_B) g_left = VGroup(left, left_label, left_tag).arrange(DOWN, buff=0.22) plus = Text("-s", font="Consolas", font_size=30, color=YELLOW) right = Rectangle(width=1.15, height=0.78, stroke_color=GREEN, stroke_width=2, fill_color=GREEN, fill_opacity=0.35) right_label = Text("-s:只存最后一帧 → png", font_size=21, color=GREEN_B) right_tag = Text("images/xxx_ManimCE_v0.20.1.png", font="Consolas", font_size=17, color=GREY_B) g_right = VGroup(right, right_label, right_tag).arrange(DOWN, buff=0.22) row = VGroup(g_left, plus, g_right).arrange(RIGHT, buff=0.85) row.next_to(title, DOWN, buff=0.85) self.play(FadeIn(g_left, shift=UP * 0.2)) self.play(FadeIn(plus, scale=0.6)) self.play(FadeIn(g_right, shift=UP * 0.2)) self.wait(0.4) shapes = VGroup(Circle(radius=0.55, color=BLUE), Square(side_length=0.95, color=YELLOW), Triangle(color=RED).scale(0.75)) shapes.arrange(RIGHT, buff=0.45) stage = VGroup(shapes).next_to(row, DOWN, buff=0.72) self.play(LaggedStart(*[Create(s, run_time=1.1) for s in shapes], lag_ratio=0.35)) self.play(shapes.animate.set_fill(opacity=0.5).scale(1.12)) flash = Flash(shapes.get_center(), color=WHITE, line_length=0.35) stamp = Text("导出这一帧", font_size=22, color=WHITE) stamp.next_to(stage, DOWN, buff=0.3) self.play(flash, FadeIn(stamp, shift=UP * 0.15)) self.wait(1.4)
|