Fading

声明

这一页翻译自elteoremadebeethoven的 manim_3feb_docs

部分为鹤翔万里补充

FadeOut

class manimlib.animation.fading.FadeOut(mobject, target_mobject=None, **kwargs)
FadeOutExample
class FadeOutExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("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, target_mobject=None, **kwargs)
FadeInExample
class FadeInExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("Text").scale(2)
            )
        mobjects.scale(1.5)
        mobjects.arrange_submobjects(RIGHT,buff=2)

        self.play(
            *[FadeIn(mob) for mob in mobjects]
        )

        self.wait()

FadeInFrom

class manimlib.animation.fading.FadeInFrom(mobject, direction=None, **kwargs)
FadeInFromExample
class FadeInFromExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("Text").scale(2)
            )
        mobjects.scale(1.5)
        mobjects.arrange_submobjects(RIGHT,buff=2)

        directions=[UP,LEFT,DOWN,RIGHT]

        for direction in directions:
            self.play(
                *[FadeInFrom(mob,direction) for mob in mobjects]
            )

        self.wait()

FadeInFromDown

class manimlib.animation.fading.FadeInFromDown(mobject, direction=None, **kwargs)

与FadeInFrom相同,只是有一个与默认值相同的名称

FadeInFromDownExample
class FadeInFromDownExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("Text").scale(2)
            )
        mobjects.scale(1.5)
        mobjects.arrange_submobjects(RIGHT,buff=2)

        self.play(
            *[FadeInFromDown(mob) for mob in mobjects]
        )

        self.wait()

FadeOutAndShift

class manimlib.animation.fading.FadeOutAndShift(mobject, direction=None, **kwargs)
FadeOutAndShiftExample
class FadeOutAndShiftExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("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(
                *[FadeOutAndShift(mob,direction) for mob in mobjects]
            )

        self.wait()

FadeOutAndShiftDown

class manimlib.animation.fading.FadeOutAndShiftDown(mobject, direction=None, **kwargs)

与FadeOutAndShift相同,只是有一个与默认值相同的名称

FadeOutAndShiftDownExample
class FadeOutAndShiftDownExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("Text").scale(2)
            )
        mobjects.scale(1.5)
        mobjects.arrange_submobjects(RIGHT,buff=2)

        self.play(
            *[FadeOutAndShiftDown(mob) for mob in mobjects]
        )

        self.wait()

FadeInFromPoint

class manimlib.animation.fading.FadeInFromPoint(mobject, point, **kwargs)
FadeInFromPointExample
class FadeInFromPointExample(Scene):
    def construct(self):
        mobjects = VGroup(
            Circle(),
            Circle(fill_opacity=1),
            TextMobject("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()

FadeInFromLarge

class manimlib.animation.fading.FadeInFromLarge(mobject, scale_factor=2, **kwargs)
FadeInFromLargeExample
class FadeInFromLargeExample(Scene):
    def construct(self):
        mobjects = VGroup(
                Circle(),
                Circle(fill_opacity=1),
                TextMobject("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 = TextMobject(f"\\tt scale\\_factor = {scale_factor}")
            t_scale_factor.to_edge(UP)

            self.add(t_scale_factor)

            self.play(
                *[FadeInFromLarge(mob,scale_factor) for mob in mobjects]
            )

            self.remove(t_scale_factor)

        self.wait(0.3)

VFadeIn

class manimlib.animation.fading.VFadeIn(mobject, **kwargs)

VFadeIn和VFadeOut只对VMobject有效

VFadeOut

class manimlib.animation.fading.VFadeOut(mobject, **kwargs)

VFadeInThenOut

class manimlib.animation.fading.VFadeInThenOut(mobject, **kwargs)

Fade和VFade的区别

FadeIn 的边从细变粗,从暗变亮。 VFadeIn 的边始终是正常粗细,从暗变亮。

FadeOutVFadeOut 无区别