动画¶
使 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