We can animate the methods of the Mobject as it is.
self.play(mob.to_edge, RIGHT)
Most of the animation methods we saw earlier were by animation classes.
In this animation class, it creates an animation by making the image of a different shape for each frame for the target object. Therefore, because the method of Mobject changes the shape of an object for each frame, it is the same principle to play this method to create an animation class.
Note that the method name should be written without parentheses, and the parameter for the method should be written after the comma.
For exampel, if we make an animation from left to right by creating a circle,
self.play(circle.to_edge, LEFT)
self.play(circle.to_edge, RIGHT)
The animation where the color is painted inside the circle,
self.play(circle.set_fill, RED, 1)
self.play(circle.set_color_by_gradient, YELLOW)
Note that when you need to specify a dictionary type value as a method parameter, you must enter the complete dictionary type.
self.play(circle.set_fill, RED, {"opacity":1})
If you want to animate back to the original state, you can save the original state with mob.save_state() and animate the mob.restore method.
circle.save_state()
self.play(circle.to_edge, RIGHT)
self.play(circle.restore)
The disadvantage of animation by methods compared to animation by classes is that method type animations cannot be grouped.
Classes are grouped by AnimationGroup and can be executed while adjusting the execution interval through lag_ratio, but the method type animation must be manually adjusted by the each 'play' method.
The example below is an animation that uses a method to move a circle and change its color in different directions on the screen.
circle = Circle()
circle.save_state()
self.play(circle.to_edge, LEFT)
self.play(circle.to_edge, RIGHT)
self.play(circle.restore)
self.play(circle.to_edge, UP)
self.play(circle.to_edge, DOWN)
self.play(circle.restore)
self.play(circle.set_fill, RED, {"opacity": 0.5})
self.play(circle.set_color_by_gradient, YELLOW)
self.play(circle.to_corner, UL)
self.play(circle.to_corner, DR)
self.play(circle.restore)
self.wait()
Next: [06-3] Animation by Object Updating
Go To: [99] Table of Contents
'Programming > Manim Lectures' 카테고리의 다른 글
[06-3-A] Use add_updater (0) | 2020.06.09 |
---|---|
[06-3] Animation by Object Updating (0) | 2020.06.09 |
[06-1-I] Animation : Special Effect (0) | 2020.06.09 |
[06-1-H] Animation : Grouping (0) | 2020.06.09 |
[06-1-G] Animation : Transformation series (3/3) (0) | 2020.06.09 |