Esempio n. 1
0
    def add_lines(self, left, right):
        line_kwargs = {
            "color": BLUE,
            "stroke_width": 2,
        }
        left_rows = [VGroup(*row) for row in left.get_mob_matrix()]
        h_lines = VGroup()
        for row in left_rows[:-1]:
            h_line = Line(row.get_left(), row.get_right(), **line_kwargs)
            h_line.next_to(row, DOWN, buff=left.v_buff / 2.)
            h_lines.add(h_line)

        right_cols = [
            VGroup(*col) for col in np.transpose(right.get_mob_matrix())
        ]
        v_lines = VGroup()
        for col in right_cols[:-1]:
            v_line = Line(col.get_top(), col.get_bottom(), **line_kwargs)
            v_line.next_to(col, RIGHT, buff=right.h_buff / 2.)
            v_lines.add(v_line)

        self.play(ShowCreation(h_lines))
        self.play(ShowCreation(v_lines))
        self.wait()
        self.show_frame()
Esempio n. 2
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)
Esempio n. 3
0
    def vector_to_coords(self, vector, integer_labels=True, clean_up=True):
        """
        This method displays vector as a Vector() based vector, and then shows 
        the corresponding lines that make up the x and y components of the vector. 
        Then, a column matrix (henceforth called the label) is created near the 
        head of the Vector.

        Parameters
        ----------
        vector Union(np.ndarray, list, tuple)
            The vector to show.
        
        integer_label (bool=True)
            Whether or not to round the value displayed.
            in the vector's label to the nearest integer
        
        clean_up (bool=True)
            Whether or not to remove whatever
            this method did after it's done.

        """
        starting_mobjects = list(self.mobjects)
        show_creation = False
        if isinstance(vector, Arrow):
            arrow = vector
            vector = arrow.get_end()[:2]
        else:
            arrow = Vector(vector)
            show_creation = True
        array = vector_coordinate_label(arrow, integer_labels=integer_labels)
        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()
        x_coord_start = self.position_x_coordinate(x_coord.copy(), x_line,
                                                   vector)
        y_coord_start = self.position_y_coordinate(y_coord.copy(), y_line,
                                                   vector)
        brackets = array.get_brackets()

        if show_creation:
            self.play(ShowCreation(arrow))
        self.play(ShowCreation(x_line), Write(x_coord_start), run_time=1)
        self.play(ShowCreation(y_line), Write(y_coord_start), run_time=1)
        self.wait()
        self.play(
            Transform(x_coord_start, x_coord, lag_ratio=0),
            Transform(y_coord_start, y_coord, lag_ratio=0),
            Write(brackets, run_time=1),
        )
        self.wait()

        self.remove(x_coord_start, y_coord_start, brackets)
        self.add(array)
        if clean_up:
            self.clear()
            self.add(*starting_mobjects)
        return array, x_line, y_line
Esempio n. 4
0
    def construct(self):
        axes = ThreeDAxes()
        circle = Circle()

        self.set_camera_orientation(phi=0 * DEGREES)

        self.play(ShowCreation(circle), ShowCreation(axes))
        self.wait()
Esempio n. 5
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)
Esempio n. 6
0
    def vector_to_coords(self, vector, integer_labels=True, clean_up=True):
        starting_mobjects = list(self.mobjects)
        show_creation = False
        if isinstance(vector, Arrow):
            arrow = vector
            vector = arrow.get_end()[:2]
        else:
            arrow = Vector(vector)
            show_creation = True
        array = vector_coordinate_label(arrow, integer_labels=integer_labels)
        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()
        x_coord_start = self.position_x_coordinate(
            x_coord.copy(), x_line, vector
        )
        y_coord_start = self.position_y_coordinate(
            y_coord.copy(), y_line, vector
        )
        brackets = array.get_brackets()

        if show_creation:
            self.play(ShowCreation(arrow))
        self.play(
            ShowCreation(x_line),
            Write(x_coord_start),
            run_time=1
        )
        self.play(
            ShowCreation(y_line),
            Write(y_coord_start),
            run_time=1
        )
        self.wait()
        self.play(
            Transform(x_coord_start, x_coord, lag_ratio=0),
            Transform(y_coord_start, y_coord, lag_ratio=0),
            Write(brackets, run_time=1),
        )
        self.wait()

        self.remove(x_coord_start, y_coord_start, brackets)
        self.add(array)
        if clean_up:
            self.clear()
            self.add(*starting_mobjects)
        return array, x_line, y_line
Esempio n. 7
0
    def construct(self):
        circle = Circle()
        text = TexMobject(r"\pi")

        self.play(ShowCreation(circle))
        self.play(circle.become, text)
        self.wait()
Esempio n. 8
0
    def construct(self):
        # Set objets
        theta = ValueTracker(self.theta)
        line_1 = Line(ORIGIN, RIGHT * self.lines_size, color=self.line_1_color)
        line_2 = Line(ORIGIN, RIGHT * self.lines_size, color=self.line_2_color)

        line_2.rotate(theta.get_value(), about_point=ORIGIN)
        line_2.add_updater(lambda m: m.set_angle(theta.get_value()))

        angle = Arc(radius=self.radius,
                    start_angle=line_1.get_angle(),
                    angle=line_2.get_angle(),
                    color=self.radius_color)

        # Show the objects

        self.play(*[ShowCreation(obj) for obj in [line_1, line_2, angle]])

        # Set update function to angle

        angle.add_updater(lambda m: m.become(
            Arc(radius=self.radius,
                start_angle=line_1.get_angle(),
                angle=line_2.get_angle(),
                color=self.radius_color)))
        # Remember to add the objects again to the screen
        # when you add the add_updater method.
        self.add(angle)

        self.play(theta.increment_value, self.increment_theta)
        # self.play(theta.set_value,self.final_theta)

        self.wait()
Esempio n. 9
0
    def add_T_label(self,
                    x_val,
                    side=RIGHT,
                    label=None,
                    color=WHITE,
                    animated=False,
                    **kwargs):
        triangle = RegularPolygon(n=3, start_angle=np.pi / 2)
        triangle.set_height(MED_SMALL_BUFF)
        triangle.move_to(self.coords_to_point(x_val, 0), UP)
        triangle.set_fill(color, 1)
        triangle.set_stroke(width=0)
        if label is None:
            T_label = TexMobject(self.variable_point_label, fill_color=color)
        else:
            T_label = TexMobject(label, fill_color=color)

        T_label.next_to(triangle, DOWN)
        v_line = self.get_vertical_line_to_graph(x_val,
                                                 self.v_graph,
                                                 color=YELLOW)

        if animated:
            self.play(DrawBorderThenFill(triangle), ShowCreation(v_line),
                      Write(T_label, run_time=1), **kwargs)

        if np.all(side == LEFT):
            self.left_T_label_group = VGroup(T_label, triangle)
            self.left_v_line = v_line
            self.add(self.left_T_label_group, self.left_v_line)
        elif np.all(side == RIGHT):
            self.right_T_label_group = VGroup(T_label, triangle)
            self.right_v_line = v_line
            self.add(self.right_T_label_group, self.right_v_line)
Esempio n. 10
0
    def construct(self):
        N = 15

        self.setup_axes(animate=True)

        func_graph = self.get_graph(np.cos, color=BLUE)
        approx_graphs = [
            self.get_graph(lambda x: self.taylor(x, n), color=GREEN)
            for n in range(0, N)
        ]

        term_nums = [
            TexMobject(f"n = {n}", aligned_edge=TOP) for n in range(0, N)
        ]
        term = VectorizedPoint()
        term.to_edge(BOTTOM, buff=SMALL_BUFF)

        for term_num in term_nums:
            term_num.to_edge(BOTTOM, buff=SMALL_BUFF)

        approx_graph = VectorizedPoint(self.input_to_graph_point(
            0, func_graph))

        self.play(ShowCreation(func_graph))
        for graph, term_num in zip(approx_graphs, term_nums):
            self.play(Transform(approx_graph, graph, run_time=1),
                      Transform(term, term_num))
            self.wait()

        self.wait()
    def add_T_label(self, x_val, side=RIGHT, label=None, color=WHITE, animated=False, **kwargs):
        """
        This method adds to the Scene:
            -- a Vertical line from the x-axis to the corresponding point on the graph/curve.
            -- a small vertical Triangle whose top point lies on the base of the vertical line
            -- a TexMobject to be a label for the Line and Triangle, at the bottom of the Triangle.
        The scene needs to have the graph have the identifier/variable name self.v_graph.

        Parameters
        ----------
        x_val (Union[float, int])
            The x value at which the secant enters, and intersects
            the graph for the first time.
        
        side (np.ndarray())
        
        label (str)
            The label to give the vertline and triangle
        
        color (str)
            The hex color of the label.
        
        animated (bool=False)
            Whether or not to animate the addition of the T_label
        
        **kwargs
            Any valid keyword argument of a self.play call.
        """
        triangle = RegularPolygon(n=3, start_angle=np.pi / 2)
        triangle.set_height(MED_SMALL_BUFF)
        triangle.move_to(self.coords_to_point(x_val, 0), UP)
        triangle.set_fill(color, 1)
        triangle.set_stroke(width=0)
        if label is None:
            T_label = TexMobject(self.variable_point_label, fill_color=color)
        else:
            T_label = TexMobject(label, fill_color=color)

        T_label.next_to(triangle, DOWN)
        v_line = self.get_vertical_line_to_graph(
            x_val, self.v_graph,
            color=YELLOW
        )

        if animated:
            self.play(
                DrawBorderThenFill(triangle),
                ShowCreation(v_line),
                Write(T_label, run_time=1),
                **kwargs
            )

        if np.all(side == LEFT):
            self.left_T_label_group = VGroup(T_label, triangle)
            self.left_v_line = v_line
            self.add(self.left_T_label_group, self.left_v_line)
        elif np.all(side == RIGHT):
            self.right_T_label_group = VGroup(T_label, triangle)
            self.right_v_line = v_line
            self.add(self.right_T_label_group, self.right_v_line)
Esempio n. 12
0
    def construct(self):
        number_line = NumberLine(x_min=-2, x_max=2)
        triangle = RegularPolygon(3, start_angle=-PI / 2) \
            .scale(0.2) \
            .next_to(number_line.get_left(), UP, buff=SMALL_BUFF)
        numbers = VGroup(
            *[TextMobject("%s" % i) \
                  .next_to(number_line.get_tick(i - 2), DOWN) for i in range(1, 5)]
        )

        self.add(number_line)
        self.play(ShowCreation(triangle))
        self.wait(0.3)

        self.play(
            ApplyMethod(triangle.shift,
                        RIGHT * 4,
                        rate_func=linear,
                        run_time=4),
            *[
                AnimationGroup(Animation(Mobject(), run_time=i + 1),
                               Write(numbers[i]),
                               lag_ratio=1) for i in range(4)
            ],
        )

        self.wait()
Esempio n. 13
0
    def construct(self):
        a = 1
        c = FunctionGraph(lambda x: 2 * np.exp(-2 * (x - a * 1)**2))
        axes = Axes(y_min=-3, y_max=3)

        def update_curve(c, dt):
            alpha = interpolate(1, 4, dt)
            c_c = FunctionGraph(lambda x: 2 * np.exp(-2 * (x - a * alpha)**2))
            c.become(c_c)

        self.play(ShowCreation(axes), ShowCreation(c))
        self.wait()
        self.play(UpdateFromAlphaFunc(c, update_curve),
                  rate_func=there_and_back,
                  run_time=4)
        self.wait()
Esempio n. 14
0
    def construct(self):
        def update_curve(c, dt):
            rate = self.rate * dt
            other_mob = FunctionGraph(
                lambda x: self.amp * np.sin((x - (self.t_offset + rate))),
                x_min=0,
                x_max=self.x_max).shift(LEFT * self.x_min)
            c.become(other_mob)
            self.t_offset += rate

        c = FunctionGraph(lambda x: self.amp * np.sin((x)),
                          x_min=0,
                          x_max=self.x_max).shift(LEFT * self.x_min)

        self.play(ShowCreation(c))

        print("coord_x_in:", c.points[0][1])

        c.add_updater(update_curve)
        self.add(c)

        # The animation begins
        self.wait(4)

        c.remove_updater(update_curve)
        self.wait()

        print("coord_x_end:", c.points[0][1])
Esempio n. 15
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)
Esempio n. 16
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
     )
Esempio n. 17
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
     )
Esempio n. 18
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)))
Esempio n. 19
0
 def __init__(self, mobject, **kwargs):
     assert (isinstance(mobject, Mobject))
     digest_config(self, kwargs)
     if not hasattr(mobject, "lines"):
         self.generate_lines(mobject)
     if not hasattr(mobject, "rectangle"):
         self.generate_rec(mobject)
     mobject.rectangle.save_state()
     mobject.rectangle.set_width(0, stretch=True, about_edge=LEFT)
     AnimationGroup.__init__(self, ShowCreation(mobject.lines, lag_ratio=0),
                             Restore(mobject.rectangle), **kwargs)
Esempio n. 20
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()
Esempio n. 21
0
    def construct(self):
        self.setup_axes(animate=False)
        func_graph1 = self.get_graph(self.func_to_graph1, color=RED)
        func_graph2 = self.get_graph(self.func_to_graph2, color=WHITE)
        func_graph3 = self.get_graph(self.func_to_graph3, color=BLUE)
        func_graph4 = self.get_graph(self.func_to_graph4, color=PINK)

        label1 = self.get_graph_label(func_graph1, label="\\sin(x)")
        label2 = self.get_graph_label(func_graph2, label="\\sin(2x)")
        label3 = self.get_graph_label(func_graph3,
                                      label="\\sin(.5x+2)",
                                      direction=UP)
        label4 = self.get_graph_label(func_graph4,
                                      label="\\sin(x)+\\sin(2x) + sin(.5x+2)",
                                      x_val=-2,
                                      direction=15 * DOWN)

        self.play(ShowCreation(func_graph1), ShowCreation(func_graph2),
                  ShowCreation(func_graph3))
        self.play(ShowCreation(label1), ShowCreation(label2),
                  ShowCreation(label3))

        self.play(Transform(func_graph1, func_graph4), FadeOut(func_graph2),
                  FadeOut(label1), FadeOut(label2), FadeOut(func_graph3),
                  FadeOut(label3))
Esempio n. 22
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()
Esempio n. 23
0
 def show_reflines(self):
     reflines = VGroup(*[rhombus.get_refline() for rhombus in self.rhombi])
     eqtri_text = self.bg_texts[1]
     self.play(Write(eqtri_text),
               ShowCreation(reflines),
               Animation(self.rhombi),
               run_time=3)
     self.play(
         Indicate(VGroup(self.rhombi, reflines), scale_factor=1.05),
         run_time=2,
     )
     self.wait()
     self.reflines = reflines
Esempio n. 24
0
    def construct(self):
        circle = Circle(color=YELLOW).scale(self.radius)

        points = []
        lines = []
        for point in range(self.points):
            start_angle = (point / self.points) * 2 * np.pi
            start_point = (RIGHT * np.cos(start_angle) + UP * np.sin(start_angle)) * self.radius
            points.append(start_point)

            stop_angle = (point + point * self.step) / self.points * 2 * np.pi
            stop_point = (RIGHT * np.cos(stop_angle) + UP * np.sin(stop_angle)) * self.radius
            lines.append(Line(start_point, stop_point, **self.line_config))

        self.play(ShowCreation(circle))
        self.wait()

        points_group = VGroup(*[Dot(point, **self.dot_config) for point in points])
        lines_group = VGroup(*lines)

        # self.play(ShowCreation(points_group), run_time=2)
        self.play(ShowCreation(lines_group), run_time=10, rate_func=linear)
        self.wait()
Esempio n. 25
0
    def construct(self):
        plane = NumberPlane(**self.plane_kwargs)
        plane.add(plane.get_axis_labels())
        self.add(plane)

        self.field = VGroup(*[
            self.calc_field(x * RIGHT + y * UP) for x in np.arange(-9, 9, 1)
            for y in np.arange(-5, 5, 1)
        ])

        source_charge = self.Positron().move_to(self.point_charge_loc)
        self.play(FadeIn(source_charge))
        self.play(ShowCreation(self.field))
        self.moving_charge()
Esempio n. 26
0
 def add_axes(self, animate=False, color=WHITE, **kwargs):
     """
     Adds a pair of Axes to the Scene.
     Parameters
     ----------
     animate (bool=False)
         Whether or not to animate the addition of the axes through ShowCreation.
     color (str)
         The color of the axes. Defaults to WHITE.
     """
     axes = Axes(color=color, tick_frequency=1)
     if animate:
         self.play(ShowCreation(axes))
     self.add(axes)
     return axes
Esempio n. 27
0
 def show_rhombi(self):
     self.wait()
     rhombi = VGroup(
         *[RhombusType() for RhombusType in (RRhombus, HRhombus, LRhombus)])
     rhombi.arrange_submobjects(RIGHT, aligned_edge=DOWN, buff=1)
     rhombi.to_edge(RIGHT, buff=1)
     rhombi.to_edge(UP)
     hexagon_text, rhombi_text = self.bg_texts[0]
     self.play(Write(hexagon_text), run_time=1)
     self.wait()
     self.play(ShowCreation(rhombi, submobject_mode="all_at_once"),
               Write(rhombi_text),
               run_time=1)
     self.wait()
     self.rhombi = rhombi
Esempio n. 28
0
 def ask_about_how_to_prove(self):
     claim_text = self.q_texts[0]
     self.wait()
     self.play(self.q_texts.shift, DOWN, run_time=1)
     claim_rect = SurroundingRectangle(VGroup(claim_text,
                                              self.how_to_prove_text),
                                       stroke_color=YELLOW,
                                       buff=0.3)
     self.play(
         Write(self.how_to_prove_text),
         ShowCreation(claim_rect),
         run_time=1,
     )
     self.wait()
     self.claim_rect = claim_rect
Esempio n. 29
0
    def create(self, *mobject_or_chars, pre_time=0.5, post_time=1, **kwargs):

        if not isinstance(mobject_or_chars, (list, tuple, ndarray)):
            mobject_or_chars = [mobject_or_chars]
        mobject = Group(*[MobjectOrChars(each) for each in mobject_or_chars])
        keys = ["shift"]
        [
            exec(
                "mobject." + key + "([" +
                ','.join(str(x) for x in kwargs.get(key)) + "])",
                {"mobject": mobject}) for key in keys if key in kwargs
        ]
        self.wait(pre_time)
        self.play(ShowCreation(mobject), **kwargs)
        self.wait(post_time)
        return self
Esempio n. 30
0
    def construct(self):
        self.setup_axes(animate=False)
        graph1=self.get_graph(self.func_to_graph1, color=RED)
        graph2=self.get_graph(self.func_to_graph2, color=WHITE)
        graph3=self.get_graph(self.func_to_graph3, color=BLUE)
        graph4=self.get_graph(self.func_to_graph4, color=PINK)
        graph5=self.get_graph(self.func_to_graph5, color=PURPLE)
        
        label1 = self.get_graph_label(graph1, label = "\\sin(\\pi x)", direction= 2*DOWN)
        label2 = self.get_graph_label(graph2, label = "\\frac{1}{3}\\sin(3 \\pi x)",direction= 2*DOWN)
        label3 = self.get_graph_label(graph3, label = "\\frac{1}{5}\\sin(5 \\pi x)",direction= 2*DOWN)
        label4 = self.get_graph_label(graph4,label = "\\frac{1}{7}\\sin(7 \\pi x)",direction= 2*DOWN)

        self.play(ShowCreation(graph1), ShowCreation(label1))
        self.play(ShowCreation(graph2), ShowCreation(label2), FadeOut(label1))
        self.play(ShowCreation(graph3), ShowCreation(label3), FadeOut(label2))
        self.play(ShowCreation(graph4), ShowCreation(label4), FadeOut(label3))
        self.play(Transform(graph1, graph5),FadeOut(label4), FadeOut(graph2),FadeOut(graph3),FadeOut(graph4))