An animation.

Animations have a fixed time span.

PARAMETERS:

Example (Essential):

from manim import *


class AnimationExample(Scene):

def construct(self):

circle = Circle()

square = Square()

triangle = Triangle()

self.add(circle)

self.wait(2)

self.remove(circle)

self.play(ShowCreationThenFadeOut(square),runtime = 3)

#or

self.play(Create(triangle))

self.play(Rotating(triangle))

self.play(FadeOut(triangle))

Output:

- Explanation Line by Line: - First line as I mentioned we create a class that we work on, so to play this we would have done in the terminal: ```sh manim Example.py AnimationExample -pqh ```

- So we define the construct method on self as the parameter.
- Then we use from the Mobjects in Manim circle, Square and Triangle and grab them inside the variables we have defined.
- Now the important part of animation..
- Imagine Self as a canvas so when you just do add it adds it into the canvas, we will learn about it's placement later on in this but as of now just understand that when we do self.add(stuff), we are adding that stuff into the canvas, as you can see from the video , that doesn't really have any animation but when we have done that on the square we have used ShowCreationThenFadeOut which will give you a warning but that's okay , it's just a good practice to use the other option that I showed in triangle that to create it first and then fade it out, I will list other useful function here as well, which you can use for animation.
- Self.wait({seconds}), accepts seconds as the input and you can specify the runtime which also takes values in seconds as I have done for square creation.

Tracing Objects:

Example:

from manim import *

  

class Tracing(Scene):

def construct(self):

circ = Circle(color=RED).shift(4*LEFT)

dot = Dot(color=RED).move_to(circ.get_start())

rolling_circle = VGroup(circ, dot)

trace = TracedPath(circ.get_start)

rolling_circle.add_updater(lambda m: m.rotate(-0.4))

self.add(trace, rolling_circle)

# self.wait()

self.play(rolling_circle.animate.shift(8*RIGHT),rate_func = linear, run_time = 4)

# self.wait()

rolling_circle.clear_updaters()

trace.clear_updaters()

trace2 = TracedPath(circ.get_start, dissipating_time=0.4, stroke_width=5, stroke_color=BLUE)

self.add(trace2, rolling_circle)

rolling_circle.add_updater(lambda m: m.rotate(+0.2))

self.play(rolling_circle.animate.shift(8*LEFT), run_time=4,rate_func = linear)
- Here we have used the previously discussed function and different type of tracing by modifying parameters.