Fading¶
注意
旧版的各种 FadeInFrom
和 FadeOutFrom
等方法已经全部整合在 FadeIn
和 FadeOut
中,以参数的形式给出,使得类的使用更加简洁
FadeOut¶
-
class
manimlib.animation.fading.
FadeOut
(mobject, shift=array([0.0, 0.0, 0.0]), scale=1, **kwargs)¶ 淡出
scale
: 缩放倍数shift
: 移动向量
FadeOutExample¶
class FadeOutExample(Scene):
def construct(self):
mobjects = VGroup(
Circle(),
Circle(fill_opacity=1),
Text("Text").scale(2)
)
mobjects.scale(1.5)
mobjects.arrange_submobjects(RIGHT,buff=2)
self.add(mobjects)
self.wait(0.3)
self.play(
*[FadeOut(mob) for mob in mobjects]
)
self.wait()
FadeIn¶
-
class
manimlib.animation.fading.
FadeIn
(mobject, shift=array([0.0, 0.0, 0.0]), scale=1, **kwargs)¶ 淡入
scale
: 缩放倍数shift
: 移动向量
FadeInExample¶
class FadeInExample(Scene):
def construct(self):
mobjects = VGroup(
Circle(),
Circle(fill_opacity=1),
TexText("Text").scale(2)
)
mobjects.scale(1.5)
mobjects.arrange_submobjects(RIGHT,buff=2)
self.play(
*[FadeIn(mob) for mob in mobjects]
)
self.wait()
FadeInFromExample¶
class FadeInFromExample(Scene):
def construct(self):
mobjects = VGroup(
Circle(),
Circle(fill_opacity=1),
TexText("Text").scale(2)
)
mobjects.scale(1.5)
mobjects.arrange_submobjects(RIGHT,buff=2)
directions=[UP,LEFT,DOWN,RIGHT]
for direction in directions:
self.play(
*[FadeIn(mob,shift=direction) for mob in mobjects]
)
self.wait()
FadeOutAndShiftExample¶
class FadeOutAndShiftExample(Scene):
def construct(self):
mobjects = VGroup(
Circle(),
Circle(fill_opacity=1),
TexText("Text").scale(2)
)
mobjects.scale(1.5)
mobjects.arrange_submobjects(RIGHT,buff=2)
directions=[UP,LEFT,DOWN,RIGHT]
self.add(mobjects)
self.wait(0.3)
for direction in directions:
self.play(
*[FadeOut(mob,shift=direction) for mob in mobjects]
)
self.wait()
FadeInFromLargeExample¶
class FadeInFromLargeExample(Scene):
def construct(self):
mobjects = VGroup(
Circle(),
Circle(fill_opacity=1),
TexText("Text").scale(2)
)
mobjects.scale(1.5)
mobjects.arrange_submobjects(RIGHT,buff=2)
scale_factors=[0.3,0.8,1,1.3,1.8]
for scale_factor in scale_factors:
t_scale_factor = TexText(f"\\tt scale\\_factor = {scale_factor}")
t_scale_factor.to_edge(UP)
self.add(t_scale_factor)
self.play(
*[FadeIn(mob,scale=scale_factor) for mob in mobjects]
)
self.remove(t_scale_factor)
self.wait(0.3)
FadeInFromPoint¶
-
class
manimlib.animation.fading.
FadeInFromPoint
(mobject, point, **kwargs)¶ 从传入的一个坐标点淡入
FadeInFromPointExample¶
class FadeInFromPointExample(Scene):
def construct(self):
mobjects = VGroup(
Circle(),
Circle(fill_opacity=1),
TexText("Text").scale(2)
)
mobjects.scale(1.5)
mobjects.arrange_submobjects(RIGHT,buff=2)
self.wait()
self.play(
*[FadeInFromPoint(mob, UP*3) for mob in mobjects]
)
self.wait()
FadeOutToPoint¶
-
class
manimlib.animation.fading.
FadeOutToPoint
(mobject, point, **kwargs)¶ 淡出到指定的坐标点
FadeTransform¶
FadeTransformPieces¶
-
class
manimlib.animation.fading.
FadeTransformPieces
(mobject, target_mobject, **kwargs)¶ 子物件分别渐变为目标
VFadeIn¶
-
class
manimlib.animation.fading.
VFadeIn
(mobject, **kwargs)¶ VFadeIn and VFadeOut only work for VMobjects,
VFadeOut¶
-
class
manimlib.animation.fading.
VFadeOut
(mobject, **kwargs)¶
VFadeInThenOut¶
-
class
manimlib.animation.fading.
VFadeInThenOut
(mobject, **kwargs)¶ 淡入后淡出
Fade和VFade的区别:
FadeIn
的边从细变粗,从暗变亮。 VFadeIn
的边始终是正常粗细,从暗变亮。
FadeOut
和 VFadeOut
无区别