예제 #1
0
 def __init__(self, mobject, **kwargs):
     digest_config(self, kwargs)
     if self.scale_about_point is None:
         self.scale_about_point = mobject.get_center()
     if self.rotate_about_point is None:
         self.rotate_about_point = mobject.get_center()
     OldAnimation.__init__(self, mobject, **kwargs)
예제 #2
0
 def update_config(self, **kwargs):
     OldAnimation.update_config(self, **kwargs)
     if "path_arc" in kwargs:
         self.path_func = path_along_arc(
             kwargs["path_arc"],
             kwargs.get("path_arc_axis", OUT)
         )
예제 #3
0
    def update_config(self, **kwargs):
        OldAnimation.update_config(self, **kwargs)

        # If AnimationGroup is called with any configuration,
        # it is propagated to the sub_animations
        for anim in self.sub_anims:
            anim.update_config(**kwargs)
예제 #4
0
 def __init__(self, decimal_number_mobject, number_update_func, **kwargs):
     digest_config(self, kwargs, locals())
     if self.tracked_mobject:
         dmc = decimal_number_mobject.get_center()
         tmc = self.tracked_mobject.get_center()
         self.diff_from_tracked_mobject = dmc - tmc
         self.diff_from_tracked_mobject = dmc - tmc
     OldAnimation.__init__(self, decimal_number_mobject, **kwargs)
예제 #5
0
 def __init__(self, homotopy, mobject, **kwargs):
     """
     Homotopy a function from (x, y, z, t) to (x', y', z')
     """
     def function_at_time_t(t):
         return lambda p: homotopy(p[0], p[1], p[2], t)
     self.function_at_time_t = function_at_time_t
     digest_config(self, kwargs)
     OldAnimation.__init__(self, mobject, **kwargs)
예제 #6
0
 def __init__(self, AnimationClass, mobjects, **kwargs):
     full_kwargs = AnimationClass.CONFIG
     full_kwargs.update(kwargs)
     full_kwargs["mobject"] = Mobject(
         *[mob.get_point_mobject() for mob in mobjects])
     self.centers_container = AnimationClass(**full_kwargs)
     full_kwargs.pop("mobject")
     OldAnimation.__init__(self, Mobject(*mobjects), **full_kwargs)
     self.name = str(self) + AnimationClass.__name__
예제 #7
0
 def update_mobject(self, alpha):
     OldAnimation.update_mobject(self, alpha)
     if self.in_place and self.about_point is None:
         self.about_point = self.mobject.get_center()
     self.mobject.rotate(
         alpha * self.radians,
         axis=self.axis,
         about_point=self.about_point,
         about_edge=self.about_edge,
     )
예제 #8
0
    def __init__(self, mobject, target_mobject, **kwargs):
        # Copy target_mobject so as to not mess with caller
        self.original_target_mobject = target_mobject
        target_mobject = target_mobject.copy()
        mobject.align_data(target_mobject)
        self.target_mobject = target_mobject
        digest_config(self, kwargs)
        self.init_path_func()

        OldAnimation.__init__(self, mobject, **kwargs)
        self.name += "To" + str(target_mobject)
예제 #9
0
    def __init__(self, *sub_anims, **kwargs):
        sub_anims = [x for x in sub_anims if not (x.empty)]
        digest_config(self, locals())
        self.update_config(**kwargs)  # Handles propagation to self.sub_anims

        if len(sub_anims) == 0:
            self.empty = True
            self.run_time = 0
        else:
            self.run_time = max([a.run_time for a in sub_anims])
        everything = Mobject(*[a.mobject for a in sub_anims])
        OldAnimation.__init__(self, everything, **kwargs)
예제 #10
0
    def __init__(self, AnimationClass, mobject, arg_creator=None, **kwargs):
        digest_config(self, kwargs)
        for key in "rate_func", "run_time", "lag_ratio":
            if key in kwargs:
                kwargs.pop(key)
        if arg_creator is None:

            def arg_creator(mobject):
                return (mobject, )

        self.subanimations = [
            AnimationClass(*arg_creator(submob),
                           run_time=self.run_time,
                           rate_func=squish_rate_func(self.rate_func, beta,
                                                      beta + self.lag_ratio),
                           **kwargs)
            for submob, beta in zip(
                mobject, np.linspace(0, 1 - self.lag_ratio, len(mobject)))
        ]
        OldAnimation.__init__(self, mobject, **kwargs)
예제 #11
0
 def __init__(self, mobject, path, **kwargs):
     digest_config(self, kwargs, locals())
     OldAnimation.__init__(self, mobject, **kwargs)
예제 #12
0
 def clean_up(self, surrounding_scene=None):
     OldAnimation.clean_up(self, surrounding_scene)
     if self.replace_mobject_with_target_in_scene and surrounding_scene is not None:
         surrounding_scene.remove(self.mobject)
         if not self.remover:
             surrounding_scene.add(self.original_target_mobject)
예제 #13
0
 def __init__(self, mobject, tracked_mobject, **kwargs):
     digest_config(self, kwargs, locals())
     tcp = self.tracked_critical_point
     self.diff = mobject.get_critical_point(tcp) - \
         tracked_mobject.get_critical_point(tcp)
     OldAnimation.__init__(self, mobject, **kwargs)
예제 #14
0
 def __init__(self, mobject, update_function, **kwargs):
     digest_config(self, kwargs, locals())
     OldAnimation.__init__(self, mobject, **kwargs)
예제 #15
0
    def __init__(self, *args, **kwargs):
        """
        Each arg will either be an animation, or an animation class
        followed by its arguments (and potentially a dict for
        configuration).
        For example,
        Succession(
            ShowCreation(circle),
            Transform, circle, square,
            Transform, circle, triangle,
            ApplyMethod, circle.shift, 2*UP, {"run_time" : 2},
        )
        """
        animations = []
        state = {
            "animations": animations,
            "curr_class": None,
            "curr_class_args": [],
            "curr_class_config": {},
        }

        def invoke_curr_class(state):
            if state["curr_class"] is None:
                return
            anim = state["curr_class"](*state["curr_class_args"],
                                       **state["curr_class_config"])
            state["animations"].append(anim)
            anim.update(1)
            state["curr_class"] = None
            state["curr_class_args"] = []
            state["curr_class_config"] = {}

        for arg in args:
            if isinstance(arg, OldAnimation):
                animations.append(arg)
                arg.update(1)
                invoke_curr_class(state)
            elif isinstance(arg, type) and issubclass(arg, Animation):
                invoke_curr_class(state)
                state["curr_class"] = arg
            elif isinstance(arg, dict):
                state["curr_class_config"] = arg
            else:
                state["curr_class_args"].append(arg)
        invoke_curr_class(state)
        for anim in animations:
            anim.update(0)

        animations = [x for x in animations if not (x.empty)]

        self.run_times = [anim.run_time for anim in animations]
        if "run_time" in kwargs:
            run_time = kwargs.pop("run_time")
            warnings.warn(
                "Succession doesn't currently support explicit run_time.")
        run_time = sum(self.run_times)
        self.num_anims = len(animations)
        if self.num_anims == 0:
            self.empty = True
        self.animations = animations
        # Have to keep track of this run_time, because Scene.play
        # might very well mess with it.
        self.original_run_time = run_time

        # critical_alphas[i] is the start alpha of self.animations[i]
        # critical_alphas[i + 1] is the end alpha of self.animations[i]
        critical_times = np.concatenate(([0], np.cumsum(self.run_times)))
        self.critical_alphas = [
            np.true_divide(x, run_time) for x in critical_times
        ] if self.num_anims > 0 else [0.0]

        # self.scene_mobjects_at_time[i] is the scene's mobjects at start of self.animations[i]
        # self.scene_mobjects_at_time[i + 1] is the scene mobjects at end of self.animations[i]
        self.scene_mobjects_at_time = [None for i in range(self.num_anims + 1)]
        self.scene_mobjects_at_time[0] = Group()
        for i in range(self.num_anims):
            self.scene_mobjects_at_time[
                i + 1] = self.scene_mobjects_at_time[i].copy()
            self.animations[i].clean_up(self.scene_mobjects_at_time[i + 1])

        self.current_alpha = 0
        # If self.num_anims == 0, this is an invalid index, but so it goes
        self.current_anim_index = 0
        if self.num_anims > 0:
            self.mobject = self.scene_mobjects_at_time[0]
            self.mobject.add(self.animations[0].mobject)
        else:
            self.mobject = Group()

        OldAnimation.__init__(self, self.mobject, run_time=run_time, **kwargs)
예제 #16
0
 def __init__(self, *args, **kwargs):
     return OldAnimation.__init__(self, Group(), *args, **kwargs)
예제 #17
0
 def __init__(self, vmobject, **kwargs):
     if not isinstance(vmobject, VMobject):
         raise Exception("DrawBorderThenFill only works for VMobjects")
     self.reached_halfway_point_before = False
     OldAnimation.__init__(self, vmobject, **kwargs)
예제 #18
0
 def __init__(self, mobject=None, **kwargs):
     if mobject is None:
         mobject = Line(3 * LEFT, 3 * RIGHT)
     OldAnimation.__init__(self, mobject, **kwargs)