知行迭代
导航
首页
最近更改
随机页面
常用
分类目录
Linux命令
Mediawiki常用
电脑技巧
工具
链入页面
相关更改
特殊页面
页面信息
登录
查看“Manim”的源代码
←
Manim
页面
讨论
阅读
查看源代码
查看历史
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:[
[1]
]
您可以查看和复制此页面的源代码。
Manim是一个用于创建数学动画的Python库。最初由[https://www.3blue1brown.com/ 3Blue1Brown]作者为个人项目而开发。目前由两个版本,一个是3b1b版,一个是manim社区版。 ==简介== ===时间轴=== ===版本=== {| class="wikitable" ! 名称 ! 描述 ! 官网 |- |manim 社区版 | 由 Manim Community 开发团队维护,目标是更稳定易使用。<br />安装:<code>pip install manim</code> | https://github.com/ManimCommunity/manim |- | manim 3b1b版 | 也称ManimGL,通过OpenGL渲染。由 3Blue1Brown 的 Grant Sanderson 维护。<br />安装:<code>pip install manimgl</code> | https://github.com/3b1b/manim |} ===安装=== ====Windows==== * 安装好[[FFmpeg]],命令行输入<code>ffmpeg --version</code>检验。 * 安装好[[LaTeX]],如果需要用到LaTeX则安装。命令行输入<code>latex --version</code>检验。 * 使用如下命令安装 pip install manim {{了解更多 |[https://docs.manim.community/en/stable/installation/windows.html Manim 社区版文档:安装/Windows] }} ==快速入门== 新建一个目录project。新建一个文件<code>scene.py</code>,输入如下代码: <syntaxhighlight lang="python" > from manim import * class CreateCircle(Scene): def construct(self): circle = Circle() # 创建一个圆形 circle.set_fill(PINK, opacity=0.5) # 填充颜色和透明度 self.play(Create(circle)) # 显示在屏幕上 </syntaxhighlight> 打开命令行,进入project目录,执行如下命令: manim -pql scene.py CreateCircle Manim 将输出渲染信息,然后创建一个 MP4 文件。 {{了解更多 |[https://docs.manim.community/en/stable/tutorials/quickstart.html Manim 文档:快速开始] }} ==对象== {{了解更多 |[https://docs.manim.community/en/stable/reference_index/mobjects.html Manim 文档:Mobjects] }} ===几何图形=== {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.html#module-manim.mobject.geometry.arc Manim 文档:几何图形/弧形的] }} ====弧形的==== 都位于manim.mobject.geometry.arc模块 {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.Circle.html#manim.mobject.geometry.arc.Circle Circle] | 圆形 |<code>Circle()</code> <br /><code>Circle(radius=2.0, color=BLUE_B, fill_opacity=1)</code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.Dot.html Dot] | 点 | <code>Dot()</code> <br /><code>Dot(point=LEFT, radius=0.1)</code><br /><code>Dot(color='#FF00FF')</code> |- | | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.geometry.arc.Arc.html Manim 文档:Arc] }} ====线==== {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.Line.html#manim.mobject.geometry.line.Line Line] | 线段 <br />常用函数:<br /><code>put_start_and_end_on(start, end)</code> 设置线的开始和结束坐标 | <code>Line()</code> <br /><code>Line([1,1,0], [2,2,0])</code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.Arrow.html Arrow] | 箭头 | <code>Arrow(start=LEFT, end=RIGHT)</code> <br /><code>Arrow([1,1,0], [2,2,0])</code> |- | | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.geometry.line.html Manim 文档:line] }} ====多边形==== {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.mobject.geometry.polygram.Square.html#manim.mobject.geometry.polygram.Square Square] | 正方形 | <code>Square(side_length=2.0)</code> <br /><code>Square(0.6)</code> |- | | | |- | | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.geometry.polygram.html Manim 文档:polygram] }} ===文本=== 使用[LaTeX]渲染的类:MathTex、SingleStringMathTex、Tex、TexSymbol、Title。 {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.text_mobject.html#module-manim.mobject.text.text_mobject Text] | 文本对象。 | <code>Text('Hello world')</code> <br /><code>Text('你好').set_color(WHITE)</code></code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.text_mobject.MarkupText.html#manim.mobject.text.text_mobject.MarkupText MarkupText] | 标记文本。可以使用[https://pango.gnome.org/ Pango]布局库(类似html)渲染 | <code><nowiki>MarkupText('<span foreground="red" size="x-large">你</span>好,<i>世界</i>!')</nowiki></code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.text_mobject.Paragraph.html Paragraph] | 段落。 | |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.tex_mobject.Title.html#manim.mobject.text.tex_mobject.Title Title] | 标题。基于Tex类 | <code>Title("我是标题")</code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.tex_mobject.MathTex.html#manim.mobject.text.tex_mobject.MathTex MathTex] | 使用LaTeX渲染文本,数学模式。基于SingleStringMathTex类 |<code>MathTex(r"\int_a^b f'(x) dx = f(b)- f(a)")</code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.tex_mobject.Tex.html#manim.mobject.text.tex_mobject.Tex Tex] | 使用LaTeX渲染文本,普通模式。基于MathTex类 | <code>Tex('世界')</code> |- | [https://docs.manim.community/en/stable/reference/manim.mobject.text.code_mobject.Code.html Code] | 高亮显示源代码 | |- | | | |} {{了解更多 |[https://docs.manim.community/en/stable/guides/using_text.html Manim 文档:主题指南/渲染文本和公式] |[https://docs.manim.community/en/stable/reference/manim.mobject.text.html Manim 文档:text] }} === 表格 === {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.table.html Manim 文档:table] }} === 图像 === {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.mobject.types.image_mobject.ImageMobject.html ImageMobject] | 显示图像,通过文件或numpy数组。可以是相对路径或绝对路径 | <code>ImageMobject('picture.jpg')</code> <br /><code>ImageMobject(np.uint8([[0, 100, 30, 200],[255, 0, 5, 33]]))</code> |- | AbstractImageMobject | | |- |ImageMobjectFromCamera | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.types.image_mobject.html Manim 文档:image_mobject] }} === 矢量化 === {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.mobject.types.vectorized_mobject.VGroup.html VGroup] | 组合多个实例,以便一起操作,如缩放、移动等。 <br /> 添加元素可以使用<code>add()</code>、<code>+</code>和<code>+=</code>,删除元素使用<code>remove()</code>、<code>-</code>和<code>-=</code> <br />常用方法:<br /><code>arrange()</code> 对齐。<code>VGroup(t1, t2).arrange(direction=DOWN, aligned_edge=LEFT)</code> | <code>VGroup(c1, c2, c3)</code> |- | | | |- | | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.mobject.types.vectorized_mobject.html Manim 文档:vectorized_mobject] }} ==动画== === 动画 === {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.animation.animation.Animation.html animation] | 动画。 | <code>circle_1.animate(run_time=1, lag_ratio=0.1).shift(UP * 2)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.animation.Wait.html Wait] | 等待动画,无操作。 | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.animation.animation.html Manim 文档:animation] }} ===改变=== {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.animation.changing.AnimatedBoundary.html#manim.animation.changing.AnimatedBoundary AnimatedBoundary] | 边框颜色变化动画。 | <code>AnimatedBoundary(Text("闪耀!"), colors=[RED, GREEN, BLUE], cycle_rate=3)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.changing.TracedPath.html TracedPath] | 追踪返回点的路径。 | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.animation.changing.html Manim 文档:changing] }} === 显示或移除 === {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.animation.creation.Create.html Create] | 增量显示一个 VMobject | <code>Create(Square())</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.creation.Uncreate.html Uncreate] | 移除一个 VMobject动画 | <code>Uncreate(Square())</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.creation.Write.html Write] | 模拟手写一个Text或VMobject | <code>Text("Hello", font_size=120)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.creation.Unwrite.html Unwrite] | 模拟手动擦除一个Text或VMobject | |- | [https://docs.manim.community/en/stable/reference/manim.animation.creation.AddTextLetterByLetter.html AddTextLetterByLetter] | 逐个字母显示文本 | <code>AddTextLetterByLetter(>Text("Hello"))</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.creation.AddTextWordByWord.html#manim.animation.creation.AddTextWordByWord AddTextWordByWord ] | 逐个单词显示文本 | <code>AddTextWordByWord(>Text("Hello, World"))</code> |- |[https://docs.manim.community/en/stable/reference/manim.animation.creation.ShowIncreasingSubsets.html ShowIncreasingSubsets] | 逐个显示VGroup的元素VMobject,之前显示子对象不消失。 |<code>ShowIncreasingSubsets( VGroup(Dot(), Square(), Triangle()) )</code> |- |[https://docs.manim.community/en/stable/reference/manim.animation.creation.ShowSubmobjectsOneByOne.html ShowSubmobjectsOneByOne] | 逐个显示VGroup的元素VMobject,之前显示子对象不显示。 |<code>ShowIncreasingSubsets( VGroup(Dot(), Square(), Triangle()) )</code> |- |[https://docs.manim.community/en/stable/reference/manim.animation.creation.DrawBorderThenFill.html DrawBorderThenFill] |首先绘制边框,然后显示填充。 |<code>DrawBorderThenFill(Square(fill_opacity=1, fill_color=ORANGE))</code> |- |[https://docs.manim.community/en/stable/reference/manim.animation.creation.SpiralIn.html SpiralIn] | 螺旋飞入动画 | |- |[https://docs.manim.community/en/stable/reference/manim.animation.creation.ShowPartial.html ShowPartial] | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.animation.creation.html Manim 文档:creation] }} ===淡入淡出 === {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.animation.fading.FadeIn.html FadeIn] | 淡入 <br /><br />参数:<br />mobjects – 要淡入的 mobjects。<br />shift – mobject 在淡入时移动的向量。<br />target_position – mobject 在淡入时开始的位置。如果另一个 mobject 被指定为目标位置,则使用它的中心。<br />scale – mobject 在淡入时重新缩放到其原始大小之前最初缩放的因子。 | <code>FadeIn(Text("hello"))</code> <br /><code>FadeIn(Text("hello"), shift=DOWN)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.fading.FadeOut.html FadeOut] | 淡出 参数同淡入 | <code>FadeOut(Text("hello"))</code> <br /><code>FadeIn(Text("hello"), scale=0.5)</code> |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.animation.fading.html Manim 文档:fading] }} === 生长 === {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.animation.growing.GrowFromCenter.html GrowFromCenter] | 从中心生长 <br /><br />参数:<br />mobject – 要引入的 mobjects。<br />point_color – mobject 生长完成前的颜色。 |<code>GrowFromCenter(Square())</code> <br /><code>GrowFromCenter(Square(), point_color=RED)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.growing.GrowFromPoint.html GrowFromPoint] | 从一个点生长 <br /><br />参数:mobject – 要引入的 mobjects。<br />point – mobject 增长的起点。<br />oint_color –生长完成前的颜色 | <code>GrowFromPoint(Square(), ORIGIN))</code> <br /><code><code>GrowFromPoint(Square(), [-2, 2, 0]))</code></code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.growing.GrowFromEdge.html GrowFromEdge] | 从一个边生长 | <code>GrowFromEdge(Square(), RIGHT)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.growing.SpinInFromNothing.html SpinInFromNothing] | 从中心旋转生长 <br /><br />参数:<br />angle – mobject 达到其完整大小之前的旋转量。。例如 2*PI 表示一次完整旋转 | <code>SpinInFromNothing(Square())</code><br /><code>SpinInFromNothing(Square(), angle=2 * PI)</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.growing.GrowArrow.html GrowArrow] | 箭头生长 | <code>GrowArrow(Arrow())</code> |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.animation.growing.html Manim 文档:growing] }} ===吸引注意力=== {| class="wikitable" ! 名称 ! 描述 ! 示例 |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.Wiggle.html Wiggle] | 摇摆 | <code>Wiggle(Text("Wiggle"))</code> |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.ApplyWave.html ApplyWave] | 波浪 | |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.Circumscribe.html Circumscribe] | 周围画线 | |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.Flash.html Flash] | 闪光 | |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.FocusOn.html FocusOn] | 专注于 | |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.Indicate.html Indicate] | 注明,通过临时调整大小和颜色来突出。 | |- | [https://docs.manim.community/en/stable/reference/manim.animation.indication.ShowPassingFlash.html ShowPassingFlash] | 每帧只显示 VMobject 的一小部分。 | |- | | | |} {{了解更多 |[https://docs.manim.community/en/stable/reference/manim.animation.indication.html Manim 文档:indication] }} === 变换 === === 运动 === ==相机== ==命令行和配置== ==场景== ==资源== ===官网=== * Manim 3b1b版官网:https://github.com/3b1b/manim * Manim 3b1b版文档:https://3b1b.github.io/manim/ * Manim 3b1b版中文文档:https://docs.manim.org.cn/development/about.html * Manim 社区版官网: https://www.manim.community/ * Manim 社区版文档:https://docs.manim.community/ * Manim 社区版源代码:https://github.com/ManimCommunity/manim ===文章=== *[https://github.com/cai-hust/manim-tutorial-CN cai-hust/manim-tutorial-CN:manim中文入门教程]
本页使用的模板:
模板:了解更多
(
查看源代码
)
返回至“
Manim
”。