コード例 #1
0
 def __init__(self, *animations, time=None, group=False, time_wait=None, **kwargs):
     merge_config_kwargs(self, kwargs)
     while isinstance(animations[-1], (int, float, bool)):
         if isinstance(animations[-1], bool):
             if int(animations[-1]) == 1:
                 group = True
             animations = animations[:-1]
         elif isinstance(animations[-1], (int, float)):
             if animations[-1] > 0:
                 time = animations[-1]
             elif animations[-1] < 0:
                 time_wait = -animations[-1]
             animations = animations[:-1]
     if group:
         animations = [AnimationGroup(*animations, **kwargs)]
     anims = AGroup(*animations)
     if time is not None:
         self.time=time
     if self.delay:
         anims.add_to_back(Freeze(self.time))
     else:
         anims.add(Freeze(self.time))
     if time_wait is not None:
         anims.add(Freeze(time_wait))
     super().__init__(*anims, **kwargs)
コード例 #2
0
 def add_element(self, *args, **kwargs):
     if not args or isinstance(args[0], (Mobject, list)) or not isinstance(args[0], (int, float, tuple)):
         self.mobject_or_point, self.from_offset, self.to_offset, kwargs = \
             generate_args_kwargs(self, args, kwargs,
                                  ["mobject_or_point", "from_offset", "to_offset"],
                                  [ORIGIN, -0.1, 0.1]
                                  )
     elif isinstance(args[0], (int, float, tuple)):
         self.length, self.mobject_or_point = \
             generate_args(self, args,
                           [0.2, ORIGIN])
         if isinstance(self.length, tuple):
             self.length = list(self.length)
         self.from_offset, self.to_offset = to_get_offsets(self.length, 2)
         kwargs = merge_config_kwargs(self, kwargs,
                                      ["length", "mobject_or_point"]
                                      )
     else:
         self.mobject_or_point, self.from_offset, self.to_offset, kwargs = \
             generate_args_kwargs(self, (), kwargs,
                                  ["mobject_or_point", "from_offset", "to_offset"],
                                  [ORIGIN, -0.5, 0.5]
                                  )
     return self.add_points_as_subpaths(np.transpose(
         to_get_offset_lists(
             self.mobject_or_point,
             [self.from_offset, self.to_offset])
            ,(1,0,2)) )
     '''
コード例 #3
0
 def __init__(self, *mobjects, **kwargs):
     self.show_rate_func = linear
     kwargs = merge_config_kwargs(self, kwargs)
     super().__init__(
         ShowSubmobjectsOneByOne(mobjects[0].add(Mobject()),
                                 rate_func=self.show_rate_func,
                                 **kwargs),
         FadeInThenIndicateThenFadeOut(mobjects[1], **kwargs), **kwargs)
コード例 #4
0
 def __init__(self, mobject, run_time=1, indicate=True, **kwargs):
     kwargs = merge_config_kwargs(self, kwargs, self.CONFIG)
     if not indicate:
         kwargs['color'] = mobject.get_color()
     super().__init__(
         ShowCreation(mobject, run_time=run_time*0.95),
         Indicate(mobject, run_time=run_time*0.05, **kwargs),
         run_time=run_time, **kwargs
     )
コード例 #5
0
 def __init__(self, mobjs1, mobjs2, run_time=1, transpose=1, lag_ratio=0, **kwargs):
     kwargs = merge_config_kwargs(self, kwargs)
     animations = AGroup()
     if transpose:
         #[a, b, c], [x, y, z]
         mobjects = list(map(list, zip(mobjs1, mobjs2)))
         #[a, x], [b, y], [c, z]
     [animations.add(ApplyMethod(self.func(each[0]), each[1], **kwargs))
      for each in mobjects]
     super().__init__(*animations, lag_ratio=lag_ratio, run_time=run_time, **kwargs)
コード例 #6
0
    def __init__(self, mobject, **kwargs):
        self.mobject_color = YELLOW
        self.total_run_time = 4
        self.total_lag_ratio = 1
        kwargs = merge_config_kwargs(self, kwargs)

        super().__init__(
            ShowPassingFlash(mobject.set_color(
                self.mobject_color), **kwargs),
            IndicateThenFadeOut(mobject.copy(), **kwargs),
            run_time=self.total_run_time, lag_ratio=self.total_lag_ratio)
コード例 #7
0
 def __init__(self,
              mobject,
              mobject_or_point="get_center()",
              *args,
              **kwargs):
     self.mobject_or_point = to_get_point(mobject_or_point, mobject)
     self.args_name = ["point_color", "scale"]
     self.args = [None, 0]
     [self.point_color, self.scale] = \
         generate_args(self, args, self.args)
     kwargs = merge_config_kwargs(self, kwargs, self.args_name)
     super().__init__(mobject, **kwargs)
コード例 #8
0
 def __init__(self, *args, **kwargs):
     self.args_name = \
         ["height", "width", "mobject_or_point",
             "start_angle", "element", "normal_vector"]
     self.args = \
         [2, 4, ORIGIN, None, "edge", "IN"]
     [self.height, self.width, self.mobject_or_point, self.start_angle, self.element, self.normal_vector] = \
         generate_args(self, args, self.args)
     kwargs = merge_config_kwargs(self, kwargs, self.args_name)
     self.mobject_or_point = Location(self.mobject_or_point)
     ul, ur, dr, dl = np.add(np.multiply(
         (UL, UR, DR, DL), [self.width/2, self.height/2, 0]), self.mobject_or_point)
     GeomPolygon.__init__(self, ul, ur, dr, dl, **kwargs)
コード例 #9
0
    def __init__(self, *args, **kwargs):
        self.args_name = \
            ["side_length", "mobject_or_point",
                "start_angle", "element", "normal_vector"]
        self.args = \
            [2, ORIGIN,  None, "edge", "IN"]
        [self.side_length, self.mobject_or_point, self.start_angle, self.element, self.normal_vector] = \
            generate_args(self, args, self.args)
        kwargs = merge_config_kwargs(self, kwargs, self.args_name)

        GeomRectangle.__init__(
            self,
            self.side_length,
            self.side_length,
            *args[1:],
            **kwargs
        )
コード例 #10
0
    def __init__(self, n=6, *args, **kwargs):
        self.args_name = \
            ["mobject_or_point", "radius", "start_angle", "element", "normal_vector"]
        self.args = \
            [ORIGIN, 1, None, "point", "OUT"]
        self.mobject_or_point, self.radius, self.start_angle, self.element, self.normal_vector = \
            generate_args(self, args, self.args)
        kwargs = merge_config_kwargs(self, kwargs, self.args_name)

        self.mobject_or_point = Location(self.mobject_or_point)
        if self.element == "point":
            if self.start_angle is None:
                if n % 2 == 0:
                    self.start_angle = 0
                else:
                    self.start_angle = 90 * DEGREES
            start_vect = rotate_vector(self.radius*RIGHT, self.start_angle)
        vertices = np.add(compass_directions(n, start_vect),
                          np.repeat([self.mobject_or_point], n, axis=0))
        GeomPolygon.__init__(self, *vertices, **kwargs)