初见manim¶
配置环境¶
Mac上需要用homebrew
安装一些依赖:
brew install py3cairo ffmpeg
# py3cairo 换成 cairo 似乎也可以
brew install pango pkg-config scipy
python -m venv venv
source venv/bin/activate
python3 -m pip install manim
hello world!¶
from manim import *
class SquareToCircle(Scene):
def construct(self):
circle = Circle()
circle.set_fill(PINK, opacity=0.5)
square = Square()
square.rotate(PI / 4)
self.play(Create(square))
self.play(Transform(square, circle))
self.play(FadeOut(square))
渲染结果:
Latex¶
如果需要在视频里渲染Latex需要额外安装tex:
brew install mactex
然后就可以渲染公式啦:
from manim import *
class HelloLaTeX(Scene):
def construct(self):
tex = Tex(r"\LaTeX", font_size=144)
self.add(tex)
渲染结果:
最后更新: 2024-05-29 00:20:03
创建日期: 2023-08-11 15:17:27
创建日期: 2023-08-11 15:17:27