zl程序教程

您现在的位置是:首页 >  后端

当前栏目

利用您的 Python 技能创建精美的数学动画之 Manim创建解释性数学视频库

Python动画 创建 利用 视频 技能 数学 精美
2023-09-11 14:18:32 时间

什么是Manim

请添加图片描述

Manim 是一个精确动画引擎,专为创建解释性数学视频而设计。请注意,有 2 个版本的 manim。一个由 Grant 创建,一个由 Manim 社区分叉和维护。由于 Manim 社区维护的版本比 Grant 的版本更新更频繁且测试更好,因此我们将使用 Manim 社区维护的版本。

下面是安装方式

pip install manim

开始使用

创建一个从中心生长的蓝色正方形

我们将创建一个从中心开始生长的蓝色正方形。创建动画的代码位于construct派生自Scene.

from manim import * 

class PointMovingOnShapes(Scene):
    def construct(self):
        square = Square(color=BLUE) # Create a square
        square.flip(RIGHT) # Flip the square to the right
        square.rotate(-3 * TAU / 8) # Rotate the square -3/8 * 2*PI 

         # Play the animation of a square growing from the center
        self.play(GrowFromCenter(square))

请添加图片描述