mobject¶
可显示对象的基类。
类型别名
类
函数
- override_animate(method)[源代码]¶
用于覆盖方法动画的装饰器。
这允许指定一个方法(返回一个
Animation
),当使用.animate
语法来动画化方法的应用时,该方法会被调用。另请参阅
注意
被覆盖的方法不能与正常方法或其他被覆盖的方法结合使用,通过
.animate
语法进行方法链式调用。示例
示例:AnimationOverrideExample ¶
from manim import * class CircleWithContent(VGroup): def __init__(self, content): super().__init__() self.circle = Circle() self.content = content self.add(self.circle, content) content.move_to(self.circle.get_center()) def clear_content(self): self.remove(self.content) self.content = None @override_animate(clear_content) def _clear_content_animation(self, anim_args=None): if anim_args is None: anim_args = {} anim = Uncreate(self.content, **anim_args) self.clear_content() return anim class AnimationOverrideExample(Scene): def construct(self): t = Text("hello!") my_mobject = CircleWithContent(t) self.play(Create(my_mobject)) self.play(my_mobject.animate.clear_content()) self.wait()
class CircleWithContent(VGroup): def __init__(self, content): super().__init__() self.circle = Circle() self.content = content self.add(self.circle, content) content.move_to(self.circle.get_center()) def clear_content(self): self.remove(self.content) self.content = None @override_animate(clear_content) def _clear_content_animation(self, anim_args=None): if anim_args is None: anim_args = {} anim = Uncreate(self.content, **anim_args) self.clear_content() return anim class AnimationOverrideExample(Scene): def construct(self): t = Text("hello!") my_mobject = CircleWithContent(t) self.play(Create(my_mobject)) self.play(my_mobject.animate.clear_content()) self.wait()
- 返回类型:
LambdaType