def _main_title(self):
        paper_name_a = TextMobject(
            "Simulating human interactions in supermarkets to")
        paper_name_b = TextMobject(
            "measure the risk of COVID-19 contagion at scale")
        author_list_a = TextMobject(
            "Serge Plata\\quad Sumanas Sarma\\quad Melvin Lancelot")
        author_list_b = TextMobject(
            "Kristine Bagrova\\quad David Romano-Critchley")
        arxiv = TextMobject("arXiv:2006.15213")

        paper_name_a.shift(UP)
        paper_name_b.next_to(paper_name_a, DOWN)

        author_list_a.scale(0.8)
        author_list_b.scale(0.8)

        author_list_a.next_to(paper_name_b, DOWN + DOWN)
        author_list_b.next_to(author_list_a, DOWN)

        arxiv.scale(0.6)
        arxiv.next_to(author_list_b, DOWN + DOWN)

        self.play(FadeIn(paper_name_a), FadeIn(paper_name_b))
        self.wait()
        self.play(FadeIn(author_list_a), FadeIn(author_list_b))
        self.play(FadeIn(arxiv))

        self.wait(4)
        self.play(FadeOut(paper_name_a), FadeOut(paper_name_b),
                  FadeOut(author_list_a), FadeOut(author_list_b),
                  ApplyMethod(arxiv.move_to, BOTTOM + (UP * 0.5)))
Пример #2
0
    def construct(self):
        quote = TextMobject("Imagination is more important than knowledge")
        quote.set_color(RED)
        quote.to_edge(UP)

        quote2 = TextMobject(
            "A person who never made a mistake never tried anything new")
        quote2.set_color(YELLOW)
        author = TextMobject("- Albert Einstein")
        author.scale(0.75)

        corner = quote.get_corner(DOWN + RIGHT)
        print("corner", corner)
        author.next_to(corner, ORIGIN)

        self.add(quote, author)
        self.wait(2)
        self.play(
            Transform(quote, quote2),
            ApplyMethod(author.move_to,
                        quote2.get_corner(DOWN + RIGHT) + DOWN + 2 * LEFT))
        self.play(ApplyMethod(author.scale, 1.5))
        author.match_color(quote2)
        self.play(FadeOut(quote), FadeOut(author))
        self.wait()
Пример #3
0
 def __init__(self, *mobjects,run_time = 0.001, **kwargs):
     if isinstance(mobjects[-1], (int, float)):
         run_time = mobjects[-1]
         mobject = Group(*mobjects[:-1])
     else:
         
         mobject = Group(*mobjects)
     super().__init__(
         FadeOut(mobject, run_time=run_time*0.9),
         FadeOut(mobject, run_time=run_time*0.1),
         run_time=run_time,**kwargs)
Пример #4
0
    def __init__(self, pi_creature, **kwargs):
        assert hasattr(pi_creature, "bubble")
        digest_config(self, kwargs, locals())

        pi_creature.generate_target()
        pi_creature.target.change_mode(self.target_mode)
        if self.look_at_arg is not None:
            pi_creature.target.look_at(self.look_at_arg)

        AnimationGroup.__init__(
            self,
            MoveToTarget(pi_creature),
            FadeOut(pi_creature.bubble),
            FadeOut(pi_creature.bubble.content),
        )
Пример #5
0
    def coords_to_vector(self,
                         vector,
                         coords_start=2 * RIGHT + 2 * UP,
                         clean_up=True):
        starting_mobjects = list(self.submobjects)
        array = Matrix(vector)
        array.shift(coords_start)
        arrow = Vector(vector)
        x_line = Line(ORIGIN, vector[0] * RIGHT)
        y_line = Line(x_line.get_end(), arrow.get_end())
        x_line.set_color(X_COLOR)
        y_line.set_color(Y_COLOR)
        x_coord, y_coord = array.get_mob_matrix().flatten()

        self.play(Write(array, run_time=1))
        self.wait()
        self.play(
            ApplyFunction(
                lambda x: self.position_x_coordinate(x, x_line, vector),
                x_coord))
        self.play(ShowCreation(x_line))
        self.play(
            ApplyFunction(
                lambda y: self.position_y_coordinate(y, y_line, vector),
                y_coord), FadeOut(array.get_brackets()))
        y_coord, brackets = self.get_mobjects_from_last_animation()
        self.play(ShowCreation(y_line))
        self.play(ShowCreation(arrow))
        self.wait()
        if clean_up:
            self.clear()
            self.add(*starting_mobjects)
Пример #6
0
 def __init__(self, mobject, run_time=1, ratio_array=[0.01, 0.5, 0.5], fadeout_func=rush_into, **kwargs):
     animations = AGroup(
         FadeIn(mobject, run_time=ratio_array[0]*run_time),
         Indicate(mobject, run_time=ratio_array[1]*run_time,  **kwargs),
         FadeOut(mobject, run_time=ratio_array[2]*run_time, rate_func=fadeout_func))
     [animations.remove(animations[i])
      for i in range(len(ratio_array)) if ratio_array[i] == 0]
     super().__init__(*animations, **kwargs)
Пример #7
0
 def __init__(self, mobject, run_time=1, ratio_array=[0.5, 0.5], **kwargs):
     super().__init__(
         Indicate(mobject, run_time=run_time *
                  ratio_array[0], **kwargs),  # 0.5
         FadeOut(mobject, run_time=run_time * \
                 ratio_array[1], **kwargs),  # 0.03
         **kwargs
     )
Пример #8
0
 def __init__(self, mobject, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([mobject])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     super().__init__(ShowCreation(mobject), FadeOut(mobject), **kwargs)
Пример #9
0
 def __init__(self, mobject, run_time=5, ratio_array=[0.95, 0.05], **kwargs):
     super().__init__(
         ShowCreation(mobject, run_time=run_time *
                      ratio_array[0], **kwargs),  # run_time *
         # ratio_array[0], **kwargs),  # 0.5
         FadeOut(mobject, run_time=run_time * \
                 ratio_array[1], **kwargs),  # 0.03
         **kwargs
     )
Пример #10
0
    def coords_to_vector(self,
                         vector,
                         coords_start=2 * RIGHT + 2 * UP,
                         clean_up=True):
        """
        This method writes the vector as a column matrix (henceforth called the label),
        takes the values in it one by one, and form the corresponding
        lines that make up the x and y components of the vector. Then, an
        Vector() based vector is created between the lines on the Screen.

        Parameters
        ----------
        vector Union(np.ndarray, list, tuple)
            The vector to show.
        
        coords_start Union(np.ndarray,list,tuple)
            The starting point of the location of 
            the label of the vector that shows it 
            numerically.
            Defaults to 2 * RIGHT + 2 * UP or (2,2)
        
        clean_up (bool=True)
            Whether or not to remove whatever
            this method did after it's done.

        """
        starting_mobjects = list(self.mobjects)
        array = Matrix(vector)
        array.shift(coords_start)
        arrow = Vector(vector)
        x_line = Line(ORIGIN, vector[0] * RIGHT)
        y_line = Line(x_line.get_end(), arrow.get_end())
        x_line.set_color(X_COLOR)
        y_line.set_color(Y_COLOR)
        x_coord, y_coord = array.get_mob_matrix().flatten()

        self.play(Write(array, run_time=1))
        self.wait()
        self.play(
            ApplyFunction(
                lambda x: self.position_x_coordinate(x, x_line, vector),
                x_coord))
        self.play(ShowCreation(x_line))
        self.play(
            ApplyFunction(
                lambda y: self.position_y_coordinate(y, y_line, vector),
                y_coord), FadeOut(array.get_brackets()))
        y_coord, brackets = self.get_mobjects_from_last_animation()
        self.play(ShowCreation(y_line))
        self.play(ShowCreation(arrow))
        self.wait()
        if clean_up:
            self.clear()
            self.add(*starting_mobjects)
Пример #11
0
    def construct(self):
        circle = Circle()
        square = Square()
        line = Line((3, 0, 0), (5, 0, 0))
        triangle = Polygon((0, 0, 0), (1, 1, 0), (1, -1, 0))

        self.play(ShowCreation(circle), run_time=5)
        self.play(FadeOut(circle), GrowFromCenter(square))
        self.add(line)
        self.play(Transform(square, triangle))
        self.play(Transform(triangle))
        self.wait()
Пример #12
0
    def construct(self):
        circle = Circle()
        square = Square()
        line = Line(np.array([3, 0, 0]), np.array([5, 0, 0]))
        triangle = Polygon(np.array([0, 0, 0]), np.array([1, 1, 0]),
                           np.array([1, -1, 0]))

        self.add(line)
        self.play(ShowCreation(circle))
        self.play(FadeOut(circle))
        self.play(GrowFromCenter(square))
        self.play(Transform(square, triangle))
        self.wait()
Пример #13
0
 def __init__(self,
              *mobjects,
              run_time=5,
              ratio_array=[0.95, 0.05],
              **kwargs):
     super().__init__(
         ShowCreationThenFadeOut(mobjects[0], run_time=run_time*ratio_array[0], **kwargs),  # run_time *
         # ratio_array[0], **kwargs),  # 0.5
         ShowCreationThenFadeOut(mobjects[1], run_time=run_time*ratio_array[0], **kwargs),  # run_time *
         # ratio_array[0], **kwargs),  # 0.5
         FadeOut(VGroup(*mobjects), run_time=run_time * \
                 ratio_array[1], **kwargs),  # 0.03
         **kwargs
     )
Пример #14
0
    def construct(self):
        morty = Mortimer()
        morty.next_to(ORIGIN, DOWN)

        patreon_logo = PatreonLogo()
        patreon_logo.to_edge(UP)

        patrons = list(map(TextMobject, self.specific_patronds))
        num_groups = float(len(patrons)) / self.max_patron_group_size
        proportion_range = np.linspace(0, 1, num_groups + 1)
        indices = (len(patrons) * proportion_range).astype('int')
        patron_groups = [
            VGroup(*patrons[i:j])
            for i, j in zip(indices, indices[1:])
        ]

        for i, group in enumerate(patron_groups):
            left_group = VGroup(*group[:len(group) / 2])
            right_group = VGroup(*group[len(group) / 2:])
            for subgroup, vect in (left_group, LEFT), (right_group, RIGHT):
                subgroup.arrange(DOWN, aligned_edge=LEFT)
                subgroup.scale(self.patron_scale_val)
                subgroup.to_edge(vect)

        last_group = None
        for i, group in enumerate(patron_groups):
            anims = []
            if last_group is not None:
                self.play(
                    FadeOut(last_group),
                    morty.look, UP + LEFT
                )
            else:
                anims += [
                    DrawBorderThenFill(patreon_logo),
                ]
            self.play(
                LaggedStartMap(
                    FadeIn, group,
                    run_time=2,
                ),
                morty.change, "gracious", group.get_corner(UP + LEFT),
                *anims
            )
            self.play(morty.look_at, group.get_corner(DOWN + LEFT))
            self.play(morty.look_at, group.get_corner(UP + RIGHT))
            self.play(morty.look_at, group.get_corner(DOWN + RIGHT))
            self.play(Blink(morty))
            last_group = group
Пример #15
0
    def animate_product(self, left, right, result):
        l_matrix = left.get_mob_matrix()
        r_matrix = right.get_mob_matrix()
        result_matrix = result.get_mob_matrix()
        circle = Circle(radius=l_matrix[0][0].get_height(), color=GREEN)
        circles = VGroup(*[
            entry.get_point_mobject()
            for entry in (l_matrix[0][0], r_matrix[0][0])
        ])
        (m, k), n = l_matrix.shape, r_matrix.shape[1]
        for mob in result_matrix.flatten():
            mob.set_color(BLACK)
        lagging_anims = []
        for a in range(m):
            for b in range(n):
                for c in range(k):
                    l_matrix[a][c].set_color(YELLOW)
                    r_matrix[c][b].set_color(YELLOW)
                for c in range(k):
                    start_parts = VGroup(l_matrix[a][c].copy(),
                                         r_matrix[c][b].copy())
                    result_entry = result_matrix[a][b].split()[c]

                    new_circles = VGroup(*[
                        circle.copy().shift(part.get_center())
                        for part in start_parts.split()
                    ])
                    self.play(Transform(circles, new_circles))
                    self.play(
                        Transform(
                            start_parts,
                            result_entry.copy().set_color(YELLOW),
                            path_arc=-np.pi / 2,
                            lag_ratio=0,
                        ), *lagging_anims)
                    result_entry.set_color(YELLOW)
                    self.remove(start_parts)
                    lagging_anims = [
                        ApplyMethod(result_entry.set_color, WHITE)
                    ]

                for c in range(k):
                    l_matrix[a][c].set_color(WHITE)
                    r_matrix[c][b].set_color(WHITE)
        self.play(FadeOut(circles), *lagging_anims)
        self.wait()
Пример #16
0
 def play_farey_sum_animation(self, p1, q1, p2, q2):
     c1, c2, c3, l1, l2, l3 = self.get_farey_sum_key_mobjects(p1, q1, p2, q2)
     l3.set_color(PINK)
     self.wait()
     self.play(
         ShowCreation(c1), ApplyMethod(l1.set_color, YELLOW),
         ShowCreation(c2), ApplyMethod(l2.set_color, YELLOW),
     )
     self.play(
         ReplacementTransform(l1.numer.deepcopy(), l3.numer),
         ReplacementTransform(l1.line.deepcopy(), l3.line),
         ReplacementTransform(l1.denom.deepcopy(), l3.denom),
         ReplacementTransform(l2.numer.deepcopy(), l3.numer),
         ReplacementTransform(l2.line.deepcopy(), l3.line),
         ReplacementTransform(l2.denom.deepcopy(), l3.denom),
         ReplacementTransform(c1.deepcopy(), c3),
         ReplacementTransform(c2.deepcopy(), c3),
     )
     self.wait()
     self.play(FadeOut(VGroup(c1, c2, c3, l1, l2, l3)))
Пример #17
0
 def __init__(self, mobject, color=YELLOW, width=10, opacity=None, scale_factor=1, run_time=1, highlight=1, func=None, rate_func=linear, pause_ratio=4./5, f_color=None, f_width=None, f_opacity=None, lag_ratio=1, copy=False, fadeout=None,offset=4, ratio=[0.95, 0.05], name="mobject", **kwargs):
     #for each in ["zrate_func", "scale_factor", "color", "stroke_opacity", "width"]:
     #    try:
     #        if locals()[each]:
     #            kwargs[each] = locals()[each]
     #    except:
     #        pass
     #kwargs = merge_config_kwargs(self, kwargs,self.CONFIG)
     if copy:
         mobject=mobject.copy()
     if isinstance(color, (int, float)):
         if color < 0:
             run_time = -color
             color = None
     animations = AGroup()
     if f_color is not None or f_width is not None or f_opacity is not None:
         animations.add(
             ApplyMethod(mobject.set_stroke, f_color,f_width, f_opacity,  rate_func=funz(step,0.05),run_time=run_time*ratio[1]))
             
         run_time = run_time*ratio[0]
     elif (copy and fadeout is None) or fadeout:
         animations.add(FadeOut(mobject,run_time=0.001))
     if highlight:
         kws=dict()
         if color is not None:
             kws['color']=color
         if width is not None:
             kws['width']=width
         if opacity is not None:
             kws['opacity']=opacity
         animations.add_to_back(Highlight(
                 mobject,scale_factor=scale_factor, run_time=run_time,**kws))
     else:
         animations.add_to_back(
             ApplyMethod(mobject.set_stroke, color, width, opacity, rate_func=funz(linear_pulse,0.05,0.9), run_time=run_time))
             #Transform(mobject,mobject.copy().set_stroke(color, width, opacity), rate_func=funz(linear_pulse,0.05,0.9), run_time=run_time))
             #ShowCreation(mobject.copy().set_stroke(color, width, opacity), rate_func=funz(linear_pulse,0.05,0.9), run_time=run_time))
     super().__init__(*animations, **kwargs)
Пример #18
0
 def __init__(self, mobject, **kwargs):
     super().__init__(
         ShowCreation(mobject),
         FadeOut(mobject),
         **kwargs
     )
Пример #19
0
    def construct(self):
        self.phase = 0

        point_x, point_y = self.comp_point(0)

        self.make_axes()

        self.ellipse = VMobject(color=self.path_color)

        self.phi = TexMobject(r"\Delta \Phi = ").set_color(BLACK).shift(4 *
                                                                        RIGHT +
                                                                        2 * UP)
        self.phi_0 = TexMobject("0").set_color(BLACK).next_to(self.phi, RIGHT)
        self.phi_pi_2 = TexMobject(r"\frac{\pi}{2}").set_color(BLACK).next_to(
            self.phi, RIGHT).shift(0.06 * DOWN)
        self.phi_3_pi_4 = TexMobject(r"\frac{3 \pi}{4}").set_color(
            BLACK).next_to(self.phi, RIGHT)

        self.x_vector = Vector(point_x * RIGHT,
                               color=self.axes_vector_color,
                               **self.vector_args)
        self.y_vector = Vector(point_y * UP,
                               color=self.axes_vector_color,
                               **self.vector_args)

        self.xy_vector = Vector(point_x * RIGHT + point_y * UP,
                                color=self.xy_vector_color,
                                **self.vector_args)

        update_group = VGroup(
            self.ellipse,
            self.xy_vector,
            self.x_vector,
            self.y_vector,
        )

        self.wait(1.6)
        self.add(self.ellipse)

        self.play(FadeIn(self.x_vector))
        # self.wait(1)
        self.play(FadeIn(self.y_vector))
        self.wait(4)
        self.play(FadeIn(self.xy_vector))
        self.play(UpdateFromAlphaFunc(update_group,
                                      self.do_vectors_and_ellipse_period),
                  run_time=self.period,
                  rate_func=linear)
        self.play(
            UpdateFromAlphaFunc(update_group,
                                self.do_vectors_only_period,
                                run_time=self.period,
                                rate_func=linear))
        self.play(
            AnimationGroup(UpdateFromAlphaFunc(update_group,
                                               self.do_vectors_only_period,
                                               run_time=self.period,
                                               rate_func=linear),
                           AnimationGroup(FadeIn(self.phi),
                                          FadeIn(self.phi_0)),
                           lag_ratio=0.7))
        self.play(
            UpdateFromAlphaFunc(update_group,
                                self.do_vectors_only_period,
                                run_time=self.period,
                                rate_func=linear))

        self.x_vector.set_color(BLACK)
        self.play(UpdateFromAlphaFunc(update_group,
                                      self.do_90_phase_shift,
                                      rate_func=linear),
                  FadeOut(self.ellipse),
                  FadeOut(self.phi_0),
                  FadeIn(self.phi_pi_2),
                  run_time=self.period / 4)

        self.phase = np.pi / 2
        self.ellipse.set_points([])
        self.x_vector.set_color(self.axes_vector_color)

        self.play(UpdateFromAlphaFunc(update_group,
                                      self.do_vectors_and_ellipse_period),
                  run_time=self.period,
                  rate_func=linear)
        for _ in range(3):
            self.play(UpdateFromAlphaFunc(update_group,
                                          self.do_vectors_only_period),
                      run_time=self.period,
                      rate_func=linear)

        self.x_vector.set_color(BLACK)
        self.play(UpdateFromAlphaFunc(update_group,
                                      self.do_45_phase_shift,
                                      rate_func=linear),
                  FadeOut(self.ellipse),
                  FadeOut(self.phi_pi_2),
                  FadeIn(self.phi_3_pi_4),
                  run_time=self.period / 8)

        self.phase = 3 * np.pi / 4
        self.ellipse.set_points([])
        self.x_vector.set_color(self.axes_vector_color)

        self.play(UpdateFromAlphaFunc(update_group,
                                      self.do_vectors_and_ellipse_period),
                  run_time=self.period,
                  rate_func=linear)

        self.play(
            AnimationGroup(UpdateFromAlphaFunc(
                update_group,
                self.do_vectors_only_period_hide,
                rate_func=linear,
                run_time=self.period),
                           AnimationGroup(FadeOut(self.phi_3_pi_4),
                                          FadeOut(self.phi)),
                           lag_ratio=0.7))
        self.play(FadeOut(self.axes), FadeOut(self.axes_labels))
        self.wait()
Пример #20
0
 def reset_everything(self):
     self.play(FadeOut(VGroup(*self.mobjects), lag_ratio=0))
     self.wait()
Пример #21
0
 def construct_infinite_sum(self):
     for n in range(1, 11):
         # Get highlighted terms
         highlighted_terms = self.get_highlighted_terms(n)
         # Update highlight rectangles
         if n == 1:
             rects = self.get_highlight_rectangles(1)
             self.play(ShowCreation(rects), lag_ratio=0.2)
             self.wait()
         else:
             new_rects = self.get_highlight_rectangles(n)
             self.play(Transform(rects, new_rects))
             if n <= 4:
                 self.wait()
         # Show the detailed construction of the first four terms
         if n <= 4:
             # Make copies of the elements that are going to be moved
             highlighted_terms_copy = self.get_highlighted_terms(
                 n).deepcopy()
             times_symbols_copy = self.get_times_symbols().deepcopy()
             cdots_copy = self.get_cdots_symbol().deepcopy()
             # Move highlighted terms into position
             arranged_terms_list = []
             for i in range(4):
                 arranged_terms_list.append(highlighted_terms_copy[i])
                 arranged_terms_list.append(times_symbols_copy[i])
             arranged_terms_list.append(cdots_copy)
             arranged_terms = VGroup(*arranged_terms_list)
             arranged_terms.arrange_submobjects(RIGHT, buff=0.2)
             arranged_terms.next_to(self.sum_tex,
                                    UP,
                                    aligned_edge=RIGHT,
                                    buff=0.5)
             # Move highlighted terms into position
             anims_list = []
             for i in range(4):
                 anims_list.append(
                     ReplacementTransform(
                         self.get_highlighted_terms(n)[i].deepcopy(),
                         arranged_terms[2 * i],
                         lag_ratio=0,
                         run_time=2))
                 anims_list.append(
                     ReplacementTransform(
                         self.get_times_symbols()[i].deepcopy(),
                         arranged_terms[2 * i + 1],
                         lag_ratio=0,
                         run_time=2))
             anims_list.append(
                 ReplacementTransform(self.get_cdots_symbol().deepcopy(),
                                      arranged_terms[-1],
                                      lag_ratio=0,
                                      run_time=2))
             self.play(AnimationGroup(*anims_list))
             self.wait()
             if n == 1:
                 self.play(Transform(arranged_terms, self.get_sum_term(n)))
             else:
                 self.play(
                     Transform(arranged_terms, self.get_sum_term(n)),
                     Write(self.get_plus_symbol(n - 1)),
                 )
             self.wait()
         # And show the result for the remaining terms
         else:
             self.play(
                 Transform(
                     VGroup(
                         self.get_highlighted_terms(n).deepcopy(),
                         self.get_times_symbols().deepcopy(),
                         self.get_cdots_symbol().deepcopy(),
                     ),
                     self.get_sum_term(n),
                     lag_ratio=0,
                 ),
                 Write(self.get_plus_symbol(n - 1)),
             )
     # Add \cdots to the end.
     self.wait()
     self.play(FadeOut(rects), Write(self.sum_tex[-1][-4:]))
     self.wait()