Add¶
Qualified name: manim.animation.animation.Add
- class Add(mobject=None, *args, use_override=True, **kwargs)[source]¶
Bases:
Animation
Add Mobjects to a scene, without animating them in any other way. This is similar to the
Scene.add()
method, butAdd
is an animation which can be grouped into other animations.- Parameters:
run_time (float) – The duration of the animation after adding the
mobjects
. Defaults to 0, which means this is an instant animation without extra wait time after adding them.**kwargs (Any) – Additional arguments to pass to the parent
Animation
class.
Examples
Example: 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()
Example: 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()
Methods
Begin the animation.
Clean up the
Scene
after finishing the animation.Finish the animation.
Set the animation progress.
Updates things like starting_mobject, and (for Transforms) target_mobject.
Attributes
run_time
- _original__init__(*mobjects, run_time=0.0, **kwargs)¶
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
mobjects (Mobject)
run_time (float)
kwargs (Any)
- Return type:
None
- begin()[source]¶
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.
- Return type:
None
- clean_up_from_scene(scene)[source]¶
Clean up the
Scene
after finishing the animation.This includes to
remove()
the Animation’sMobject
if the animation is a remover.- Parameters:
scene (Scene) – The scene the animation should be cleaned up from.
- Return type:
None
- finish()[source]¶
Finish the animation.
This method gets called when the animation is over.
- Return type:
None