Composition

AnimationGroup

class manimlib.animation.composition.AnimationGroup(*animations, **kwargs)

动画组,可以传入一系列动画,统一播放

build_animations_with_timings()

创建三元组列表 (anim, start_time, end_time)

update_mobjects(dt)

更新 starting_mobject,以及 Transform 中的 target_mobject 的状态

注意:通常情况下,处在动画进程中的 self.mobject 会停止更新(只处理动画),所以这个方法对它是没有用的

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

AnimationGroupExample
class AnimationGroupExample(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.wait()
        anims = AnimationGroup(
            *[GrowFromCenter(mob) for mob in mobjects]
        )
        self.play(anims)
        self.wait()

Succession

class manimlib.animation.composition.Succession(*animations, **kwargs)

使子动画逐一播放

update_mobjects(dt)

更新 starting_mobject,以及 Transform 中的 target_mobject 的状态

注意:通常情况下,处在动画进程中的 self.mobject 会停止更新(只处理动画),所以这个方法对它是没有用的

Updates things like starting_mobject, and (for Transforms) target_mobject. Note, since typically (always?) self.mobject will have its updating suspended during the animation, this will do nothing to self.mobject.

SuccessionExample
class SuccessionExample(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()
        anims = Succession(
            *[ApplyMethod(mob.shift, DOWN) for mob in mobjects]
        )
        self.play(anims)
        self.wait()

LaggedStart

class manimlib.animation.composition.LaggedStart(*animations, **kwargs)

可以统一控制 lag_ratio 的动画组

LaggedStartExample
class LaggedStartExample(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()
        anims = LaggedStart(
            *[ApplyMethod(mob.shift, DOWN) for mob in mobjects]
        )
        self.play(anims)
        self.wait()

LaggedStartMap

class manimlib.animation.composition.LaggedStartMap(AnimationClass, mobject, arg_creator=None, **kwargs)

统一控制 动画类mobjectslag_ratio 的动画组

LaggedStartMapExample
class LaggedStartMapExample(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()
        anims = LaggedStartMap(
            FadeOut, mobjects
        )
        self.play(anims)
        self.wait()