名称: manimce-best-practices
描述: |
触发条件:(1) 用户提及 "manim"、"Manim Community" 或 "ManimCE";(2) 代码中包含 from manim import *;(3) 用户运行 manim CLI 命令;(4) 使用 Scene、MathTex、Create() 或 ManimCE 特定类。
Manim Community Edition(社区维护的 Python 动画引擎)的最佳实践。涵盖场景结构、动画、LaTeX/MathTex、使用 ThreeDScene 的 3D 功能、摄像机控制、样式和 CLI 用法。
manimlib 导入和 manimgl CLI)。阅读各个规则文件以获取详细说明和代码示例:
完整且经过测试的示例文件,演示常见模式:
复制并修改这些模板以启动新项目:
from manim import *
class MyScene(Scene):
def construct(self):
# 创建 mobject
circle = Circle()
# 添加到场景(静态)
self.add(circle)
# 或进行动画
self.play(Create(circle))
# 等待
self.wait(1)
# 基础渲染并预览
manim -pql scene.py MyScene
# 质量标志:-ql(低)、-qm(中)、-qh(高)、-qk(4K)
manim -pqh scene.py MyScene
| 特性 | Manim Community | 3b1b/ManimGL |
|---|---|---|
| 导入 | from manim import * |
from manimlib import * |
| CLI | manim |
manimgl |
| 数学文本 | MathTex(r"\pi") |
Tex(R"\pi") |
| 场景 | Scene |
InteractiveScene |
| 包 | manim (PyPI) |
manimgl (PyPI) |
使用 %%manim 单元格魔术命令:
%%manim -qm MyScene
class MyScene(Scene):
def construct(self):
self.play(Create(Circle()))
manim(社区版),而非 manimgl(3b1b 版)from manim import * 是 ManimCE;from manimlib import * 是 ManimGLmanim 命令未找到,请使用 python -m manim 或检查 PATH# 安装 Manim Community
pip install manim
# 检查安装
manim checkhealth
manim -pql scene.py Scene # 预览低质量(开发用)
manim -pqh scene.py Scene # 预览高质量
manim --format gif scene.py # 输出为 GIF
manim checkhealth # 验证安装
manim plugins -l # 列出插件