manimce-best-practices
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHow to use
使用方法
Read individual rule files for detailed explanations and code examples:
阅读单个规则文件获取详细说明和代码示例:
Core Concepts
核心概念
- rules/scenes.md - Scene structure, construct method, and scene types
- rules/mobjects.md - Mobject types, VMobject, Groups, and positioning
- rules/animations.md - Animation classes, playing animations, and timing
- rules/scenes.md - Scene结构、construct方法及场景类型
- rules/mobjects.md - Mobject类型、VMobject、Groups及定位
- rules/animations.md - 动画类、播放动画及时间控制
Creation & Transformation
创建与变换
- rules/creation-animations.md - Create, Write, FadeIn, DrawBorderThenFill
- rules/transform-animations.md - Transform, ReplacementTransform, morphing
- rules/animation-groups.md - AnimationGroup, LaggedStart, Succession
- rules/creation-animations.md - Create、Write、FadeIn、DrawBorderThenFill
- rules/transform-animations.md - Transform、ReplacementTransform、形态变换
- rules/animation-groups.md - AnimationGroup、LaggedStart、Succession
Text & Math
文本与数学公式
- rules/text.md - Text mobjects, fonts, and styling
- rules/latex.md - MathTex, Tex, LaTeX rendering, and coloring formulas
- rules/text-animations.md - Write, AddTextLetterByLetter, TypeWithCursor
- rules/text.md - Text mobjects、字体及样式设置
- rules/latex.md - MathTex、Tex、LaTeX渲染及公式着色
- rules/text-animations.md - Write、AddTextLetterByLetter、TypeWithCursor
Styling & Appearance
样式与外观
- rules/colors.md - Color constants, gradients, and color manipulation
- rules/styling.md - Fill, stroke, opacity, and visual properties
- rules/colors.md - 颜色常量、渐变及颜色操作
- rules/styling.md - 填充、描边、透明度及视觉属性
Positioning & Layout
定位与布局
- rules/positioning.md - move_to, next_to, align_to, shift methods
- rules/grouping.md - VGroup, Group, arrange, and layout patterns
- rules/positioning.md - move_to、next_to、align_to、shift方法
- rules/grouping.md - VGroup、Group、排列及布局模式
Coordinate Systems & Graphing
坐标系与绘图
- rules/axes.md - Axes, NumberPlane, coordinate systems
- rules/graphing.md - Plotting functions, parametric curves
- rules/3d.md - ThreeDScene, 3D axes, surfaces, camera orientation
- rules/axes.md - Axes、NumberPlane、坐标系
- rules/graphing.md - 函数绘图、参数曲线
- rules/3d.md - ThreeDScene、3D坐标轴、曲面、相机方向
Animation Control
动画控制
- rules/timing.md - Rate functions, easing, run_time, lag_ratio
- rules/updaters.md - Updaters, ValueTracker, dynamic animations
- rules/camera.md - MovingCameraScene, zoom, pan, frame manipulation
- rules/timing.md - 速率函数、缓动效果、run_time、lag_ratio
- rules/updaters.md - Updaters、ValueTracker、动态动画
- rules/camera.md - MovingCameraScene、缩放、平移、帧操作
Configuration & CLI
配置与CLI
- rules/cli.md - Command-line interface, rendering options, quality flags
- rules/config.md - Configuration system, manim.cfg, settings
- rules/cli.md - 命令行界面、渲染选项、质量标识
- rules/config.md - 配置系统、manim.cfg、设置项
Shapes & Geometry
形状与几何
- rules/shapes.md - Circle, Square, Rectangle, Polygon, and geometric primitives
- rules/lines.md - Line, Arrow, Vector, DashedLine, and connectors
- rules/shapes.md - Circle、Square、Rectangle、Polygon及几何基元
- rules/lines.md - Line、Arrow、Vector、DashedLine及连接器
Working Examples
实战示例
Complete, tested example files demonstrating common patterns:
- examples/basic_animations.py - Shape creation, text, lagged animations, path movement
- examples/math_visualization.py - LaTeX equations, color-coded math, derivations
- examples/updater_patterns.py - ValueTracker, dynamic animations, physics simulations
- examples/graph_plotting.py - Axes, functions, areas, Riemann sums, polar plots
- examples/3d_visualization.py - ThreeDScene, surfaces, 3D camera, parametric curves
完整的已测试示例文件,展示常见使用模式:
- examples/basic_animations.py - 形状创建、文本、延迟动画、路径移动
- examples/math_visualization.py - LaTeX方程、颜色编码数学公式、推导过程
- examples/updater_patterns.py - ValueTracker、动态动画、物理模拟
- examples/graph_plotting.py - 坐标轴、函数、区域、黎曼和、极坐标图
- examples/3d_visualization.py - ThreeDScene、曲面、3D相机、参数曲线
Scene Templates
场景模板
Copy and modify these templates to start new projects:
- templates/basic_scene.py - Standard 2D scene template
- templates/camera_scene.py - MovingCameraScene with zoom/pan
- templates/threed_scene.py - 3D scene with surfaces and camera rotation
复制并修改以下模板以启动新项目:
- templates/basic_scene.py - 标准2D场景模板
- templates/camera_scene.py - 带缩放/平移的MovingCameraScene模板
- templates/threed_scene.py - 带曲面和相机旋转的3D场景模板
Quick Reference
快速参考
Basic Scene Structure
基础场景结构
python
from manim import *
class MyScene(Scene):
def construct(self):
# Create mobjects
circle = Circle()
# Add to scene (static)
self.add(circle)
# Or animate
self.play(Create(circle))
# Wait
self.wait(1)python
from manim import *
class MyScene(Scene):
def construct(self):
# 创建mobjects
circle = Circle()
# 添加到场景(静态)
self.add(circle)
# 或添加动画
self.play(Create(circle))
# 等待
self.wait(1)Render Command
渲染命令
bash
undefinedbash
undefinedBasic render with preview
基础渲染并预览
manim -pql scene.py MyScene
manim -pql scene.py MyScene
Quality flags: -ql (low), -qm (medium), -qh (high), -qk (4k)
质量标识:-ql(低)、-qm(中)、-qh(高)、-qk(4K)
manim -pqh scene.py MyScene
undefinedmanim -pqh scene.py MyScene
undefinedKey Differences from 3b1b/ManimGL
与3b1b/ManimGL的主要区别
| Feature | Manim Community | 3b1b/ManimGL |
|---|---|---|
| Import | | |
| CLI | | |
| Math text | | |
| Scene | | |
| Package | | |
| 特性 | Manim Community | 3b1b/ManimGL |
|---|---|---|
| 导入方式 | | |
| CLI命令 | | |
| 数学文本 | | |
| 场景类 | | |
| 包名称 | | |
Jupyter Notebook Support
Jupyter Notebook支持
Use the cell magic:
%%manimpython
%%manim -qm MyScene
class MyScene(Scene):
def construct(self):
self.play(Create(Circle()))使用单元格魔法命令:
%%manimpython
%%manim -qm MyScene
class MyScene(Scene):
def construct(self):
self.play(Create(Circle()))Common Pitfalls to Avoid
常见误区规避
- Version confusion - Ensure you're using (Community), not
manim(3b1b version)manimgl - Check imports - is ManimCE;
from manim import *is ManimGLfrom manimlib import * - Outdated tutorials - Video tutorials may be outdated; prefer official documentation
- manimpango issues - If text rendering fails, check manimpango installation requirements
- PATH issues (Windows) - If command not found, use
manimor check PATHpython -m manim
- 版本混淆 - 确保使用的是(社区版),而非
manim(3b1b版本)manimgl - 检查导入语句 - 是ManimCE;
from manim import *是ManimGLfrom manimlib import * - 过时教程 - 视频教程可能已过时,优先参考官方文档
- manimpango问题 - 若文本渲染失败,检查manimpango的安装要求
- PATH问题(Windows) - 若命令未找到,使用
manim或检查PATH配置python -m manim
Installation
安装方法
bash
undefinedbash
undefinedInstall Manim Community
安装Manim Community
pip install manim
pip install manim
Check installation
检查安装情况
manim checkhealth
undefinedmanim checkhealth
undefinedUseful Commands
实用命令
bash
manim -pql scene.py Scene # Preview low quality (development)
manim -pqh scene.py Scene # Preview high quality
manim --format gif scene.py # Output as GIF
manim checkhealth # Verify installation
manim plugins -l # List pluginsbash
manim -pql scene.py Scene # 预览低质量版本(开发用)
manim -pqh scene.py Scene # 预览高质量版本
manim --format gif scene.py # 输出为GIF格式
manim checkhealth # 验证安装状态
manim plugins -l # 列出插件