当前位置: 首页>>代码示例>>Python>>正文


Python TexMobject.copy方法代码示例

本文整理汇总了Python中mobject.tex_mobject.TexMobject.copy方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.copy方法的具体用法?Python TexMobject.copy怎么用?Python TexMobject.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mobject.tex_mobject.TexMobject的用法示例。


在下文中一共展示了TexMobject.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def construct(self):
        two_dot = TexMobject("2\\cdot")
        equals = TexMobject("=")
        self.add_axes()
        v = self.add_vector([3, 1])
        v_coords, vx_line, vy_line = self.vector_to_coords(v, cleanup = False)
        self.play(ApplyMethod(v_coords.to_edge, UP))
        two_dot.next_to(v_coords, LEFT)
        equals.next_to(v_coords, RIGHT)
        two_v = self.add_vector([6, 2], animate = False)
        self.remove(two_v)
        self.play(
            Transform(v.copy(), two_v), 
            Write(two_dot, run_time = 1)
        )
        two_v_coords, two_v_x_line, two_v_y_line = self.vector_to_coords(
            two_v, cleanup = False
        )
        self.play(
            ApplyMethod(two_v_coords.next_to, equals, RIGHT),
            Write(equals, run_time = 1)
        )
        self.dither(2)

        x, y = v_coords.get_mob_matrix().flatten()
        two_v_elems = two_v_coords.get_mob_matrix().flatten()
        x_sym, y_sym = map(TexMobject, ["x", "y"])
        two_x_sym, two_y_sym = map(TexMobject, ["2x", "2y"])
        VMobject(x_sym, two_x_sym).highlight(X_COLOR)
        VMobject(y_sym, two_y_sym).highlight(Y_COLOR)
        syms = [x_sym, y_sym, two_x_sym, two_y_sym]
        VMobject(*syms).scale(VECTOR_LABEL_SCALE_VAL)
        for sym, num in zip(syms, [x, y] + list(two_v_elems)):
            sym.move_to(num)
        self.play(
            Transform(x, x_sym),
            Transform(y, y_sym),
            FadeOut(VMobject(*two_v_elems))
        )
        self.dither()
        self.play(
            Transform(
                VMobject(two_dot.copy(), x.copy()),
                two_x_sym
            ),
            Transform(
                VMobject(two_dot.copy(), y.copy() ),
                two_y_sym
            )
        )
        self.dither(2)
开发者ID:namkam5,项目名称:manim,代码行数:53,代码来源:chapter1.py

示例2: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def construct(self):
        v_mob = TexMobject(get_vect_tex("v"))
        v_mob.highlight(V_COLOR)

        matrix = Matrix([self.vect_coords])
        vector = Matrix(self.vect_coords)
        matrix.highlight_columns(X_COLOR, Y_COLOR)
        vector.highlight_columns(YELLOW)
        _input = Matrix(["x", "y"])
        _input.get_entries().gradient_highlight(X_COLOR, Y_COLOR)
        left_input, right_input = [_input.copy() for x in range(2)]
        dot, equals = map(TexMobject, ["\\cdot", "="])
        equation = Group(
            vector, dot, left_input, equals,
            matrix, right_input
        )
        equation.arrange_submobjects()
        left_brace = Brace(Group(vector, left_input))
        right_brace = Brace(matrix, UP)
        left_words = left_brace.get_text("Dot product")
        right_words = right_brace.get_text("Transform")
        right_words.scale_to_fit_width(right_brace.get_width())

        right_v_brace = Brace(right_input, UP)
        right_v_mob = v_mob.copy()
        right_v_brace.put_at_tip(right_v_mob)
        right_input.add(right_v_brace, right_v_mob)
        left_v_brace = Brace(left_input, UP)
        left_v_mob = v_mob.copy()
        left_v_brace.put_at_tip(left_v_mob)
        left_input.add(left_v_brace, left_v_mob)        


        self.add(matrix, right_input)
        self.play(
            GrowFromCenter(right_brace),
            Write(right_words, run_time = 1)
        )
        self.dither()
        self.play(
            Write(equals),
            Write(dot),
            Transform(matrix.copy(), vector),
            Transform(right_input.copy(), left_input)
        )
        self.play(
            GrowFromCenter(left_brace),
            Write(left_words, run_time = 1)
        )
        self.dither()
开发者ID:scottopell,项目名称:manim,代码行数:52,代码来源:chapter8p2.py

示例3: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
 def construct(self):
     l_m1, l_m2, eq, r_m2, r_m1 = TexMobject([
         "M_1",  "M_2", "=", "M_2", "M_1"
     ]).scale(1.5).split()
     VMobject(l_m1, r_m1).highlight(YELLOW)
     VMobject(l_m2, r_m2).highlight(PINK)
     q_marks = TextMobject("???")
     q_marks.highlight(TEAL)
     q_marks.next_to(eq, UP)
     neq = TexMobject("\\neq")
     neq.move_to(eq)
     
     self.play(*map(Write, [l_m1, l_m2, eq]))
     self.play(
         Transform(l_m1.copy(), r_m1),
         Transform(l_m2.copy(), r_m2),
         path_arc = -np.pi,
         run_time = 2
     )
     self.play(Write(q_marks))
     self.dither()
     self.play(Transform(
         VMobject(eq, q_marks),
         VMobject(neq),
         submobject_mode = "lagged_start"
     ))
     self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:29,代码来源:chapter4.py

示例4: show_snells

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def show_snells(self, index, frame):
        left_text, right_text = [
            "\\dfrac{\\sin(\\theta_%d)}{\\phantom{\\sqrt{y_1}}}"%x
            for x in index, index+1
        ]
        left, equals, right = TexMobject(
            [left_text, "=", right_text]
        ).split()
        vs = []
        sqrt_ys = []
        for x, numerator in [(index, left), (index+1, right)]:
            v, sqrt_y = [
                TexMobject(
                    text, size = "\\Large"
                ).next_to(numerator, DOWN)
                for text in "v_%d"%x, "\\sqrt{y_%d}"%x
            ]
            vs.append(v)
            sqrt_ys.append(sqrt_y)
        start, end = [
            Mobject(
                left.copy(), mobs[0], equals.copy(), right.copy(), mobs[1]
            ).replace(frame)
            for mobs in vs, sqrt_ys
        ]

        self.add(start)
        self.dither(2)
        self.play(Transform(
            start, end, 
            path_func = counterclockwise_path()
        ))
        self.dither(2)
        self.remove(start, end)
开发者ID:GodotMisogi,项目名称:manim,代码行数:36,代码来源:graveyard.py

示例5: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def construct(self):
        self.setup()
        matrix = Matrix(np.array(self.transposed_matrix).transpose())
        matrix.highlight_columns(X_COLOR, Y_COLOR)
        matrix.next_to(ORIGIN, LEFT).to_edge(UP)
        matrix_background = BackgroundRectangle(matrix)
        self.play(ShowCreation(matrix_background), Write(matrix))
        if self.show_square:
            self.add_unit_square(animate = True)
        self.add_foreground_mobject(matrix_background, matrix)
        self.dither()
        self.apply_transposed_matrix([self.transposed_matrix[0], [0, 1]])
        self.apply_transposed_matrix([[1, 0], self.transposed_matrix[1]])
        self.dither()
        if self.show_square:


            bottom_brace = Brace(self.i_hat, DOWN)
            right_brace = Brace(self.square, RIGHT)
            width = TexMobject(str(self.transposed_matrix[0][0]))
            height = TexMobject(str(self.transposed_matrix[1][1]))
            width.next_to(bottom_brace, DOWN)
            height.next_to(right_brace, RIGHT)
            for mob in bottom_brace, width, right_brace, height:
                mob.add_background_rectangle()
                self.play(Write(mob, run_time = 0.5))
            self.dither()

            width_target, height_target = width.copy(), height.copy()
            det = np.linalg.det(self.transposed_matrix)
            times, eq_det = map(TexMobject, ["\\times", "=%d"%det])
            words = TextMobject("New area $=$")
            equation = VMobject(
                words, width_target, times, height_target, eq_det
            )
            equation.arrange_submobjects(RIGHT, buff = 0.2)
            equation.next_to(self.square, UP, aligned_edge = LEFT)
            equation.shift(0.5*RIGHT)
            background_rect = BackgroundRectangle(equation)

            self.play(
                ShowCreation(background_rect),                
                Transform(width.copy(), width_target),
                Transform(height.copy(), height_target),
                *map(Write, [words, times, eq_det])
            )
            self.dither()
开发者ID:xhrwang,项目名称:manim,代码行数:49,代码来源:chapter5.py

示例6: rearrange

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def rearrange(self):
        sqrt_nudge = 0.2*LEFT        
        y, equals = self.y_equals.split()
        d, sin, squared, theta = self.y_expression.split()
        y_sqrt = TexMobject("\\sqrt{\\phantom{y}}")
        d_sqrt = y_sqrt.copy()
        y_sqrt.shift(y.get_center()+sqrt_nudge)
        d_sqrt.shift(d.get_center()+sqrt_nudge)

        self.play(
            ShimmerIn(y_sqrt),
            ShimmerIn(d_sqrt),
            ApplyMethod(squared.shift, 4*UP),
            ApplyMethod(theta.shift, 1.5* squared.get_width()*LEFT)
        )
        self.dither()
        y_sqrt.add(y)
        d_sqrt.add(d)
        sin.add(theta)

        sin_over = TexMobject("\\dfrac{\\phantom{\\sin(\\theta)}}{\\quad}")
        sin_over.next_to(sin, DOWN, 0.15)
        new_eq = equals.copy()
        new_eq.next_to(sin_over, LEFT)
        one_over = TexMobject("\\dfrac{1}{\\quad}")
        one_over.next_to(new_eq, LEFT)
        one_over.shift(
            (sin_over.get_bottom()[1]-one_over.get_bottom()[1])*UP
        )

        self.play(
            Transform(equals, new_eq),
            ShimmerIn(sin_over),
            ShimmerIn(one_over),
            ApplyMethod(
                d_sqrt.next_to, one_over, DOWN,
                path_func = path_along_arc(-np.pi)
            ),
            ApplyMethod(
                y_sqrt.next_to, sin_over, DOWN,
                path_func = path_along_arc(-np.pi)
            ),
            run_time = 2
        )
        self.dither()

        brace = Brace(d_sqrt, DOWN)
        constant = TextMobject("Constant")
        constant.next_to(brace, DOWN)

        self.play(
            GrowFromCenter(brace),
            ShimmerIn(constant)
        )
开发者ID:GodotMisogi,项目名称:manim,代码行数:56,代码来源:cycloid.py

示例7: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def construct(self):
        v = TexMobject(self.v_str)
        v.highlight(YELLOW)
        eq = TexMobject("=")
        coords = Matrix(["x", "y", "z"])
        eq2 = eq.copy()
        if self.post_transform:
            L, l_paren, r_paren = map(TexMobject, "L()")
            parens = VMobject(l_paren, r_paren)
            parens.scale(2)
            parens.stretch_to_fit_height(
                coords.get_height()
            )
            VMobject(L, l_paren, coords, r_paren).arrange_submobjects(buff = 0.1)
            coords.submobjects = [L, l_paren] + coords.submobjects + [r_paren]

        lin_comb = VMobject(*map(TexMobject, [
            "x", self.i_str, "+",
            "y", self.j_str, "+",
            "z", self.k_str,
        ]))
        lin_comb.arrange_submobjects(
            RIGHT, buff = 0.1, 
            aligned_edge = ORIGIN if self.post_transform else DOWN
        )
        lin_comb_parts = np.array(lin_comb.split())
        new_x, new_y, new_z = lin_comb_parts[[0, 3, 6]]
        i, j, k = lin_comb_parts[[1, 4, 7]]
        plusses = lin_comb_parts[[2, 5]]
        i.highlight(X_COLOR)
        j.highlight(Y_COLOR)
        k.highlight(Z_COLOR)

        everything = VMobject(v, eq, coords, eq2, lin_comb)
        everything.arrange_submobjects(buff = 0.2)
        everything.scale_to_fit_width(2*SPACE_WIDTH - 1)
        everything.to_edge(DOWN)
        if not self.post_transform:
            lin_comb.shift(0.35*UP)

        self.play(*map(Write, [v, eq, coords]))
        self.dither()
        self.play(
            Transform(
                coords.get_entries().copy(),
                VMobject(new_x, new_y, new_z),
                path_arc = -np.pi,
                submobject_mode = "lagged_start"
            ),
            Write(VMobject(*[eq2, i, j, k] + list(plusses))),
            run_time = 3
        )
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:55,代码来源:footnote.py

示例8: generate_sea_of_zeros

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
 def generate_sea_of_zeros(self):
     zero = TexMobject("0")
     self.sea_of_zeros = []
     for n in range(self.nrows):
         for a in range((self.nrows - n)/2 + 1):
             for k in (n + a + 1, -a -1):
                 self.coords.append((n, k))
                 mob = zero.copy()
                 mob.shift(self.coords_to_center(n, k))
                 self.coords_to_mobs[n][k] = mob
                 self.add(mob)
     return self
开发者ID:GodotMisogi,项目名称:manim,代码行数:14,代码来源:combinatorics.py

示例9: get_log_anim

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
 def get_log_anim(self, center):
     O_log_n = TexMobject(["O(", "\\log(n)", ")"])
     O_log_n.shift(center)
     log_n = O_log_n.split()[1]
     #super hacky
     g = log_n.split()[2]
     for mob in g.submobjects:
         mob.is_subpath = False 
         mob.set_fill(BLACK, 1.0)
         log_n.add(mob)
     g.submobjects = []
     #end hack
     top = TOP(2, None, "n", radius = 0.75)
     top.scale_to_fit_width(log_n.get_width())
     top.shift(log_n.get_center())
     new_O_log_n = O_log_n.copy()
     new_O_log_n.submobjects[1] = top
     return Transform(O_log_n, new_O_log_n)
开发者ID:PythonJedi,项目名称:manim,代码行数:20,代码来源:end.py

示例10: write_old_style_rules

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
 def write_old_style_rules(self):
     start = TexMobject("a^x a^y = a^{x+y}")
     end = TexMobject("\\log_a(xy) = \\log_a(x) + \\log_a(y)")
     start.shift(UP)
     end.shift(DOWN)
     a1, x1, a2, y1, eq1, a3, p1, x2, y2 = start.split()
     a4, x3, y3, eq2, a5, x4, p2, a6, y4 = np.array(end.split())[
         [3, 5, 6, 8, 12, 14, 16, 20, 22]
     ]
     start_copy = start.copy()
     self.play(Write(start_copy))
     self.dither()
     self.play(Transform(
         VMobject(a1, x1, a2, y1, eq1, a3, p1, x2, a3.copy(), y2),
         VMobject(a4, x3, a4.copy(), y3, eq2, a5, p2, x4, a6, y4)
     ))
     self.play(Write(end))
     self.clear()
     self.add(start_copy, end)
     self.dither()
     return start_copy, end
开发者ID:PythonJedi,项目名称:manim,代码行数:23,代码来源:triangle.py

示例11: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def construct(self):
        CycloidScene.construct(self)

        equation = TexMobject([
            "\\dfrac{\\sin(\\theta)}{\\sqrt{y}}",
            "= \\text{constant}"
        ])
        sin_sqrt, const = equation.split()
        new_eq = equation.copy()
        new_eq.to_edge(UP, buff = 1.3)
        cycloid_word = TextMobject("Cycloid")
        arrow = Arrow(2*UP, cycloid_word)
        arrow.reverse_points()
        q_mark = TextMobject("?")

        self.play(*map(ShimmerIn, equation.split()))
        self.dither()
        self.play(
            ApplyMethod(equation.shift, 2.2*UP),
            ShowCreation(arrow)
        )
        q_mark.next_to(sin_sqrt)
        self.play(ShimmerIn(cycloid_word))
        self.dither()
        self.grow_parts()
        self.draw_cycloid()
        self.dither()
        extra_terms = [const, arrow, cycloid_word]
        self.play(*[
            Transform(mob, q_mark)
            for mob in extra_terms
        ])
        self.remove(*extra_terms)
        self.roll_back()
        q_marks, arrows = self.get_q_marks_and_arrows(sin_sqrt)
        self.draw_cycloid(3, 
            ShowCreation(q_marks),
            ShowCreation(arrows)
        )
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:42,代码来源:cycloid.py

示例12: show_layer_variables

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def show_layer_variables(self):
        layer_top_pairs = zip(
            self.layer_tops[:self.num_variables], 
            self.layer_tops[1:]
        )
        v_equations = []
        start_ys = []
        end_ys = []
        center_paths = []
        braces = []
        for (top1, top2), x in zip(layer_top_pairs, it.count(1)):
            eq_mob = TexMobject(
                ["v_%d"%x, "=", "\sqrt{\phantom{y_1}}"],
                size = "\\Large"
            )
            midpoint = UP*(top1+top2)/2
            eq_mob.shift(midpoint)
            v_eq = eq_mob.split()
            center_paths.append(Line(
                midpoint+SPACE_WIDTH*LEFT, 
                midpoint+SPACE_WIDTH*RIGHT
            ))            
            brace_endpoints = Mobject(
                Point(self.top*UP+x*RIGHT),
                Point(top2*UP+x*RIGHT)
            )
            brace = Brace(brace_endpoints, RIGHT)

            start_y = TexMobject("y_%d"%x, size = "\\Large")
            end_y = start_y.copy()            
            start_y.next_to(brace, RIGHT)
            end_y.shift(v_eq[-1].get_center())
            end_y.shift(0.2*RIGHT)

            v_equations.append(v_eq)
            start_ys.append(start_y)
            end_ys.append(end_y)
            braces.append(brace)

        for v_eq, path, time in zip(v_equations, center_paths, [2, 1, 0.5]):
            photon_run = self.photon_run_along_path(
                path,
                rate_func = None
            )
            self.play(
                ShimmerIn(v_eq[0]),
                photon_run,
                run_time = time
            )
        self.dither()
        for start_y, brace in zip(start_ys, braces):
            self.add(start_y)            
            self.play(GrowFromCenter(brace))
        self.dither()
        quads = zip(v_equations, start_ys, end_ys, braces)
        self.equations = []
        for v_eq, start_y, end_y, brace in quads:
            self.remove(brace)
            self.play(
                ShowCreation(v_eq[1]),
                ShowCreation(v_eq[2]),
                Transform(start_y, end_y)
            )

            v_eq.append(start_y)
            self.equations.append(Mobject(*v_eq))
开发者ID:GodotMisogi,项目名称:manim,代码行数:68,代码来源:graveyard.py

示例13: Notation

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
class Notation(Scene):
    def construct(self):
        self.introduce_notation()
        self.shift_to_good_and_back()
        self.shift_to_visuals()
        self.swipe_left()


    def introduce_notation(self):
        notation = TextMobject("Notation")
        notation.to_edge(UP)

        self.sum1 = TexMobject("\\sum_{n=1}^\\infty \\dfrac{1}{n}")
        self.prod1 = TexMobject("\\prod_{p\\text{ prime}}\\left(1-p^{-s}\\right)")
        self.trigs1 = TexMobject([
            ["\\sin", "(x)"],
            ["\\cos", "(x)"],
            ["\\tan", "(x)"],
        ], next_to_direction = DOWN)
        self.func1 = TexMobject("f(x) = y")
        symbols = [self.sum1, self.prod1, self.trigs1, self.func1]
        for sym, vect in zip(symbols, compass_directions(4, UP+LEFT)):
            sym.scale(0.5)
            vect[0] *= 2
            sym.shift(vect)
        self.symbols = VMobject(*symbols)

        self.play(Write(notation))
        self.play(Write(self.symbols))
        self.dither()
        self.add(notation, self.symbols)



    def shift_to_good_and_back(self):
        sum2 = self.sum1.copy()
        sigma = sum2.submobjects[1]
        plus = TexMobject("+").replace(sigma)
        sum2.submobjects[1] = plus

        prod2 = self.prod1.copy()
        pi = prod2.submobjects[0]
        times = TexMobject("\\times").replace(pi)
        prod2.submobjects[0] = times

        new_sin, new_cos, new_tan = [
            VMobject().set_anchor_points(
                corners, mode = "corners"
            ).replace(trig_part.split()[0])
            for corners, trig_part in zip(
                [
                    [RIGHT, RIGHT+UP, LEFT],
                    [RIGHT+UP, LEFT, RIGHT],
                    [RIGHT+UP, RIGHT, LEFT],
                ],
                self.trigs1.split()
            )
        ]
        x1, x2, x3 = [
            trig_part.split()[1]
            for trig_part in self.trigs1.split()
        ]
        trigs2 = VMobject(
            VMobject(new_sin, x1),
            VMobject(new_cos, x2),
            VMobject(new_tan, x3),
        )

        x, arrow, y = TexMobject("x \\rightarrow y").split()
        f = TexMobject("f")
        f.next_to(arrow, UP)
        func2 = VMobject(f, VMobject(), x, VMobject(), arrow, y)
        func2.scale(0.5)
        func2.shift(self.func1.get_center())

        good_symbols = VMobject(sum2, prod2, trigs2, func2)
        bad_symbols = self.symbols.copy()
        self.play(Transform(
            self.symbols, good_symbols, 
            path_arc = np.pi
        ))
        self.dither(3)
        self.play(Transform(
            self.symbols, bad_symbols,
            path_arc = np.pi
        ))
        self.dither()


    def shift_to_visuals(self):
        sigma, prod, trig, func = self.symbols.split()
        new_trig = trig.copy()        
        sin, cos, tan = [
            trig_part.split()[0]
            for trig_part in new_trig.split()
        ]
        trig_anim = TrigAnimation()
        sin.highlight(trig_anim.sin_color)
        cos.highlight(trig_anim.cos_color)
        tan.highlight(trig_anim.tan_color)
#.........这里部分代码省略.........
开发者ID:GodotMisogi,项目名称:manim,代码行数:103,代码来源:intro.py

示例14: house_example

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def house_example(self, starter_mobject, title):
        house = SVGMobject("house")
        house.set_stroke(width = 0)
        house.set_fill(BLUE_C, opacity = 1)
        house.scale_to_fit_height(3)
        house.center()
        square_footage_words = TextMobject("Square footage:")
        price_words = TextMobject("Price: ")
        square_footage = TexMobject("2{,}600\\text{ ft}^2")
        price = TextMobject("\\$300{,}000")

        house.to_edge(LEFT).shift(UP)
        square_footage_words.next_to(house, RIGHT)
        square_footage_words.shift(0.5*UP)
        square_footage_words.highlight(RED)
        price_words.next_to(square_footage_words, DOWN, aligned_edge = LEFT)
        price_words.highlight(GREEN)
        square_footage.next_to(square_footage_words)
        square_footage.highlight(RED)
        price.next_to(price_words)
        price.highlight(GREEN)

        vector = Matrix([square_footage.copy(), price.copy()])
        vector.next_to(house, RIGHT).shift(0.25*UP)
        new_square_footage, new_price = vector.get_mob_matrix().flatten()
        not_equals = TexMobject("\\ne")
        not_equals.next_to(vector)
        alt_vector = Matrix([
            TextMobject("300{,}000\\text{ ft}^2").highlight(RED),
            TextMobject("\\$2{,}600").highlight(GREEN)
        ])
        alt_vector.next_to(not_equals)

        brace = Brace(vector, RIGHT)
        two_dimensional = TextMobject("2 dimensional")
        two_dimensional.next_to(brace)
        brackets = vector.get_brackets()

        self.play(Transform(starter_mobject, house))
        self.remove(starter_mobject)
        self.add(house)
        self.add(square_footage_words)
        self.play(Write(square_footage, run_time = 2))
        self.add(price_words)
        self.play(Write(price, run_time = 2))
        self.dither()
        self.play(
            FadeOut(square_footage_words), FadeOut(price_words),
            Transform(square_footage, new_square_footage),
            Transform(price, new_price),
            Write(brackets),
            run_time = 1
        )
        self.remove(square_footage_words, price_words)
        self.dither()
        self.play(
            Write(not_equals),
            Write(alt_vector),
            run_time = 1
        )
        self.dither()
        self.play(FadeOut(not_equals), FadeOut(alt_vector))
        self.remove(not_equals, alt_vector)
        self.dither()
        self.play(
            GrowFromCenter(brace),
            Write(two_dimensional),
            run_time = 1
        )
        self.dither()

        everything = VMobject(
            house, square_footage, price, brackets, brace, 
            two_dimensional, title
        )
        self.play(ApplyMethod(everything.shift, 2*SPACE_WIDTH*LEFT))
        self.remove(everything)
开发者ID:namkam5,项目名称:manim,代码行数:79,代码来源:chapter1.py

示例15: contrast_big_and_small_concavity

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import copy [as 别名]
    def contrast_big_and_small_concavity(self):
        colors = color_gradient([GREEN, WHITE], 3)
        x0, y0 = 4, 2
        graphs = [
            self.get_graph(func, color = color)
            for color, func in zip(colors, [
                lambda x : 5*(x - x0)**2 + y0,
                lambda x : 0.2*(x - x0)**2 + y0,
                lambda x : (x-x0) + y0,
            ])
        ]
        arg_rhs_list = [
            TexMobject("(", str(x0), ")", "=", str(rhs))
            for rhs in 10, 0.4, 0
        ]
        for graph, arg_rhs in zip(graphs, arg_rhs_list):
            graph.ss_group = self.get_secant_slope_group(
                x0-1, graph, 
                dx = 0.001,
                secant_line_color = YELLOW
            )
            arg_rhs.move_to(self.second_deriv.get_center(), LEFT)
            graph.arg_rhs = arg_rhs
        graph = graphs[0]

        v_line = DashedLine(*[
            self.coords_to_point(x0, 0),
            self.coords_to_point(x0, y0),
        ])
        input_label = TexMobject(str(x0))
        input_label.next_to(v_line, DOWN)

        self.play(ShowCreation(graph, run_time = 2))
        self.play(
            Write(input_label),
            ShowCreation(v_line)
        )
        self.play(
            ReplacementTransform(
                input_label.copy(),
                graph.arg_rhs.get_part_by_tex(str(x0))
            ),
            self.second_deriv.next_to, graph.arg_rhs.copy(), LEFT, SMALL_BUFF,
            Write(VGroup(*[
                submob
                for submob in graph.arg_rhs
                if submob is not graph.arg_rhs.get_part_by_tex(str(x0))
            ]))
        )
        self.dither()
        self.play(FadeIn(graph.ss_group))
        self.animate_secant_slope_group_change(
            graph.ss_group, target_x = x0 + 1,
            run_time = 3,
        )
        self.play(FadeOut(graph.ss_group))
        self.dither()
        for new_graph in graphs[1:]:
            self.play(Transform(graph, new_graph))
            self.play(Transform(
                graph.arg_rhs,
                new_graph.arg_rhs,
            ))
            self.play(FadeIn(new_graph.ss_group))
            self.animate_secant_slope_group_change(
                new_graph.ss_group, target_x = x0 + 1,
                run_time = 3,
            )
            self.play(FadeOut(new_graph.ss_group))
开发者ID:PythonJedi,项目名称:manim,代码行数:71,代码来源:footnote.py


注:本文中的mobject.tex_mobject.TexMobject.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。