Manim - Python 绘画引擎

发布于:2024-04-27 ⋅ 阅读:(23) ⋅ 点赞:(0)

在这里插入图片描述



关于 Manim

Manim : Mathematical Animation,是由 Grant Sanderson 开发,是一个用于精确编程动画的引擎,专为创建解释性数学视频而设计。


相关教程/博客
-【2024最新教程】Manim动画软件教程,像3blue1brown那样做动画【更新中】
https://www.bilibili.com/video/BV1om411k7Fv/


安装

manim 有两个版本

1、该存储库最初是3Blue1Brown作者的个人项目,旨在为这些视频制作动画,视频特定的代码可在此处获取。
2、2020 年,一群开发人员将其分叉为 社区版本,目标是更稳定、更好的测试、更快地响应社区贡献以及更容易上手。
请参阅此页面了解更多详细信息。

警告:这些说明 仅适用于 ManimGL 。尝试使用这些说明来安装ManimCommunity/manim 或那里的说明来安装此版本将导致问题。
您应该首先决定要安装哪个版本,然后仅按照您所需版本的说明进行操作。

注意:如果直接通过pip安装manim,请注意安装包的名称。这个存储库是 3b1b 的 ManimGL。
包名称是manimgl,代替manimmanimlib
请使用pip install manimgl安装此存储库的版本。


要求

1、Manim 在 Python 3.7 或更高版本上运行。
2、系统要求是FFmpegOpenGLLaTeX(可选,如果您想使用 LaTeX)。
对于 Linux,需要Pango及其开发头文件。请参阅此处的说明。


macOS 安装 FFMpeg 可参考:https://blog.csdn.net/lovechris00/article/details/125921387

brew install ffmpeg mactex

Windows

  1. 安装 FFmpeg
  2. 安装 LaTeX 发行版。推荐MiKTeX

直接使用 pip

# Install manimgl
pip install manimgl

# Try it out
manimgl

使用源码安装

如果您想修改 manimlib,请克隆此存储库并在该目录中执行:

# Install manimgl
pip install -e .

# Try it out
manimgl example_scenes.py OpeningManimExample
# or
manim-render example_scenes.py OpeningManimExample

使用 manim

下载git 源码包后,尝试运行以下命令:

manimgl example_scenes.py OpeningManimExample

这应该会弹出一个窗口,播放一个简单的场景。
一些有用的标志包括:

  • -w将场景写入文件
  • -o将场景写入文件并打开结果
  • -s,跳到最后并只显示最后一帧。
    • -so将最终帧保存到图像中并显示它
  • -n <number>向前跳至n场景的第一个动画。
  • -f使播放窗口全屏显示

Manual

manimgl --help   

ManimGL v1.6.1

usage: manimgl [-h] [-w] [-s] [-l] [-m] [–hd] [–uhd] [-f] [-p] [-g] [-i] [-t] [-q] [-a] [-o] [–finder] [–config] [–file_name FILE_NAME] [-n START_AT_ANIMATION_NUMBER] [-e LINENO] [-r RESOLUTION] [–frame_rate FRAME_RATE] [-c COLOR] [–leave_progress_bars] [–video_dir VIDEO_DIR] [–config_file CONFIG_FILE] [-v] [–log-level LOG_LEVEL] [file] [scene_names …]

positional arguments:
file, Path to file holding the python code for the scene
scene_names, Name of the Scene class you want to see


options:

  • -h, --help, show this help message and exit
  • -w, --write_file, Render the scene as a movie file
  • -s, --skip_animations
    Save the last frame
  • -l, --low_quality, Render at a low quality (for faster rendering)
  • -m, `–medium_quality Render at a medium quality
  • --hd, `, Render at a 1080p
  • --uhd, Render at a 4k
  • -f, --full_screen, Show window in full screen
  • -p, `–presenter_mode Scene will stay paused during wait calls until space bar or right arrow is hit, like a slide show
  • -g, --save_pngs, Save each frame as a png
  • -i, --gif, Save the video as gif
  • -t, --transparent, Render to a movie file with an alpha channel
  • -q, `–quiet
  • -a, --write_all, Write all the scenes from a file
  • -o, --open, Automatically open the saved file once its done
  • --finder, Show the output file in finder
  • --config, Guide for automatic configuration
  • --file_name FILE_NAME
    Name for the movie or image file
  • -n START_AT_ANIMATION_NUMBER, --start_at_animation_number START_AT_ANIMATION_NUMBER
    Start rendering not from the first animation, butfrom another, specified by its index. If you passin two comma separated values, e.g. “3,6”, it`
    will endthe rendering at the second value
  • -e LINENO, --embed LINENO
    Takes a line number as an argument, and resultsin the scene being called as if the line self.embed()was inserted into the scene code at that`
    line number.
  • -r RESOLUTION, --resolution RESOLUTION
    Resolution, passed as “WxH”, e.g. “1920x1080”
  • --frame_rate FRAME_RATE
    Frame rate, as an integer
  • -c COLOR, --color COLOR
    Background color
  • --leave_progress_bars
    Leave progress bars displayed in terminal
  • --video_dir VIDEO_DIR
    Directory to write video
  • --config_file CONFIG_FILE
    Path to the custom configuration file
  • -v, --version, Display the version of manimgl
  • --log-level LOG_LEVEL
    Level of messages to Display, can be DEBUG / INFO / WARNING / ERROR / CRITICAL

2024-04-22(一)


网站公告

今日签到

点亮在社区的每一天
去签到