API 参考:核心与其他

共 4 个类,按字母排序。每个类含中文说明、继承链、参数表与上手示例,API 文档由 autodoc 从 manim v0.21.0 源码自动生成;带完整中文精讲的类见 API 索引。

CairoRenderer

Cairo 渲染器:默认的 2D 矢量光栅化后端,把 VMobject 画成帧。

参数

file_writer_class

<class 'manim.scene.scene_f…,type[SceneFileWriter]

camera_class

None,type[Camera] | None

skip_animations

False,bool

API 文档

class manim.CairoRenderer(file_writer_class: type[SceneFileWriter] = <class 'manim.scene.scene_file_writer.SceneFileWriter'>, camera_class: type[Camera] | None = None, skip_animations: bool = False, **kwargs: Any)

基类:object

add_frame(frame: PixelArray, num_frames: int = 1) → None

Adds a frame to the video_file_stream

Parameters

frame

The frame to add, as a pixel array.

num_frames

The number of times to add frame.

freeze_current_frame(duration: float) → None

Adds a static frame to the movie for a given duration. The static frame is the current frame.

Parameters

duration

[description]

get_frame() → PixelArray

Gets the current frame as NumPy array.

Returns

PixelArray

NumPy array of pixel values of each pixel in screen. The shape of the array is height x width x 3.

save_static_frame_data(scene: Scene, static_mobjects: Iterable[Mobject]) → PixelArray | None

Compute and save the static frame, that will be reused at each frame to avoid unnecessarily computing static mobjects.

Parameters

scene

The scene played.

static_mobjects

Static mobjects of the scene. If None, self.static_image is set to None.

Returns

PixelArray | None

The static image computed. The return value is None if there are no static mobjects in the scene.

show_frame(scene: Scene) → None

Opens the current frame in the Default Image Viewer of your system.

update_frame(scene: Scene, mobjects: Iterable[Mobject] | None = None, include_submobjects: bool = True, ignore_skipping: bool = True, **kwargs: Any) → None

Update the frame.

Parameters

scene

mobjects

list of mobjects

include_submobjects

ignore_skipping

**kwargs

update_skipping_status() → None

This method is used internally to check if the current animation needs to be skipped or not. It also checks if the number of animations that were played correspond to the number of animations that need to be played, and raises an EndSceneEarlyException if they don't correspond.

CapStyleType

线帽样式枚举:butt/round/square,控制线段端点形状。

API 文档

class manim.CapStyleType(*values)

基类:Enum

LineJointType

线连接样式枚举:miter/round/bevel,控制折角处形状。

API 文档

class manim.LineJointType(*values)

基类:Enum

RendererType

渲染器类型枚举:选择 cairo 或 OpenGL 渲染后端。

API 文档

class manim.RendererType(*values)

基类:Enum

CAIRO = 'cairo'

A renderer based on the cairo backend.

OPENGL = 'opengl'

An OpenGL-based renderer.