Пример #1
0
    def play(self, *animations, **kwargs):
        if "run_time" in kwargs:
            run_time = kwargs["run_time"]
        else:
            run_time = animations[0].run_time
        for animation in animations:
            animation.set_run_time(run_time)
        moving_mobjects = [
            mobject
            for anim in animations
            for mobject in anim.mobject.get_full_submobject_family()
        ]

        bundle = Mobject(*self.mobjects)
        static_mobjects = filter(
            lambda m : m not in moving_mobjects, 
            bundle.get_full_submobject_family()
        )
        background = disp.paint_mobjects(
            static_mobjects,
            self.background,
            include_sub_mobjects = False
        )

        print "Generating " + ", ".join(map(str, animations))
        progress_bar = progressbar.ProgressBar(maxval=run_time)
        progress_bar.start()

        for t in np.arange(0, run_time, self.frame_duration):
            progress_bar.update(t)
            for animation in animations:
                animation.update(t / animation.run_time)
            new_frame = disp.paint_mobjects(moving_mobjects, background)
            self.frames.append(new_frame)
        for animation in animations:
            animation.clean_up()
        self.add(*moving_mobjects)
        self.repaint_mojects()
        progress_bar.finish()
        return self