长动画改一个细节就要整体重渲,很浪费时间。用 self.next_section("名字") 把场景切成几段,配合 --save_sections 就能只重渲某一段。示例把画圆、平移、变色分成三段。
完整代码
1 2 3 4 5 6 7 8 9 10 11 12
| from manim import * class SectionedScene(Scene): def construct(self): self.next_section("part1") circle = Circle(color=BLUE) self.play(Create(circle)) self.next_section("part2") self.play(circle.animate.shift(RIGHT * 2)) self.next_section("part3") self.play(circle.animate.set_color(YELLOW)) self.wait(1) self.wait(1.60)
|
演示视频
下载 Python 脚本
要点
next_section() 写在两段动画之间,名字会出现在输出目录里
--save_sections 让每段单独出片,便于局部替换
- 分段不影响总时长,只是给渲染器一个可切分的边界
代码来源:Manim Community 官方教程 Tutorials / Manim’s Output Settings,示例代码按 Manim CE 0.20.1 编写并实跑验证。
主观感受,仅供参考。本文采用 本文采用 CC BY-NC-SA 4.0 许可 协议,
完整转载请注明来自
数学动画引擎。