Manim文档及源码笔记-CE教程BE05英文笔记速览版
Interactivity _ Mathematical Animations WITH EASE
前言
这次筛选到了Behackl博士的教程,逐步拆解,更为细腻~
参考视频在此【或请自行搜索上面的英文标题】;
本页中文版传送门【建设中】;
更新【new】:
- 8月23日
-
- 文首标注了“前言”与“正文”;
-
- 本系列暂告段落,升级了系列目录,放到了文尾;
- 后续更新备忘:文中“【建设中】”的内容;欢迎朋友们催更~
首先,国际通则:Just GET STARTED~ JUST DO IT~
然后,让我们行动起来~
注:
1、代码实践过程根据运行环境及笔记需要略有改动;
2、经过实践理解,加入了一些自己的注释;
3、常见问题及大概率解决方案:
- Python相关:注意缩进、冒号,中英文字符、大小写;
- Manim相关:安装与运行环境;
- Coding相关:检查拼写;
正文
The OpenGL renderer and You
- Different rendering backend( default: Cairo), can utilize GPU
- Activate using --renderer=opengl or by setting config.renderer=“openg”
- Warning: user experience can be somewhat rough
- OpenGL-Mobjects have a different interface( e.g., they inherit from OpenGLMobject instead of Mobject), but most users facing mobjects( Dot, Axes, …) can ben used without changes
- (minor) differences for 3D mobjects, camera control, CLI flags
%%manim -v WARNING -qm -p --renderer=opengl OpenGLIntro
from manim import *
from manim.opengl import *
class OpenGLIntro(Scene):
def construct(self):
hello_world=Tex("Hello world!").scale(3)
self.play(Write(hello_world))
self.play(
self.camera.animate.set_euler_angles(
theta=-10*DEGREES,
phi=50*DEGREES
)
)
self.play(FadeOut(hello_world))
%%manim -v WARNING -qm -p --renderer=opengl OpenGLIntro1
from manim import *
from manim.opengl import *
class OpenGLIntro1(Scene):
def construct(self):
hello_world=Tex("Hello world!").scale(3)
self.play(Write(hello_world))
self.play(
self.camera.animate.set_euler_angles(
theta=-10*DEGREES,
phi=50*DEGREES
)
)
self.play(FadeOut(hello_world))
surface=OpenGLSurface(
lambda u,v: (u,v,u*np.sin(v)+v*np.cos(u)),
u_range=(-3,3),
v_range=(-3,3)
)
surface_mesh=OpenGLSurfaceMesh(surface)
self.play(Create(surface_mesh))
self.play(FadeTransform(surface_mesh,surface))
self.wait()
%%manim -v WARNING -qm -p --renderer=opengl OpenGLIntro2
from manim import *
from manim.opengl import *
class OpenGLIntro2(Scene):
def construct(self):
hello_world=Tex("Hello world!").scale(3)
self.play(Write(hello_world))
self.play(
self.camera.animate.set_euler_angles(
theta=-10*DEGREES,
phi=50*DEGREES
)
)
self.play(FadeOut(hello_world))
surface=OpenGLSurface(
lambda u,v