1 Star 0 Fork 0

子安/manim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

logo

Build Status Documentation MIT License Manim Subreddit Manim Discord

Manim is an animation engine for explanatory math videos. It's used to create precise animations programmatically, as seen in the videos at 3Blue1Brown.

This repository contains the version of manim used by 3Blue1Brown. There is also a community maintained version at https://github.com/ManimCommunity/manim/. To get help or to join the development effort, please join the discord.

Installation

Manim runs on Python 3.7. You can install it from PyPI via pip:

pip3 install manimlib

System requirements are cairo, ffmpeg, sox, latex (optional, if you want to use LaTeX).

You can now use it via the manim command. For example:

manim my_project.py MyScene

For more options, take a look at the Using manim sections further below.

Directly

If you want to hack on manimlib itself, clone this repository and in that directory execute:

# Install python requirements
python3 -m pip install -r requirements.txt

# Try it out
python3 ./manim.py example_scenes.py SquareToCircle -pl

Directly (Windows)

  1. Install FFmpeg.

  2. Install Cairo. For most users, pycairo‑1.18.0‑cp37‑cp37m‑win32.whl will do fine.

    pip3 install C:\path\to\wheel\pycairo‑1.18.0‑cp37‑cp37m‑win32.whl
    
  3. Install a LaTeX distribution. MiKTeX is recommended.

  4. Install SoX.

  5. Install the remaining Python packages. Make sure that pycairo==1.17.1 is changed to pycairo==1.18.0 in requirements.txt.

    git clone https://github.com/3b1b/manim.git
    cd manim
    pip3 install -r requirements.txt
    python3 manim.py example_scenes.py SquareToCircle -pl
    

Anaconda Install

  • Install sox and latex as above.
  • Create a conda environment using conda env create -f environment.yml
  • WINDOWS ONLY Install pyreadline via pip install pyreadline.

Using virtualenv and virtualenvwrapper

After installing virtualenv and virtualenvwrapper

git clone https://github.com/3b1b/manim.git
mkvirtualenv -a manim -r requirements.txt manim
python3 -m manim example_scenes.py SquareToCircle -pl

Using Docker

Since it's a bit tricky to get all the dependencies set up just right, there is a Dockerfile and Compose file provided in this repo as well as a premade image on Docker Hub. The Dockerfile contains instructions on how to build a manim image, while the Compose file contains instructions on how to run the image.

The prebuilt container image has manim repository included. INPUT_PATH is where the container looks for scene files. You must set the INPUT_PATH environment variable to the absolute path containing your scene file and the OUTPUT_PATH environment variable to the directory where you want media to be written.

  1. Install Docker
  2. Install Docker Compose
  3. Render an animation:
INPUT_PATH=/path/to/dir/containing/source/code \
OUTPUT_PATH=/path/to/output/ \
docker-compose run manim example_scenes.py SquareToCircle -l

The command needs to be run as root if your username is not in the docker group.

You can replace example.scenes.py with any relative path from your INPUT_PATH.

docker diagram

After running the output will say files ready at /tmp/output/, which refers to path inside the container. Your OUTPUT_PATH is bind mounted to this /tmp/output so any changes made by the container to /tmp/output will be mirrored on your OUTPUT_PATH. /media/ will be created in OUTPUT_PATH.

-p won't work as manim would look for video player in the container system, which it does not have.

The first time you execute the above command, Docker will pull the image from Docker Hub and cache it. Any subsequent runs until the image is evicted will use the cached image. Note that the image doesn't have any development tools installed and can't preview animations. Its purpose is building and testing only.

Using manim

Try running the following:

python3 -m manim example_scenes.py SquareToCircle -pl

The -p flag in the command above is for previewing, meaning the video file will automatically open when it is done rendering. The -l flag is for a faster rendering at a lower quality.

Some other useful flags include:

  • -s to skip to the end and just show the final frame.
  • -n <number> to skip ahead to the n'th animation of a scene.
  • -f to show the file in finder (for OSX).

Set MEDIA_DIR environment variable to specify where the image and animation files will be written.

Look through the old_projects folder to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility with those old projects. To run an old project with a guarantee that it will work, you will have to go back to the commit which completed that project.

While developing a scene, the -sp flags are helpful to just see what things look like at the end without having to generate the full animation. It can also be helpful to use the -n flag to skip over some number of animations.

Documentation

Documentation is in progress at eulertour.com/docs.

Walkthrough

Todd Zimmerman put together a tutorial on getting started with manim, which has been updated to run on Python 3.7.

Contributing

Although they are welcome, pull requests to this repository are rarely accepted. Most pull requests should be directed to the community version.

License

All files in the directory from_3b1b, which by and large generate the visuals for 3b1b videos, are copyright 3Blue1Brown.

The general purpose animation code found in the remainder of the repository, on the other hand, is under the MIT license.

All files of this project under the directory "from_3b1b" are copyright 3Blue1Brown LLC and used by permission for this project only. Any other file of this project is available under the MIT license as follow: MIT License Copyright (c) 2018 3Blue1Brown LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Animation engine for explanatory math videos 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

接近5年前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/andrewgithub/manim.git
git@gitee.com:andrewgithub/manim.git
andrewgithub
manim
manim
master

搜索帮助