目录
一、简介
Manim(Mathematical Animation)
基于Python的数学动画软件。
二、安装相关软件
- 先完成python3的基础安装,然后
三、在VSCode中进行测试
- 测试用代码
- 运行
生成的mp4文件见输出的“File ready at”之后。
- 或者如下测试
四、manim的基本元素
- Scene: 给动画提供一个播放的场景
- Mobject: 场景中的各种物体,如圆形、方形等。
- Animation: 作用在Mobject之上,用这些物体制作一些动画。
- 命令行参数
其他常用命令行参数
命令行参数 | 作用 |
---|---|
-qh,-qm,-ql | 控制输出视频的画质,分别对应高画质、中等画质、低画质。当该参数不被指定时,默认为高画质。 |
-s | 输出视频的最后一帧(保存为图片) |
-a | 渲染一个py文件中所有的Scene。 |
–renderer[cairo┃opengl] | 使用cairo或者opengl进行渲染(默认使用cairo) |
–disable_caching | 在渲染时禁用缓存 |
五、manim的坐标系统
1. 绝对坐标
坐标为标准右手系——(x,y,z)。
在平面上
默认宽为x,高为y。默认宽为w=128/9,高为h=8。
x轴:在图中是右正,左负。
y轴:在图中是上正,下负。
默认Mobject物件原点的绝对坐标为(0,0,0)。
改变绝对坐标的方法:
- move_to()
- set_x()
- set_y()
- set_z()
测试代码如下:
2. 相对坐标
3. 位置匹配
还可以c.match_color(s),c.match_width(s),c.match_height(s)等