Skip to content

Latest commit

 

History

History
125 lines (90 loc) · 3.64 KB

README_zh.md

File metadata and controls

125 lines (90 loc) · 3.64 KB

manim_express

image image image image


English | 中文说明

Install

pip install manim_express

以上步骤将安装 manim_express 和 manimlib. 然后就可以在任何代码位置导入使用这个动画库了.

快速开始

  • 渲染一个动画: 3b1b:SquareToCircle

    from manimlib import *
    from manim_express import GlEagerScene
    
    scene = GlEagerScene()
    circle = Circle()
    circle.set_fill(BLUE, opacity=0.5)
    circle.set_stroke(BLUE_E, width=4)
    
    square = Square()
    scene.play(ShowCreation(square))
    scene.play(ReplacementTransform(square, circle))
    
    scene.hold_on()

    与渲染画面交互:

    • 按住 d 键 或 鼠标左键 然后移动鼠标可以改变三维空间中相机的旋转视角.
    • 按住 s 键 或 鼠标右键 然后移动鼠标可以平移相机.
    • 按住 z 键 或 ctrl键 同时滚动鼠标滚轮以缩放画面.
    • 通过 r 重制相机视角.
    • 离开/退出当前动画: q or tab
    • 暂停动画: space or ctrl or alt
    • 前一段动画: LEFT
    • 后一段动画: RIGHT
    • 重新播放当前动画: DOWN
  • manim_express vs Matplotlib:
    使用Eager mode:

    from manimlib import *
    from manim_express import GlEagerScene
    CONFIG.use_online_tex = True # If you don't have installed latex locally.
    theta = np.linspace(0, 2*np.pi, 200)
    x = np.cos(theta)
    y = np.sin(theta)
    
    scene = GlEagerScene()
    scene.plot(x, y, color=GREEN, width=2, scale_ratio=1)
    scene.hold_on()

    使用面向对象的方式:

    from manimlib import *
    from manim_express import GlEagerScene
    import numpy as np
    class ScatterExample(GlEagerScene):
        def clip_1(self):
          n_features = 2
          X = np.random.normal(0, 20, (2000, n_features))
          theta = np.linspace(0, np.pi*2, 150)
          r = 50
          x, y = r*np.cos(theta), r*np.sin(theta)
          self.scatter2d(X[:, 0], X[:, 1], size=.03, color=YELLOW, ratio=0.618)
          self.scatter2d(x, y, size=.03, color=BLUE)
    
    ScatterExample().render()

资源

Examples

  • Bezier curve

    Bezier.mp4
  • GOA model

    ParticleMultiRay.mp4
  • GOA

  • Apply function

  • Double pendulum