返回 Skill 列表
extension
分类: 开发与工程无需 API Key

manimce-best-practices

触发条件:(1) 用户提及“manim”或“Manim Community”或“ManimCE”,(2) 代码包含`from manim import *`,(3) 用户运行`manim` CLI命令,(4) 使用Scene、MathTex、Create()或ManimCE特有的类。最佳实践针对Manim社区版 - 社区维护的Python动画引擎。涵盖场景结构、动画、LaTeX/MathTex、使用ThreeDScene的3D、摄像机控制、样式设置以及CLI使用。不适用于ManimGL/3b1b版本(该版本使用`manimlib`导入和`manimgl` CLI)。

person作者: jakexiaohubgithub

How to use

Read individual rule files for detailed explanations and code examples:

Core Concepts

Creation & Transformation

Text & Math

Styling & Appearance

Positioning & Layout

Coordinate Systems & Graphing

Animation Control

Configuration & CLI

Shapes & Geometry

  • rules/shapes.md - Circle, Square, Rectangle, Polygon, and geometric primitives
  • rules/lines.md - Line, Arrow, Vector, DashedLine, and connectors

Working Examples

Complete, tested example files demonstrating common patterns:

Scene Templates

Copy and modify these templates to start new projects:

Quick Reference

Basic Scene Structure

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)

Render Command

# Basic render with preview
manim -pql scene.py MyScene

# Quality flags: -ql (low), -qm (medium), -qh (high), -qk (4k)
manim -pqh scene.py MyScene

Key Differences from 3b1b/ManimGL

| Feature | Manim Community | 3b1b/ManimGL | |---------|-----------------|--------------| | Import | from manim import * | from manimlib import * | | CLI | manim | manimgl | | Math text | MathTex(r"\pi") | Tex(R"\pi") | | Scene | Scene | InteractiveScene | | Package | manim (PyPI) | manimgl (PyPI) |

Jupyter Notebook Support

Use the %%manim cell magic:

%%manim -qm MyScene
class MyScene(Scene):
    def construct(self):
        self.play(Create(Circle()))

Common Pitfalls to Avoid

  1. Version confusion - Ensure you're using manim (Community), not manimgl (3b1b version)
  2. Check imports - from manim import * is ManimCE; from manimlib import * is ManimGL
  3. Outdated tutorials - Video tutorials may be outdated; prefer official documentation
  4. manimpango issues - If text rendering fails, check manimpango installation requirements. Required System Libs: libpango1.0-dev, libcairo2-dev, libffi-dev, ffmpeg.
  5. PATH issues (Windows) - If manim command not found, use python -m manim or check PATH
  6. Directory Context - Always cd into the directory containing your .py script before rendering to ensure media paths are resolved correctly relative to the project root.

Installation

# Install Manim Community
pip install manim

# Check installation
manim checkhealth

# Required OS Packages (Linux)
# sudo apt-get install libpango1.0-dev libcairo2-dev libffi-dev ffmpeg

Useful Commands

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 plugins