1、概述
在第二篇文章中已经对动画系统做了简要的说明,本文将用更多示例详细说明manim中的各种动画。需要说明的是,以前三篇文章使用的是manimCE0.50的版本。而本文升级到了0.60所以很多示例可能在0.50的版本中无法正常运行。
2、 淡入淡出
%%manim -ql -v WARNING -i FadeScene
class FadeScene(Scene):
def construct(self):
text = Text('First Order Model').scale(2)
self.add(text)
# 淡入效果
#self.play(FadeIn(text,lag_ratio=.2))
#self.play(FadeInFrom(text,direction=UP))
#self.play(FadeInFromLarge(text,scale_factor=2))
#self.play(FadeInFromPoint(text,ORIGIN))
# 淡出效果
# self.play(FadeOut(text))
# self.play(FadeOutAndShift(text,direction=RIGHT))
self.play(FadeOutToPoint(text,ORIGIN))
self.wait()
3、 生长动画
- 该动画一定应用在有方向的物体上
%%manim -ql -v WARNING -i GrowScene
class GrowScene(Scene):
def construct(self):
arrow = Arrow(start=LEFT, end=RIGHT)
self.add(arrow)
circle=Circle()
self.play(GrowArrow(arrow))
self.play(Uncreate(arrow))
self.add(circle)
self.play(GrowFromCenter(circle,point_color=RED))
#self.play(GrowFromEdge(arrow,edge=LEFT))
#self.play(GrowFromPoint(circle,point=[-0.5,0,0],point_color=RED))
#self.play(SpinInFromNothing(circle,path_arc=0))
self.wait()
4 强调动画
%%manim -ql -v WARNING -i Indications
from manim import *
class Indications(Scene):
def construct(self):
indications = [ApplyWave,Circumscribe,Flash,FocusOn,Indicate,ShowPassingFlash,Wiggle]
names = [Tex(i.__name__).scale(3) for i in indications]
self.add(names[0])
for i in range(len(names)):
if indications[i] is Flash:
self.play(Flash(UP))
elif indications[i] is ShowPassingFlash:
self.play(ShowPassingFlash(Underline(names[i])))
else:
self.play(indications[i](names[i]))
self.play(AnimationGroup(
FadeOutAndShift(names[i], UP*1.5),
FadeInFrom(names[(i+1)%len(names)], DOWN*1.5),