API 参考:动画(animation)

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

Add

把 Mobject 加入场景播放序列的动画:与其他动画组合时控制「何时真正把对象放上来」,常与 Succession 搭配精排时序。

继承关系

G Animation Animation Add Add Animation->Add

参数

快速上手

self.play(Add(dot))

API 文档

class manim.Add(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

finish() → None

Finish the animation.

This method gets called when the animation is over.

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

update_mobjects(dt: float) → None

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

AddTextLetterByLetter

让 Text 逐字母浮现,每个字母带微小放大效果,模拟打字机输入,可设置每字符耗时。

继承关系

G Animation Animation ShowIncreasingSubsets ShowIncreasingSubsets Animation->ShowIncreasingSubsets AddTextLetterByLetter AddTextLetterByLetter ShowIncreasingSubsets->AddTextLetterByLetter

参数

text

—,Text

suspend_mobject_updating

False,bool

int_func

<ufunc 'ceil'>

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

time_per_char

0.1,float

run_time

None,float | None

reverse_rate_function

False

introducer

True

快速上手

self.play(AddTextLetterByLetter(text))

API 文档

class manim.AddTextLetterByLetter(mobject=None, *args, use_override=True, **kwargs)

基类:ShowIncreasingSubsets

AddTextWordByWord

让 Text 逐词浮现,按空格分词,适合字幕式进场。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup Succession Succession AnimationGroup->Succession AddTextWordByWord AddTextWordByWord Succession->AddTextWordByWord

参数

text_mobject

—,Text

run_time

None,float

time_per_char

0.06,float

快速上手

self.play(AddTextWordByWord(text))

API 文档

class manim.AddTextWordByWord(mobject=None, *args, use_override=True, **kwargs)

基类:Succession

AnimatedBoundary

围绕 VMobject 持续流动的虚线边界动画,常用于高亮某个对象「正在被讨论」。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject VGroup VGroup VMobject->VGroup AnimatedBoundary AnimatedBoundary VGroup->AnimatedBoundary

参数

vmobject

—,VMobject

colors

[ManimColor('#29ABCA'), Man…

max_stroke_width

3,float

cycle_rate

0.5,float

back_and_forth

True,bool

draw_rate_func

<function smooth at 0x7f16b…,RateFunction

fade_rate_func

<function smooth at 0x7f16b…,RateFunction

快速上手

self.add(AnimatedBoundary(circle))

API 文档

class manim.AnimatedBoundary(vmobject: ~manim.mobject.types.vectorized_mobject.VMobject, colors: ~collections.abc.Sequence[~manim.utils.color.core.ManimColor | int | str | ~numpy._typing._array_like.NDArray[~numpy.int64] | tuple[int, int, int] | ~numpy._typing._array_like.NDArray[~numpy.float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float]] = [ManimColor('#29ABCA'), ManimColor('#9CDCEB'), ManimColor('#236B8E'), ManimColor('#736357')], max_stroke_width: float = 3, cycle_rate: float = 0.5, back_and_forth: bool = True, draw_rate_func: ~manim.utils.rate_functions.RateFunction = <function smooth>, fade_rate_func: ~manim.utils.rate_functions.RateFunction = <function smooth>, **kwargs: ~typing.Any)

基类:VGroup

Animation

一切动画的基类。自定义动画时继承它并实现 interpolate():给定 alpha(0 到 1)描述画面状态。

参数

mobject

—

lag_ratio

0.0,float

run_time

1.0,float

rate_func

<function smooth at 0x7f16b…,Callable[[float], float]

reverse_rate_function

False,bool

name

None,str

remover

False,bool

suspend_mobject_updating

True,bool

introducer

False,bool

_on_finish

<function Animation.<lambda…,Callable[[Scene], None]

use_override

True,bool

快速上手

class Fade(Animation):
    def interpolate(self, alpha):
        self.mobject.set_opacity(alpha)

API 文档

class manim.Animation(mobject=None, *args, use_override=True, **kwargs)

基类:object

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

copy() → Animation

Create a copy of the animation.

Returns

Animation

A copy of self

finish() → None

Finish the animation.

This method gets called when the animation is over.

get_all_mobjects() → Sequence[Mobject | OpenGLMobject]

Get all mobjects involved in the animation.

Ordering must match the ordering of arguments to interpolate_submobject

Returns

Sequence[Mobject]

The sequence of mobjects.

get_all_mobjects_to_update() → list[Mobject]

Get all mobjects to be updated during the animation.

Returns

List[Mobject]

The list of mobjects to be updated during the animation.

get_rate_func() → Callable[[float], float]

Get the rate function of the animation.

Returns

Callable[[float], float]

The rate function of the animation.

get_run_time() → float

Get the run time of the animation.

Returns

float

The time the animation takes in seconds.

get_sub_alpha(alpha: float, index: int, num_submobjects: int) → float

Get the animation progress of any submobjects subanimation.

Parameters

alpha

The overall animation progress

index

The index of the subanimation.

num_submobjects

The total count of subanimations.

Returns

float

The progress of the subanimation.

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

is_introducer() → bool

Test if the animation is an introducer.

Returns

bool

True if the animation is an introducer, False otherwise.

is_remover() → bool

Test if the animation is a remover.

Returns

bool

True if the animation is a remover, False otherwise.

classmethod set_default(**kwargs) → None

Sets the default values of keyword arguments.

If this method is called without any additional keyword arguments, the original default values of the initialization method of this class are restored.

Parameters

kwargs

Passing any keyword argument will update the default values of the keyword arguments of the initialization function of this class.

Examples

class ChangeDefaultAnimation(Scene):
    def construct(self):
        Rotate.set_default(run_time=2, rate_func=rate_functions.linear)
        Indicate.set_default(color=None)

        S = Square(color=BLUE, fill_color=BLUE, fill_opacity=0.25)
        self.add(S)
        self.play(Rotate(S, PI))
        self.play(Indicate(S))

        Rotate.set_default()
        Indicate.set_default()
set_name(name: str) → Animation

Set the name of the animation.

Parameters

name

The new name of the animation.

Returns

Animation

self

set_rate_func(rate_func: Callable[[float], float]) → Animation

Set the rate function of the animation.

Parameters

rate_func

The new function defining the animation progress based on the relative runtime (see rate_functions).

Returns

Animation

self

set_run_time(run_time: float) → Animation

Set the run time of the animation.

Parameters

run_time

The new time the animation should take in seconds.

备注

The run_time of an animation should not be changed while it is already running.

Returns

Animation

self

update_mobjects(dt: float) → None

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

AnimationGroup

把多个动画打包同时播放,可用 lag_ratio 让组内动画依次错开,是最常用的复合动画容器。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup

参数

group

None

run_time

None,float | None

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

lag_ratio

0,float

快速上手

self.play(AnimationGroup(FadeIn(a), GrowFromCenter(b), lag_ratio=0.5))

API 文档

class manim.AnimationGroup(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

build_animations_with_timings() → None

Creates a list of triplets of the form (anim, start_time, end_time).

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

finish() → None

Finish the animation.

This method gets called when the animation is over.

get_all_mobjects() → Sequence[Mobject | OpenGLMobject]

Get all mobjects involved in the animation.

Ordering must match the ordering of arguments to interpolate_submobject

Returns

Sequence[Mobject]

The sequence of mobjects.

init_run_time(run_time: float | None) → float

Calculates the run time of the animation, if different from run_time.

Parameters

run_time

The duration of the animation in seconds.

Returns

run_time

The duration of the animation in seconds.

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

update_mobjects(dt: float) → None

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

ApplyComplexFunction

把复变函数作用到每个点的复坐标上,适合做共形变换等复分析可视化。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod ApplyComplexFunction ApplyComplexFunction ApplyMethod->ApplyComplexFunction

参数

function

—,types.MethodType

mobject

—,Mobject

快速上手

self.play(ApplyComplexFunction(lambda z: z**2, plane))

API 文档

class manim.ApplyComplexFunction(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyMethod

ApplyFunction

用任意函数逐点变形 Mobject:先复制再插值到新形状,直观展示函数对图形的变换效果。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyFunction ApplyFunction Transform->ApplyFunction

参数

function

—,types.MethodType

mobject

—,Mobject

快速上手

self.play(ApplyFunction(lambda m: m.shift(UP), mob))

API 文档

class manim.ApplyFunction(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

ApplyMatrix

用 2×2 矩阵对平面做线性变换,传入 numpy 矩阵即可,线性代数课的标配。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod ApplyPointwiseFunction ApplyPointwiseFunction ApplyMethod->ApplyPointwiseFunction ApplyMatrix ApplyMatrix ApplyPointwiseFunction->ApplyMatrix

参数

matrix

—,np.ndarray

mobject

—,Mobject

about_point

array([0., 0., 0.]),np.ndarray

快速上手

self.play(ApplyMatrix([[1, 1], [0, 1]], square))

API 文档

class manim.ApplyMatrix(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyPointwiseFunction

ApplyMethod

把任意 Mobject 方法(如 shift、set_color)包装成动画播放,是 mobject.animate 语法的底层实现。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod

参数

快速上手

self.play(ApplyMethod(dot.shift, UP))

API 文档

class manim.ApplyMethod(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

ApplyPointwiseFunction

对曲线上每个点应用 R³ 向量函数,比 ApplyFunction 更底层,直接操作点集。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod ApplyPointwiseFunction ApplyPointwiseFunction ApplyMethod->ApplyPointwiseFunction

参数

function

—,types.MethodType

mobject

—,Mobject

run_time

3.0,float

快速上手

self.play(ApplyPointwiseFunction(lambda p: p + UP, line))

API 文档

class manim.ApplyPointwiseFunction(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyMethod

ApplyPointwiseFunctionToCenter

以对象中心为原点应用逐点函数,避免整体平移,适合「原地扭曲」效果。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod ApplyPointwiseFunction ApplyPointwiseFunction ApplyMethod->ApplyPointwiseFunction ApplyPointwiseFunctionToCenter ApplyPointwiseFunctionToCenter ApplyPointwiseFunction->ApplyPointwiseFunctionToCenter

参数

function

—,types.MethodType

mobject

—,Mobject

API 文档

class manim.ApplyPointwiseFunctionToCenter(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyPointwiseFunction

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

ApplyWave

让 VMobject 产生沿路径传播的波浪形变,给静态曲线注入流动感。

继承关系

G Animation Animation Homotopy Homotopy Animation->Homotopy ApplyWave ApplyWave Homotopy->ApplyWave

参数

mobject

—,Mobject

direction

array([0., 1., 0.]),Vector3DLike

amplitude

0.2,float

wave_func

<function smooth at 0x7f16b…,RateFunction

time_width

1,float

ripples

1,int

run_time

2,float

快速上手

self.play(ApplyWave(sine_curve))

API 文档

class manim.ApplyWave(mobject=None, *args, use_override=True, **kwargs)

基类:Homotopy

Broadcast

从中心向外扩散一圈圈涟漪的强调动画,类似水波或雷达扩散。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup LaggedStart LaggedStart AnimationGroup->LaggedStart Broadcast Broadcast LaggedStart->Broadcast

参数

mobject

—,Mobject

focal_point

array([0., 0., 0.]),Sequence[float]

n_mobs

5,int

initial_opacity

1,float

final_opacity

0,float

initial_width

0.0,float

remover

True,bool

lag_ratio

0.2,float

run_time

3,float

快速上手

self.play(Broadcast(dot))

API 文档

class manim.Broadcast(mobject=None, *args, use_override=True, **kwargs)

基类:LaggedStart

ChangeDecimalToValue

把 DecimalNumber 从当前值滚动变化到目标值的动画,数字变动平滑自然。

继承关系

G Animation Animation ChangingDecimal ChangingDecimal Animation->ChangingDecimal ChangeDecimalToValue ChangeDecimalToValue ChangingDecimal->ChangeDecimalToValue

参数

decimal_mob

—,DecimalNumber

target_number

—,int

快速上手

self.play(ChangeDecimalToValue(number, 3.14))

API 文档

class manim.ChangeDecimalToValue(mobject=None, *args, use_override=True, **kwargs)

基类:ChangingDecimal

ChangeSpeed

包裹一个动画并动态改变其播放速度,speed_func 接收运行进度返回速度倍率。

继承关系

G Animation Animation ChangeSpeed ChangeSpeed Animation->ChangeSpeed

参数

anim

—

speedinfo

—,dict[float, float]

rate_func

None

affects_speed_updaters

True,bool

API 文档

class manim.ChangeSpeed(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

classmethod add_updater(mobject: Mobject, update_function: Updater, index: int | None = None, call_updater: bool = False)

This static method can be used to apply speed change to updaters.

This updater will follow speed and rate function of any ChangeSpeed animation that is playing with affects_speed_updaters=True. By default, updater functions added via the usual Mobject.add_updater() method do not respect the change of animation speed.

Parameters

mobject

The mobject to which the updater should be attached.

update_function

The function that is called whenever a new frame is rendered.

index

The position in the list of the mobject's updaters at which the function should be inserted.

call_updater

If True, calls the update function when attaching it to the mobject.

See also

ChangeSpeed Mobject.add_updater()

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

finish() → None

Finish the animation.

This method gets called when the animation is over.

get_scaled_total_time() → float

The time taken by the animation under the assumption that the run_time is 1.

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

update_mobjects(dt: float) → None

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

ChangingDecimal

持续变化的数字动画:每次显示当前 ValueTracker 的值,配合 updater 可做实时计数。

继承关系

G Animation Animation ChangingDecimal ChangingDecimal Animation->ChangingDecimal

参数

decimal_mob

—,DecimalNumber

number_update_func

—,Callable[[float], float]

suspend_mobject_updating

False,bool

快速上手

number.add_updater(lambda d: d.set_value(tracker.get_value()))

API 文档

class manim.ChangingDecimal(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

Circumscribe

在 Mobject 周围画一个强调框(矩形或圆角),默认黄色,用于「注意这里」。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup Succession Succession AnimationGroup->Succession Circumscribe Circumscribe Succession->Circumscribe

参数

mobject

—,Mobject

shape

<class 'manim.mobject.geome…

fade_in

False,bool

fade_out

False,bool

time_width

0.3,float

buff

0.1,float

color

ManimColor('#FFFF00'),ParsableManimColor

run_time

1,float

stroke_width

4,float

快速上手

self.play(Circumscribe(formula))

API 文档

class manim.Circumscribe(mobject=None, *args, use_override=True, **kwargs)

基类:Succession

ClockwiseTransform

ReplacementTransform 的顺时针变体:路径按顺时针方向插值,适合旋转感的形态变化。

继承关系

G Animation Animation Transform Transform Animation->Transform ClockwiseTransform ClockwiseTransform Transform->ClockwiseTransform

参数

mobject

—,Mobject

target_mobject

—,Mobject

path_arc

-3.141592653589793,float

API 文档

class manim.ClockwiseTransform(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

ComplexHomotopy

复同伦动画:随 t 从 0 到 1 把复平面连续变形,复分析可视化的利器。

继承关系

G Animation Animation Homotopy Homotopy Animation->Homotopy ComplexHomotopy ComplexHomotopy Homotopy->ComplexHomotopy

参数

complex_homotopy

—

mobject

—,Mobject

API 文档

class manim.ComplexHomotopy(mobject=None, *args, use_override=True, **kwargs)

基类:Homotopy

CounterclockwiseTransform

ReplacementTransform 的逆时针变体,与 ClockwiseTransform 对应。

继承关系

G Animation Animation Transform Transform Animation->Transform CounterclockwiseTransform CounterclockwiseTransform Transform->CounterclockwiseTransform

参数

mobject

—,Mobject

target_mobject

—,Mobject

path_arc

3.141592653589793,float

API 文档

class manim.CounterclockwiseTransform(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

Create

沿路径绘出 VMobject 的「一笔画」动画,是 ShowPartial 的便捷封装。

继承关系

G Animation Animation ShowPartial ShowPartial Animation->ShowPartial Create Create ShowPartial->Create

参数

mobject

—

lag_ratio

1.0,float

introducer

True,bool

快速上手

self.play(Create(circle))

API 文档

class manim.Create(mobject=None, *args, use_override=True, **kwargs)

基类:ShowPartial

CyclicReplace

把一组 Mobject 沿环置换:A 移到 B 的位置、B 移到 C……最后回到 A,可循环往复。

继承关系

G Animation Animation Transform Transform Animation->Transform CyclicReplace CyclicReplace Transform->CyclicReplace

参数

快速上手

self.play(CyclicReplace(a, b, c))

API 文档

class manim.CyclicReplace(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

DrawBorderThenFill

先描边再填充的两段式入场动画,兼具 Create 和 FadeIn 的效果,适合大面积图形。

继承关系

G Animation Animation DrawBorderThenFill DrawBorderThenFill Animation->DrawBorderThenFill

参数

vmobject

—

run_time

2,float

rate_func

<function double_smooth at …,Callable[[float], float]

stroke_width

2,float

stroke_color

None,str

introducer

True,bool

快速上手

self.play(DrawBorderThenFill(polygon))

API 文档

class manim.DrawBorderThenFill(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

get_all_mobjects() → Sequence[Mobject]

Get all mobjects involved in the animation.

Ordering must match the ordering of arguments to interpolate_submobject

Returns

Sequence[Mobject]

The sequence of mobjects.

FadeIn

淡入动画。可指定 shift、scale、target_position,让对象从某处「长」进画面,是最常用的入场方式。

继承关系

G Animation Animation Transform Transform Animation->Transform FadeIn FadeIn Transform->FadeIn

快速上手

self.play(FadeIn(mob, shift=UP))

API 文档

class manim.FadeIn(mobject=None, *args, use_override=True, **kwargs)

基类:_Fade

FadeOut

淡出动画,出场首选;常配合 target_position 让对象朝某个点消散。

继承关系

G Animation Animation Transform Transform Animation->Transform FadeOut FadeOut Transform->FadeOut

快速上手

self.play(FadeOut(mob))

API 文档

class manim.FadeOut(mobject=None, *args, use_override=True, **kwargs)

基类:_Fade

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

FadeToColor

平滑地把 Mobject 颜色过渡到目标色,set_color 的动画版。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod FadeToColor FadeToColor ApplyMethod->FadeToColor

参数

mobject

—,Mobject

color

—,str

快速上手

self.play(FadeToColor(circle, RED))

API 文档

class manim.FadeToColor(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyMethod

FadeTransform

把一个 Mobject 淡出、另一个淡入并占据其位置与样式,介于替换与交叉淡化之间。

继承关系

G Animation Animation Transform Transform Animation->Transform FadeTransform FadeTransform Transform->FadeTransform

参数

mobject

—,Mobject

target_mobject

—,Mobject

stretch

True,bool

dim_to_match

1,int

API 文档

class manim.FadeTransform(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

begin()

Initial setup for the animation.

The mobject to which this animation is bound is a group consisting of both the starting and the ending mobject. At the start, the ending mobject replaces the starting mobject (and is completely faded). In the end, it is set to be the other way around.

clean_up_from_scene(scene)

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

get_all_mobjects() → Sequence[Mobject]

Get all mobjects involved in the animation.

Ordering must match the ordering of arguments to interpolate_submobject

Returns

Sequence[Mobject]

The sequence of mobjects.

ghost_to(source, target)

Replaces the source by the target and sets the opacity to 0.

If the provided target has no points, and thus a location of [0, 0, 0] the source will simply fade out where it currently is.

FadeTransformPieces

FadeTransform 的逐子对象版本:按子对象配对交叉淡化,适合家族整体换形。

继承关系

G Animation Animation Transform Transform Animation->Transform FadeTransform FadeTransform Transform->FadeTransform FadeTransformPieces FadeTransformPieces FadeTransform->FadeTransformPieces

参数

mobject

—,Mobject

target_mobject

—,Mobject

stretch

True,bool

dim_to_match

1,int

API 文档

class manim.FadeTransformPieces(mobject=None, *args, use_override=True, **kwargs)

基类:FadeTransform

begin()

Initial setup for the animation.

The mobject to which this animation is bound is a group consisting of both the starting and the ending mobject. At the start, the ending mobject replaces the starting mobject (and is completely faded). In the end, it is set to be the other way around.

ghost_to(source, target)

Replaces the source submobjects by the target submobjects and sets the opacity to 0.

Flash

在点或 Mobject 上打出一圈闪光线条的强调动画,视觉焦点效果强。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup Flash Flash AnimationGroup->Flash

参数

point

—,Point3DLike | Mobject

line_length

0.2,float

num_lines

12,int

flash_radius

0.1,float

line_stroke_width

3,int

color

ManimColor('#FFFF00'),ParsableManimColor

time_width

1,float

run_time

1.0,float

快速上手

self.play(Flash(point))

API 文档

class manim.Flash(mobject=None, *args, use_override=True, **kwargs)

基类:AnimationGroup

FocusOn

暗化全屏、用光圈聚焦目标点的提示动画,讲解时引导视线。

继承关系

G Animation Animation Transform Transform Animation->Transform FocusOn FocusOn Transform->FocusOn

参数

focus_point

—,Point3DLike | Mobject

opacity

0.2,float

color

ManimColor('#888888'),ParsableManimColor

run_time

2,float

快速上手

self.play(FocusOn(dot))

API 文档

class manim.FocusOn(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

GrowArrow

让 Arrow 沿自身方向从头生长出来的动画。

继承关系

G Animation Animation Transform Transform Animation->Transform GrowFromPoint GrowFromPoint Transform->GrowFromPoint GrowArrow GrowArrow GrowFromPoint->GrowArrow

参数

arrow

—,Arrow

point_color

None

快速上手

self.play(GrowArrow(arrow))

API 文档

class manim.GrowArrow(mobject=None, *args, use_override=True, **kwargs)

基类:GrowFromPoint

GrowFromCenter

从中心向外长大的入场动画,可用于任意 Mobject。

继承关系

G Animation Animation Transform Transform Animation->Transform GrowFromPoint GrowFromPoint Transform->GrowFromPoint GrowFromCenter GrowFromCenter GrowFromPoint->GrowFromCenter

参数

mobject

—,Mobject

point_color

None

快速上手

self.play(GrowFromCenter(square))

API 文档

class manim.GrowFromCenter(mobject=None, *args, use_override=True, **kwargs)

基类:GrowFromPoint

GrowFromEdge

从指定边缘向对侧生长的入场动画。

继承关系

G Animation Animation Transform Transform Animation->Transform GrowFromPoint GrowFromPoint Transform->GrowFromPoint GrowFromEdge GrowFromEdge GrowFromPoint->GrowFromEdge

参数

mobject

—,Mobject

edge

—,Vector3DLike

point_color

None

快速上手

self.play(GrowFromEdge(dot, LEFT))

API 文档

class manim.GrowFromEdge(mobject=None, *args, use_override=True, **kwargs)

基类:GrowFromPoint

GrowFromPoint

从指定点向外长大的入场动画,配合 Flash 效果极佳。

继承关系

G Animation Animation Transform Transform Animation->Transform GrowFromPoint GrowFromPoint Transform->GrowFromPoint

参数

mobject

—,Mobject

point

—,Point3DLike

point_color

None

快速上手

self.play(GrowFromPoint(mob, origin))

API 文档

class manim.GrowFromPoint(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

Homotopy

同伦动画:传入关于 (x, y, z, t) 的函数,把对象连续形变到目标姿态。

继承关系

G Animation Animation Homotopy Homotopy Animation->Homotopy

参数

homotopy

—

mobject

—,Mobject

run_time

3,float

apply_function_kwargs

None,dict[str, Any] | None

快速上手

self.play(Homotopy(lambda x, y, z, t: (x, y + t, z), mob))

API 文档

class manim.Homotopy(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

Indicate

轻推一下目标对象(放大再回弹)的提示动画,比 Circumscribe 更含蓄。

继承关系

G Animation Animation Transform Transform Animation->Transform Indicate Indicate Transform->Indicate

参数

mobject

—,Mobject

scale_factor

1.2,float

color

ManimColor('#FFFF00'),ParsableManimColor

rate_func

<function there_and_back at…,RateFunction

快速上手

self.play(Indicate(formula))

API 文档

class manim.Indicate(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

LaggedStart

让一组动画按固定间隔依次启动,start_lag_ratio 控制节奏,是排队式动效的基石。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup LaggedStart LaggedStart AnimationGroup->LaggedStart

参数

快速上手

self.play(LaggedStart(*[FadeIn(m) for m in group]))

API 文档

class manim.LaggedStart(mobject=None, *args, use_override=True, **kwargs)

基类:AnimationGroup

LaggedStartMap

LaggedStart 的函数式版本:对一组对象统一套用同一种动画并按序启动。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup LaggedStart LaggedStart AnimationGroup->LaggedStart LaggedStartMap LaggedStartMap LaggedStart->LaggedStartMap

参数

animation_class

—,type[Animation]

mobject

—,Mobject

arg_creator

None

run_time

2,float

lag_ratio

0.05,float

快速上手

self.play(LaggedStartMap(FadeIn, group, lag_ratio=0.1))

API 文档

class manim.LaggedStartMap(mobject=None, *args, use_override=True, **kwargs)

基类:LaggedStart

MaintainPositionRelativeTo

让 Mobject 在目标对象动画期间保持相对位置,常配合 ApplyFunction 锁定局部位移。

继承关系

G Animation Animation MaintainPositionRelativeTo MaintainPositionRelativeTo Animation->MaintainPositionRelativeTo

参数

mobject

—,Mobject

tracked_mobject

—,Mobject

API 文档

class manim.MaintainPositionRelativeTo(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

MoveAlongPath

让 Mobject 沿给定路径(曲线)运动的动画。

继承关系

G Animation Animation MoveAlongPath MoveAlongPath Animation->MoveAlongPath

参数

mobject

—,Mobject

path

—,VMobject

suspend_mobject_updating

False,bool

快速上手

self.play(MoveAlongPath(dot, circle))

API 文档

class manim.MoveAlongPath(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

MoveToTarget

把 Mobject 移动到其 save_state 的快照位置,与 mob.target / generate_target 配合使用。

继承关系

G Animation Animation Transform Transform Animation->Transform MoveToTarget MoveToTarget Transform->MoveToTarget

参数

快速上手

mob.generate_target()
mob.target.shift(RIGHT)
self.play(MoveToTarget(mob))

API 文档

class manim.MoveToTarget(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

PhaseFlow

对向量场(如微分方程相图)随时间演化做形变动画,动力系统可视化工具。

继承关系

G Animation Animation PhaseFlow PhaseFlow Animation->PhaseFlow

参数

function

—

mobject

—,Mobject

virtual_time

1,float

suspend_mobject_updating

False,bool

rate_func

<function linear at 0x7f16b…,RateFunction

API 文档

class manim.PhaseFlow(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

RemoveTextLetterByLetter

AddTextLetterByLetter 的反向动画:Text 逐字母消失。

继承关系

G Animation Animation ShowIncreasingSubsets ShowIncreasingSubsets Animation->ShowIncreasingSubsets AddTextLetterByLetter AddTextLetterByLetter ShowIncreasingSubsets->AddTextLetterByLetter RemoveTextLetterByLetter RemoveTextLetterByLetter AddTextLetterByLetter->RemoveTextLetterByLetter

参数

text

—,Text

suspend_mobject_updating

False,bool

int_func

<ufunc 'ceil'>

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

time_per_char

0.1,float

run_time

None,float | None

reverse_rate_function

True

introducer

False

remover

True

API 文档

class manim.RemoveTextLetterByLetter(mobject=None, *args, use_override=True, **kwargs)

基类:AddTextLetterByLetter

ReplacementTransform

把一个 Mobject 原位变形替换为另一个,是最强的「变形」动画,两个对象会融合。

继承关系

G Animation Animation Transform Transform Animation->Transform ReplacementTransform ReplacementTransform Transform->ReplacementTransform

参数

mobject

—,Mobject

target_mobject

—,Mobject

快速上手

self.play(ReplacementTransform(square, circle))

API 文档

class manim.ReplacementTransform(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

Restore

让 Mobject 回到 save_state() 保存的状态,常用于「变了再变回去」。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod Restore Restore ApplyMethod->Restore

参数

快速上手

self.play(Restore(mob))

API 文档

class manim.Restore(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyMethod

Rotate

绕指定点旋转对象的动画,angle 为正逆时针。

继承关系

G Animation Animation Transform Transform Animation->Transform Rotate Rotate Transform->Rotate

参数

mobject

—,Mobject

angle

3.141592653589793,float

axis

array([0., 0., 1.]),Vector3DLike

about_point

None,Point3DLike | None

about_edge

None,Vector3DLike | None

快速上手

self.play(Rotate(square, PI / 2))

API 文档

class manim.Rotate(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

Rotating

持续旋转动画:不占用场景时间推进的「边转边讲」,常用于旋转对称演示。

继承关系

G Animation Animation Rotating Rotating Animation->Rotating

参数

mobject

—,Mobject

angle

6.283185307179586,float

axis

array([0., 0., 1.]),Vector3DLike

about_point

None,Point3DLike | None

about_edge

None,Vector3DLike | None

run_time

5,float

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

快速上手

self.add(Rotating(square))

API 文档

class manim.Rotating(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

ScaleInPlace

原地缩放的强调动画,set(width=...) 类的动画版本。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod ScaleInPlace ScaleInPlace ApplyMethod->ScaleInPlace

参数

mobject

—,Mobject

scale_factor

—,float

快速上手

self.play(ScaleInPlace(circle, 1.5))

API 文档

class manim.ScaleInPlace(mobject=None, *args, use_override=True, **kwargs)

基类:ApplyMethod

ShowIncreasingSubsets

让 VGroup 的子对象逐个显示,适合逐步揭示列表或矩阵元素。

继承关系

G Animation Animation ShowIncreasingSubsets ShowIncreasingSubsets Animation->ShowIncreasingSubsets

参数

group

—,Mobject

suspend_mobject_updating

False,bool

int_func

<ufunc 'floor'>

reverse_rate_function

False

快速上手

self.play(ShowIncreasingSubsets(group))

API 文档

class manim.ShowIncreasingSubsets(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

ShowPartial

按进度显示路径片段的底层动画,Create 与 Uncreate 的父类,可自定义绘制方向。

继承关系

G Animation Animation ShowPartial ShowPartial Animation->ShowPartial

参数

API 文档

class manim.ShowPartial(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

ShowPassingFlash

一道亮斑沿路径扫过的「电流」效果动画,time_width 控制亮斑宽度。

继承关系

G Animation Animation ShowPartial ShowPartial Animation->ShowPartial ShowPassingFlash ShowPassingFlash ShowPartial->ShowPassingFlash

参数

mobject

—,VMobject

time_width

0.1,float

快速上手

self.play(ShowPassingFlash(line))

API 文档

class manim.ShowPassingFlash(mobject=None, *args, use_override=True, **kwargs)

基类:ShowPartial

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

ShowPassingFlashWithThinningStrokeWidth

ShowPassingFlash 的变体:扫过时笔画由粗变细,更像真实书写。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup ShowPassingFlashWithThinningStrokeWidth ShowPassingFlashWithThinningStrokeWidth AnimationGroup->ShowPassingFlashWithThinningStrokeWidth

参数

vmobject

—,VMobject

n_segments

10,int

time_width

0.1,float

remover

True,bool

API 文档

class manim.ShowPassingFlashWithThinningStrokeWidth(mobject=None, *args, use_override=True, **kwargs)

基类:AnimationGroup

ShowSubmobjectsOneByOne

把 VGroup 子对象按个显示后再按个移除的序列动画,适合对比展示。

继承关系

G Animation Animation ShowIncreasingSubsets ShowIncreasingSubsets Animation->ShowIncreasingSubsets ShowSubmobjectsOneByOne ShowSubmobjectsOneByOne ShowIncreasingSubsets->ShowSubmobjectsOneByOne

参数

group

—,Iterable[Mobject]

int_func

<ufunc 'ceil'>

快速上手

self.play(ShowSubmobjectsOneByOne(group))

API 文档

class manim.ShowSubmobjectsOneByOne(mobject=None, *args, use_override=True, **kwargs)

基类:ShowIncreasingSubsets

ShrinkToCenter

向中心收缩消失的出场动画,FadeOut 的动感替代。

继承关系

G Animation Animation Transform Transform Animation->Transform ApplyMethod ApplyMethod Transform->ApplyMethod ScaleInPlace ScaleInPlace ApplyMethod->ScaleInPlace ShrinkToCenter ShrinkToCenter ScaleInPlace->ShrinkToCenter

参数

快速上手

self.play(ShrinkToCenter(mob))

API 文档

class manim.ShrinkToCenter(mobject=None, *args, use_override=True, **kwargs)

基类:ScaleInPlace

SmoothedVectorizedHomotopy

Homotopy 的平滑变体:在变换中保持向量场曲线平滑,减少锯齿。

继承关系

G Animation Animation Homotopy Homotopy Animation->Homotopy SmoothedVectorizedHomotopy SmoothedVectorizedHomotopy Homotopy->SmoothedVectorizedHomotopy

参数

homotopy

—

mobject

—,Mobject

run_time

3,float

apply_function_kwargs

None,dict[str, Any] | None

API 文档

class manim.SmoothedVectorizedHomotopy(mobject=None, *args, use_override=True, **kwargs)

基类:Homotopy

SpinInFromNothing

一边旋转一边淡入的复合入场动画。

继承关系

G Animation Animation Transform Transform Animation->Transform GrowFromPoint GrowFromPoint Transform->GrowFromPoint GrowFromCenter GrowFromCenter GrowFromPoint->GrowFromCenter SpinInFromNothing SpinInFromNothing GrowFromCenter->SpinInFromNothing

参数

mobject

—,Mobject

angle

1.5707963267948966,float

point_color

None

快速上手

self.play(SpinInFromNothing(mob))

API 文档

class manim.SpinInFromNothing(mobject=None, *args, use_override=True, **kwargs)

基类:GrowFromCenter

SpiralIn

让一组子对象沿螺旋轨迹飞入的编排动画,开场集合类内容很出彩。

继承关系

G Animation Animation SpiralIn SpiralIn Animation->SpiralIn

参数

shapes

—,Mobject

scale_factor

8,float

fade_in_fraction

0.3

快速上手

self.play(SpiralIn(group))

API 文档

class manim.SpiralIn(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

Succession

把多个动画严格串成一条时间线依次播放,前一个播完才播下一个。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup Succession Succession AnimationGroup->Succession

参数

快速上手

self.play(Succession(FadeIn(a), FadeOut(a)))

API 文档

class manim.Succession(mobject=None, *args, use_override=True, **kwargs)

基类:AnimationGroup

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

finish() → None

Finish the animation.

This method gets called when the animation is over.

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

next_animation() → None

Proceeds to the next animation.

This method is called right when the active animation finishes.

update_mobjects(dt: float) → None

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

Swap

让两个 Mobject 交换位置的动画,常带交叉路径。

继承关系

G Animation Animation Transform Transform Animation->Transform CyclicReplace CyclicReplace Transform->CyclicReplace Swap Swap CyclicReplace->Swap

参数

API 文档

class manim.Swap(mobject=None, *args, use_override=True, **kwargs)

基类:CyclicReplace

TracedPath

持续记录某点运动轨迹并实时绘出的「画笔」对象,配 MoveAlongPath 做轨迹可视化。

继承关系

G Mobject Mobject VMobject VMobject Mobject->VMobject TracedPath TracedPath VMobject->TracedPath

参数

traced_point_func

—,Callable

stroke_width

2,float

stroke_color

ManimColor('#FFFFFF')

dissipating_time

None,float | None

快速上手

trace = TracedPath(dot.get_center)
self.add(trace)
self.play(MoveAlongPath(dot, circle))

API 文档

class manim.TracedPath(traced_point_func: Callable, stroke_width: float = 2, stroke_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | None = ManimColor('#FFFFFF'), dissipating_time: float | None = None, **kwargs: Any)

基类:VMobject

Transform

把一个 Mobject 平滑变形为另一个的标准变换动画,所有 Transform 家族的基类。

继承关系

G Animation Animation Transform Transform Animation->Transform

参数

mobject

—,Mobject | None

target_mobject

None,Mobject | None

path_func

None,Callable | None

path_arc

0,float

path_arc_axis

array([0., 0., 1.]),np.ndarray

path_arc_centers

None

replace_mobject_with_target_in_scene

False,bool

快速上手

self.play(Transform(square, circle))

API 文档

class manim.Transform(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

get_all_mobjects() → Sequence[Mobject]

Get all mobjects involved in the animation.

Ordering must match the ordering of arguments to interpolate_submobject

Returns

Sequence[Mobject]

The sequence of mobjects.

TransformAnimations

把两个动画「对齐」:让第一个动画的结尾状态匹配第二个动画的起点,实现无缝衔接。

继承关系

G Animation Animation Transform Transform Animation->Transform TransformAnimations TransformAnimations Transform->TransformAnimations

参数

start_anim

—,Animation

end_anim

—,Animation

rate_func

<function squish_rate_func.…,Callable

API 文档

class manim.TransformAnimations(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

TransformFromCopy

先复制出副本再变形到位的动画,原对象保留,强调「由它推导」的逻辑。

继承关系

G Animation Animation Transform Transform Animation->Transform TransformFromCopy TransformFromCopy Transform->TransformFromCopy

参数

mobject

—,Mobject

target_mobject

—,Mobject

快速上手

self.play(TransformFromCopy(a, b))

API 文档

class manim.TransformFromCopy(mobject=None, *args, use_override=True, **kwargs)

基类:Transform

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

TransformMatchingShapes

按形状相似度在两个 VGroup 间自动配对子对象逐一变形,重构公式、图形的神器。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup TransformMatchingShapes TransformMatchingShapes AnimationGroup->TransformMatchingShapes

参数

mobject

—,Mobject

target_mobject

—,Mobject

transform_mismatches

False,bool

fade_transform_mismatches

False,bool

key_map

None,dict | None

快速上手

self.play(TransformMatchingShapes(vg1, vg2))

API 文档

class manim.TransformMatchingShapes(mobject=None, *args, use_override=True, **kwargs)

基类:TransformMatchingAbstractBase

TransformMatchingTex

TransformMatchingShapes 的 Tex 特化:按 LaTeX 片段配对变形,公式演算的标配。

继承关系

G Animation Animation AnimationGroup AnimationGroup Animation->AnimationGroup TransformMatchingTex TransformMatchingTex AnimationGroup->TransformMatchingTex

参数

mobject

—,Mobject

target_mobject

—,Mobject

transform_mismatches

False,bool

fade_transform_mismatches

False,bool

key_map

None,dict | None

快速上手

self.play(TransformMatchingTex(eq1, eq2))

API 文档

class manim.TransformMatchingTex(mobject=None, *args, use_override=True, **kwargs)

基类:TransformMatchingAbstractBase

TypeWithCursor

打字机动画 + 闪烁光标:Text 逐字输入,末尾跟一个可自定义的光标 Mobject。

继承关系

G Animation Animation ShowIncreasingSubsets ShowIncreasingSubsets Animation->ShowIncreasingSubsets AddTextLetterByLetter AddTextLetterByLetter ShowIncreasingSubsets->AddTextLetterByLetter TypeWithCursor TypeWithCursor AddTextLetterByLetter->TypeWithCursor

参数

text

—,Text

cursor

—,Mobject

buff

0.1,float

keep_cursor_y

True,bool

leave_cursor_on

True,bool

time_per_char

0.1,float

reverse_rate_function

False

introducer

True

快速上手

self.play(TypeWithCursor(text, cursor))

API 文档

class manim.TypeWithCursor(mobject=None, *args, use_override=True, **kwargs)

基类:AddTextLetterByLetter

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

finish() → None

Finish the animation.

This method gets called when the animation is over.

Uncreate

Create 的反向动画:沿路径把图形擦除。

继承关系

G Animation Animation ShowPartial ShowPartial Animation->ShowPartial Create Create ShowPartial->Create Uncreate Uncreate Create->Uncreate

参数

mobject

—

reverse_rate_function

True,bool

remover

True,bool

快速上手

self.play(Uncreate(circle))

API 文档

class manim.Uncreate(mobject=None, *args, use_override=True, **kwargs)

基类:Create

UntypeWithCursor

TypeWithCursor 的反向动画:带光标逐字删除文本。

继承关系

G Animation Animation ShowIncreasingSubsets ShowIncreasingSubsets Animation->ShowIncreasingSubsets AddTextLetterByLetter AddTextLetterByLetter ShowIncreasingSubsets->AddTextLetterByLetter TypeWithCursor TypeWithCursor AddTextLetterByLetter->TypeWithCursor UntypeWithCursor UntypeWithCursor TypeWithCursor->UntypeWithCursor

参数

text

—,Text

cursor

None,VMobject | None

time_per_char

0.1,float

reverse_rate_function

True

introducer

False

remover

True

API 文档

class manim.UntypeWithCursor(mobject=None, *args, use_override=True, **kwargs)

基类:TypeWithCursor

Unwrite

Write 的反向动画:按书写顺序把文本或公式擦除。

继承关系

G Animation Animation DrawBorderThenFill DrawBorderThenFill Animation->DrawBorderThenFill Write Write DrawBorderThenFill->Write Unwrite Unwrite Write->Unwrite

参数

vmobject

—,VMobject

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

reverse

True,bool

快速上手

self.play(Unwrite(text))

API 文档

class manim.Unwrite(mobject=None, *args, use_override=True, **kwargs)

基类:Write

UpdateFromAlphaFunc

用 updater 按动画进度 alpha 驱动任意更新逻辑的自定义动画骨架。

继承关系

G Animation Animation UpdateFromFunc UpdateFromFunc Animation->UpdateFromFunc UpdateFromAlphaFunc UpdateFromAlphaFunc UpdateFromFunc->UpdateFromAlphaFunc

参数

mobject

—,Mobject

update_function

—,Callable[[Mobject], Any]

suspend_mobject_updating

False,bool

API 文档

class manim.UpdateFromAlphaFunc(mobject=None, *args, use_override=True, **kwargs)

基类:UpdateFromFunc

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

UpdateFromFunc

在动画时长内对目标持续应用更新函数的自定义动画,适合「边播边算」的场景。

继承关系

G Animation Animation UpdateFromFunc UpdateFromFunc Animation->UpdateFromFunc

参数

mobject

—,Mobject

update_function

—,Callable[[Mobject], Any]

suspend_mobject_updating

False,bool

API 文档

class manim.UpdateFromFunc(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

interpolate_mobject(alpha: float) → None

Interpolates the mobject of the Animation based on alpha value.

Parameters

alpha

A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.

Wait

停顿动画:让时间流逝 nothing 发生(或跑背景动画),self.wait() 的动画版。

继承关系

G Animation Animation Wait Wait Animation->Wait

参数

run_time

1,float

stop_condition

None

frozen_frame

None,bool | None

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

快速上手

self.play(Wait(2))

API 文档

class manim.Wait(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

clean_up_from_scene(scene: Scene) → None

Clean up the Scene after finishing the animation.

This includes to remove() the Animation's Mobject if the animation is a remover.

Parameters

scene

The scene the animation should be cleaned up from.

finish() → None

Finish the animation.

This method gets called when the animation is over.

interpolate(alpha: float) → None

Set the animation progress.

This method gets called for every frame during an animation.

Parameters

alpha

The relative time to set the animation to, 0 meaning the start, 1 meaning the end.

update_mobjects(dt: float) → None

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

Wiggle

让对象来回扭动摇摆的强调动画,适合标记不确定性或活跃状态。

继承关系

G Animation Animation Wiggle Wiggle Animation->Wiggle

参数

mobject

—,Mobject

scale_value

1.1,float

rotation_angle

0.06283185307179587,float

n_wiggles

6,int

scale_about_point

None,Point3DLike | None

rotate_about_point

None,Point3DLike | None

run_time

2,float

快速上手

self.play(Wiggle(mob))

API 文档

class manim.Wiggle(mobject=None, *args, use_override=True, **kwargs)

基类:Animation

Write

按文字/笔画顺序「书写」文本的动画,Tex、Text 演算推导的标志性入场方式。

继承关系

G Animation Animation DrawBorderThenFill DrawBorderThenFill Animation->DrawBorderThenFill Write Write DrawBorderThenFill->Write

参数

vmobject

—

rate_func

<function linear at 0x7f16b…,Callable[[float], float]

reverse

False,bool

快速上手

self.play(Write(text))

API 文档

class manim.Write(mobject=None, *args, use_override=True, **kwargs)

基类:DrawBorderThenFill

begin() → None

Begin the animation.

This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.

finish() → None

Finish the animation.

This method gets called when the animation is over.