Animation class
object > Animation
manimlib.animaion.animation.Animation(self, mobject, **kwargs)
This is the ancestor class of all classes in charge of animation. Common basic methods for animation are defined.
In most cases, it is common to animate using subclasses of this Animation class. However, you can use the Animation class as it is. In that case, the object is simply displayed on the screen as it is.
CONFIG = {
"run_time": DEFAULT_ANIMATION_RUN_TIME,
"rate_func": smooth,
"name": None,
"remover": False,
# If 0, the animation is applied to all submobjects
# at the same time
# If 1, it is applied to each successively.
# If 0 < lag_ratio < 1, its applied to each
# with lagged start times
"lag_ratio": DEFAULT_ANIMATION_LAG_RATIO,
"suspend_mobject_updating": True,
Parameters:mobject
object to be animated
Parameters: **kwargs
CONFIG values of Animation
Frequently used values are,
- run_time=DEFAULT_ANIMATION_RUN_TIME=1.0: Total animation duration.
The unit is seconds.
Animation proceeds for the time specified here.
- rate_func=smooth: Relative speed function when the animation progresses.
Functions are defined in manimlib.utils.rate_function.py.
In the case of the linear function, the rate of change of the object
is constant during the entire animation period,
and other functions have different rates of change
according to the defined speed function.
The most commonly used properties are 'run_time' and 'rate_func' in the Animation play. The 'run_time' is to set the total animation duration, and the 'rate_func' is to set relative speeds during the animation playing.
Rate Function
For rate functins, 14 functions are defined in manimlib.utils.rate_function.py file.
smooth
linear
rush_into
rush_from
slow_into
double_smooth
there_and_back
there_and_back_with_pause
running_start
not_quite_there
wiggle
squish_rate_func
lingering
exponential_decay
Each function controls the speed of the animation.
What it means to each function is to control the animation speed:
For example, if you think of an animation that moves a point from position 0 to position 1 in 1 second, rate_func=linear is an animation that moves a point at a constant rate from 0 to 1 second. If you draw this as a graph with the x-axis as the time and the y-axis as the position of the point, it will look like the following.
The default function for rate_func in the play method is 'smooth'. This is a function that goes a little slower in the beginning and then moves at a constant speed in the middle and moves late again in the end. If you draw this as a graph, it is a sigmoid shape as shown below.
If we draw a graph for all 12 functions in this way, it is as follows.
While thinking about how to visually express the rate change of rate_func, I thought about drawing a moving position for time t.
It is good to see the difference in the operating speed of each function at a glance.
I tried to draw the graph in Excel, but I drew it in Manim using coding.
The coding strategy is,
- In Axes, make the x-axis longer than the y-axis,
- After obtaining 12 graphs through Axes.get_graph,
- Arrange and display these 12 graph objects on the screen with arange_grid.
The full source code is shown below.
def graph_rate_func2(self):
axes = Axes(
x_axis_config={
"unit_size": 2,
}
)
funcs = [smooth,linear,rush_into,rush_from,
slow_into,double_smooth,there_and_back,there_and_back_with_pause,
running_start,wiggle, lingering,exponential_decay,
]
func_names = ['smooth','linear','rush_into','rush_from',
'slow_into','double_smooth','there_and_back','there_and_back_with_pause',
'running_start','wiggle', 'lingering','exponential_decay',
]
def get_obj(name, func):
graph = axes.get_graph(func, x_min=0, x_max=1, color=YELLOW)
rect = SurroundingRectangle(graph, color=WHITE)
text = Text(name, size=0.25, stroke_width=0).next_to(graph,UP,buff=0.3)
return VGroup(graph,rect,text)
group = VGroup(*[get_obj(name,func) for name, func in zip(func_names, funcs)])
group.arrange_in_grid(4, 3)
self.add(group)
self.wait()
From the next page, we will look at animation classes dividing them by creating, indicating, transforming, moving/rotating, and grouping.
[06-1-B] Animation : Creation series
[06-1-C] Animation : Indicating series
[06-1-D] Animation : Move/Rotating series
[06-1-E] Animation : Transformation series (1/3)
[06-1-F] Animation : Transformation series (2/3)
[06-1-G] Animation : Transformation series (3/3)
[06-1-I] Animation : Special Effect
Next: [06-1-B] Animation : Creation series
Go To: [99] Table of Contents
'Programming > Manim Lectures' 카테고리의 다른 글
[06-1-C] Animation : Indicating series (0) | 2020.06.09 |
---|---|
[06-1-B] Animation : Creation series (0) | 2020.06.09 |
[06-1] Animation by Classes (0) | 2020.06.09 |
[06] Animation (0) | 2020.06.09 |
[05-5-E] Scene for Graph: GraphScene (0) | 2020.06.07 |