添加¶
完全限定名: manim.animation.animation.Add
- class Add(mobject=None, *args, use_override=True, **kwargs)[source]¶
基类:
Animation
将Mobject添加到场景中,不以其他任何方式对其进行动画处理。这类似于
Scene.add()
方法,但Add
是一种可以组合到其他动画中的动画。- 参数:
示例
示例:DefaultAddScene ¶
from manim import * class DefaultAddScene(Scene): def construct(self): text_1 = Text("I was added with Add!") text_2 = Text("Me too!") text_3 = Text("And me!") texts = VGroup(text_1, text_2, text_3).arrange(DOWN) rect = SurroundingRectangle(texts, buff=0.5) self.play( Create(rect, run_time=3.0), Succession( Wait(1.0), # You can Add a Mobject in the middle of an animation... Add(text_1), Wait(1.0), # ...or multiple Mobjects at once! Add(text_2, text_3), ), ) self.wait()
class DefaultAddScene(Scene): def construct(self): text_1 = Text("I was added with Add!") text_2 = Text("Me too!") text_3 = Text("And me!") texts = VGroup(text_1, text_2, text_3).arrange(DOWN) rect = SurroundingRectangle(texts, buff=0.5) self.play( Create(rect, run_time=3.0), Succession( Wait(1.0), # You can Add a Mobject in the middle of an animation... Add(text_1), Wait(1.0), # ...or multiple Mobjects at once! Add(text_2, text_3), ), ) self.wait()
示例:AddWithRunTimeScene ¶
from manim import * class AddWithRunTimeScene(Scene): def construct(self): # A 5x5 grid of circles circles = VGroup( *[Circle(radius=0.5) for _ in range(25)] ).arrange_in_grid(5, 5) self.play( Succession( # Add a run_time of 0.2 to wait for 0.2 seconds after # adding the circle, instead of using Wait(0.2) after Add! *[Add(circle, run_time=0.2) for circle in circles], rate_func=smooth, ) ) self.wait()
class AddWithRunTimeScene(Scene): def construct(self): # A 5x5 grid of circles circles = VGroup( *[Circle(radius=0.5) for _ in range(25)] ).arrange_in_grid(5, 5) self.play( Succession( # Add a run_time of 0.2 to wait for 0.2 seconds after # adding the circle, instead of using Wait(0.2) after Add! *[Add(circle, run_time=0.2) for circle in circles], rate_func=smooth, ) ) self.wait()
方法
开始动画。
完成动画后清理
Scene
。完成动画。
设置动画进度。
更新诸如 starting_mobject 和 (对于 Transforms) target_mobject 等内容。
属性
运行时间
- _original__init__(*mobjects, run_time=0.0, **kwargs)¶
初始化自身。有关准确签名,请参阅 help(type(self))。
- 参数:
mobjects (Mobject)
run_time (float)
kwargs (Any)
- 返回类型:
无
- clean_up_from_scene(scene)[source]¶
完成动画后清理
Scene
。这包括在动画是移除器时
remove()
动画的Mobject
。- 参数:
scene (场景) – 动画应从中清理的场景。
- 返回类型:
无