3b1b/manim
GitHub: 3b1b/manim
一个用 Python 编写的精确数学动画引擎,专为创建解释性数学教学视频而设计。
Stars: 88548 | Forks: 7386
[](https://pypi.org/project/manimgl/)
[](http://choosealicense.com/licenses/mit/)
[](https://www.reddit.com/r/manim/)
[](https://discord.com/invite/bYCyhM9Kz2)
[](https://3b1b.github.io/manim/)
Manim 是一个用于精确编程动画的引擎,旨在创建解释性的数学视频。
请注意,manim 有两个版本。这个仓库最初是 [3Blue1Brown](https://www.3blue1brown.com/) 作者的个人项目,用于为这些视频制作动画,视频特定的代码可以在[这里](https://github.com/3b1b/videos)找到。2020 年,一群开发者将其 fork 出来,成为了现在的[社区版](https://github.com/ManimCommunity/manim/),其目标是更加稳定、经过更好的测试、更快地响应社区贡献,并且总体上更友好、更容易上手。有关更多详细信息,请参阅[此页面](https://docs.manim.community/en/stable/faq/installation.html#different-versions)。
## 安装说明
Manim 运行在 Python 3.7 或更高版本上。
系统要求包括 [FFmpeg](https://ffmpeg.org/)、[OpenGL](https://www.opengl.org/) 和 [LaTeX](https://www.latex-project.org)(可选,如果你需要使用 LaTeX)。
对于 Linux,需要 [Pango](https://pango.org) 及其开发头文件。请参阅[这里](https://github.com/ManimCommunity/ManimPango#building)的说明。
### 直接安装
```
# 安装 manimgl
pip install manimgl
# 试一试
manimgl
```
有关更多选项,请查看下方的[使用 manim](#using-manim)部分。
如果你想修改 manimlib 本身,请克隆此仓库并在该目录下执行:
```
# 安装 manimgl
pip install -e .
# 试一试
manimgl example_scenes.py OpeningManimExample
# 或者
manim-render example_scenes.py OpeningManimExample
```
### 直接安装 (Windows)
1. [安装 FFmpeg](https://www.wikihow.com/Install-FFmpeg-on-Windows)。
2. 安装 LaTeX 发行版。推荐使用 [MiKTeX](https://miktex.org/download)。
3. 安装剩余的 Python 包。
git clone https://github.com/3b1b/manim.git
cd manim
pip install -e .
manimgl example_scenes.py OpeningManimExample
### Mac OSX
1. 在终端中使用 homebrew 安装 FFmpeg 和 LaTeX。
brew install ffmpeg mactex
2. 如果你使用的是基于 ARM 的处理器,请安装 Cairo。
arch -arm64 brew install pkg-config cairo
3. 使用以下命令安装最新版本的 manim。
git clone https://github.com/3b1b/manim.git
cd manim
pip install -e .
manimgl example_scenes.py OpeningManimExample(请确保首先将 manimgl 添加到路径中。)
## Anaconda 安装
1. 按照上述说明安装 LaTeX。
2. 使用 `conda create -n manim python=3.9` 创建一个 conda 环境。
3. 使用 `conda activate manim` 激活该环境。
4. 使用 `pip install -e .` 安装 manimgl。
## 使用 manim
尝试运行以下命令:
```
manimgl example_scenes.py OpeningManimExample
```
这应该会弹出一个播放简单场景的窗口。
浏览[示例场景](https://3b1b.github.io/manim/getting_started/example_scenes.html)以查看该库语法、动画类型和对象类型的示例。在 [3b1b/videos](https://github.com/3b1b/videos) 仓库中,你可以看到 3blue1brown 视频的所有代码,不过旧视频的代码可能与最新版本的 manim 不兼容。该仓库的 README 还概述了有关如何设置更具交互性的工作流的一些细节,例如[这个 manim 演示视频](https://www.youtube.com/watch?v=rbu7Zu5X1zI)所示。
在 CLI 中运行时,一些有用的标志包括:
* `-w` 将场景写入文件
* `-o` 将场景写入文件并打开结果
* `-s` 跳到最后并只显示最终帧。
* `-so` 将最终帧保存为图像并显示
* `-n ` 向前跳转到场景的第 `n` 个动画。
* `-f` 使播放窗口全屏
查看 custom_config.yml 以进行进一步的配置。要添加你的自定义设置,你可以编辑此文件,或者将另一个同名文件“custom_config.yml”添加到你运行 manim 的任何目录中。例如,[这个](https://github.com/3b1b/videos/blob/master/custom_config.yml)是用于 3blue1brown 视频的配置。在那里你可以指定视频应该输出到哪里,manim 应该在哪里查找你要读取的图像文件和声音,以及其他有关样式和视频质量的默认值。
### 文档
文档正在 [3b1b.github.io/manim](https://3b1b.github.io/manim/) 中逐步完善。并且还有一个由 [**@manim-kindergarten**](https://manim.org.cn) 维护的中文版本:[docs.manim.org.cn](https://docs.manim.org.cn/)(中文)。
[manim-kindergarten](https://github.com/manim-kindergarten/) 在 [manim_sandbox 仓库](https://github.com/manim-kindergarten/manim_sandbox)中编写并收集了一些有用的额外类和一些视频的代码。
## 贡献
随时欢迎。如上所述,[社区版](https://github.com/ManimCommunity/manim)拥有最活跃的贡献生态系统,具有测试和持续集成,但这里也欢迎提交 pull request。请说明特定更改的动机及其效果的示例。
## 许可证
本项目基于 MIT 许可证。
💡 重量级 MacTeX 包的替代方案。
标签:Python, 动画引擎, 图形渲染, 数学动画, 无后门, 视频制作, 逆向工具