动画

使 Mobject 动起来。

Add

将 Mobject 添加到场景中,不以其他任何方式对其进行动画处理。

动画

一个动画。

等待

一个“无操作”动画。

函数

override_animation(animation_class)[source]

用于将方法标记为特定 Animation 类型的重写(override)的装饰器。

仅应将其用于装饰派生自 Mobject 的类的方法。Animation 重写会继承给定义它们的 Mobject 的子类。它们不会重写所重写 Animation 的子类。

参数:

animation_class (type[Animation]) – 要被重写的动画。

返回:

实际的装饰器。这会将方法标记为重写某个动画。

返回类型:

Callable[[Callable], Callable]

示例

示例: OverrideAnimationExample

from manim import *

class MySquare(Square):
    @override_animation(FadeIn)
    def _fade_in_override(self, **kwargs):
        return Create(self, **kwargs)

class OverrideAnimationExample(Scene):
    def construct(self):
        self.play(FadeIn(MySquare()))
class MySquare(Square):
    @override_animation(FadeIn)
    def _fade_in_override(self, **kwargs):
        return Create(self, **kwargs)

class OverrideAnimationExample(Scene):
    def construct(self):
        self.play(FadeIn(MySquare()))

prepare_animation(anim)[source]

返回未更改的动画,或从传入的动画工厂构建的动画。

示例

>>> from manim import Square, FadeIn
>>> s = Square()
>>> prepare_animation(FadeIn(s))
FadeIn(Square)
>>> prepare_animation(s.animate.scale(2).rotate(42))
_MethodAnimation(Square)
>>> prepare_animation(42)
Traceback (most recent call last):
...
TypeError: Object 42 cannot be converted to an animation
参数:

anim (Animation | _AnimationBuilder)

返回类型:

动画