Search code examples
manim

Manim v0.2.0 self.play() method


I cannot figure out how to create simple animations with the new Manim version (v0.2.0). For example, I would like to move a circle to an edge and at the same time scale it.

In the previous versions I would have done as follows:

class CircleAnimations(Scene):

    def construct(self):
        circle = Circle()

        self.add(circle)
        self.play(
            circle.scale, 0.2,
            circle.to_edge, UP
        )

        self.wait()

But since in the new version, to animate in the self.play method we must use mobj.animate.method(parameters) , I tried to rewrite the self.play method as follows:

self.play(
    circle.animate.scale(0.2),
    circle.animate.to_edge(UP)
)

However this doesn't work: it seems to run only the first method, in this case, circle.animate.scale(0.2), and not both circle.animate.scale(0.2) and circle.animate.to_edge(UP)

Any solution? Thanks in advance.


Solution

  • You can nest the animations like this:

    self.play(
        circle.animate.scale(0.2).to_edge(UP)
    )
    

    Another way would be to use the ApplyMethod class:

    self.play(
        ApplyMethod(circle.scale, 0.2),
        ApplyMethod(circle.to_edge, UP)
    )