Exemplo n.º 1
0
class TransformAnimations(Transform):
    CONFIG = {
        "rate_func" : squish_rate_func(smooth)
    }
    def __init__(self, start_anim, end_anim, **kwargs):
        digest_config(self, kwargs, locals())
        if "run_time" in kwargs:
            self.run_time = kwargs.pop("run_time")
        else:
            self.run_time = max(start_anim.run_time, end_anim.run_time)
        for anim in start_anim, end_anim:
            anim.set_run_time(self.run_time)
            
        if start_anim.starting_mobject.get_num_points() != end_anim.starting_mobject.get_num_points():
            start_anim.starting_mobject.align_data(end_anim.starting_mobject)
            for anim in start_anim, end_anim:
                if hasattr(anim, "target_mobject"):
                    anim.starting_mobject.align_data(anim.target_mobject)

        Transform.__init__(self, start_anim.mobject, end_anim.mobject, **kwargs)
        #Rewire starting and ending mobjects
        start_anim.mobject = self.starting_mobject
        end_anim.mobject = self.target_mobject

    def update(self, alpha):
        self.start_anim.update(alpha)
        self.end_anim.update(alpha)
        Transform.update(self, alpha)
Exemplo n.º 2
0
 def get_rate_func(pi):
     index = creatures_list.index(pi)
     proportion = float(index) / len(creatures_list)
     start_time = 0.8 * proportion
     return squish_rate_func(
         there_and_back,
         start_time, start_time + 0.2
     )
Exemplo n.º 3
0
 def blink_anim(self, **kwargs):
     target = self.copy()
     bottom_y = self.get_bottom()[1]
     for submob in target:
         submob.apply_function(lambda p: [p[0], bottom_y, p[2]])
     if "rate_func" not in kwargs:
         kwargs["rate_func"] = squish_rate_func(there_and_back)
     return Transform(self, target, **kwargs)
Exemplo n.º 4
0
 def get_rate_func(pi):
     index = creatures_list.index(pi)
     proportion = float(index) / len(creatures_list)
     start_time = 0.8 * proportion
     return squish_rate_func(
         there_and_back,
         start_time, start_time + 0.2
     )
Exemplo n.º 5
0
class CircleIndicate(Indicate):
    CONFIG = {
        "rate_func" : squish_rate_func(there_and_back, 0, 0.8),
        "remover" : True
    }
    def __init__(self, mobject, **kwargs):
        digest_config(self, kwargs)
        circle = Circle(color = self.color, **kwargs)
        circle.surround(mobject)
        Indicate.__init__(self, circle, **kwargs)
Exemplo n.º 6
0
 def blink_anim(self, **kwargs):
     target = self.copy()
     bottom_y = self.get_bottom()[1]
     for submob in target:
         submob.apply_function(
             lambda p: [p[0], bottom_y, p[2]]
         )
     if "rate_func" not in kwargs:
         kwargs["rate_func"] = squish_rate_func(there_and_back)
     return Transform(self, target, **kwargs)
Exemplo n.º 7
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:
         arg_creator = lambda mobject: (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)))
     ]
     Animation.__init__(self, mobject, **kwargs)
Exemplo n.º 8
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))
         )
     ]
     Animation.__init__(self, mobject, **kwargs)
Exemplo n.º 9
0
class Blink(ApplyMethod):
    CONFIG = {"rate_func": squish_rate_func(there_and_back)}

    def __init__(self, pi_creature, **kwargs):
        ApplyMethod.__init__(self, pi_creature.blink, **kwargs)