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


Python TexMobject.split方法代码示例

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


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

示例1: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        definition = TexMobject([
            "\\text{HC}(", "x", ")",
            "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")"
        ])
        definition.to_edge(UP)
        definition.split()[1].highlight(BLUE)
        definition.split()[-2].highlight(BLUE)
        intro = TextMobject("Three things need to be proven")
        prove_that = TextMobject("Prove that HC is $\\dots$")
        prove_that.scale(0.7)
        prove_that.to_edge(LEFT)
        items = TextMobject([
            "\\begin{enumerate}",
            "\\item Well-defined: ",
            "Points on Pseudo-Hilbert-curves really do converge",
            "\\item A Curve: ",
            "HC is continuous",
            "\\item Space-filling: ",
            "Each point in the unit square is an output of HC",
            "\\end{enumerate}",
        ]).split()
        items[1].highlight(GREEN)
        items[3].highlight(YELLOW_C)
        items[5].highlight(MAROON)
        Mobject(*items).to_edge(RIGHT)

        self.add(definition)
        self.play(ShimmerIn(intro))
        self.dither()
        self.play(Transform(intro, prove_that))
        for item in items[1:-1]:
            self.play(ShimmerIn(item))
            self.dither()
开发者ID:Rubixdarcy,项目名称:manim,代码行数:36,代码来源:section2.py

示例2: add_scaling

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def add_scaling(self, arrows, syms, arrays):
        s_arrows = VMobject(
            TexMobject("2"), Vector([1, 1]).highlight(YELLOW), 
            TexMobject("="), Vector([2, 2]).highlight(WHITE)
        )
        s_arrows.arrange_submobjects(RIGHT)
        s_arrows.scale(0.75)
        s_arrows.next_to(arrows, DOWN)

        s_arrays = VMobject(
            TexMobject("2"), 
            matrix_to_mobject([3, -5]).highlight(YELLOW),
            TextMobject("="),
            matrix_to_mobject(["2(3)", "2(-5)"])
        )
        s_arrays.arrange_submobjects(RIGHT)
        s_arrays.scale(0.5)
        s_arrays.next_to(arrays, DOWN)

        s_syms = TexMobject(["2", "\\vec{\\textbf{v}}"])
        s_syms.split()[-1].highlight(YELLOW)
        s_syms.next_to(syms, DOWN)

        self.play(
            Write(s_arrows), Write(s_arrays), Write(s_syms),
            run_time = 2
        )
        self.dither()
开发者ID:namkam5,项目名称:manim,代码行数:30,代码来源:chapter1.py

示例3: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        exp = TexMobject("x^y = z")
        log = TexMobject("\\log_x(z) = y")
        rad = TexMobject("\\sqrt[y]{z} = x")
        exp.to_edge(LEFT).shift(2*UP)
        rad.to_edge(RIGHT).shift(2*DOWN)
        x1, y1, eq, z1 = exp.split()
        l, o, g, x2, p, z2, p, eq, y2 = log.split()
        y3, r, r, z3, eq, x3 = rad.split()
        vars1 = VMobject(x1, y1, z1).copy()
        vars2 = VMobject(x2, y2, z2)
        vars3 = VMobject(x3, y3, z3)

        self.play(Write(exp))
        self.play(Transform(vars1, vars2, path_arc = -np.pi))
        self.play(Write(log))
        self.play(Transform(vars1, vars3, path_arc = -np.pi))
        self.play(Write(rad))
        self.dither()

        words = TextMobject("Artificially unrelated")
        words.to_corner(UP+RIGHT)
        words.highlight(YELLOW)
        self.play(Write(words))
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:27,代码来源:intro.py

示例4: move_matrix_parentheses

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def move_matrix_parentheses(self, morty, matrices):
        m1, m2, m3 = matrices
        parens = TexMobject(["(", ")"])
        parens.scale_to_fit_height(1.2*m1.get_height())
        lp, rp = parens.split()
        state1 = VMobject(
            VectorizedPoint(m1.get_left()),
            m1, m2, 
            VectorizedPoint(m2.get_right()),
            m3
        )
        state2 = VMobject(*[
            m.copy() for m in lp, m1, m2, rp, m3
        ])
        state3 = VMobject(*[
            m.copy() for m in m1, lp, m2, m3, rp
        ])
        for state in state2, state3:
            state.arrange_submobjects(RIGHT, buff = 0.1)
        m1, lp, m2, m3, rp = state3.split()
        state3 = VMobject(lp, m1, m2, rp, m3)

        self.play(morty.change_mode, "angry")
        for state in state2, state3:
            self.play(Transform(state1, state))
            self.dither()
        self.play(morty.change_mode, "confused")
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:30,代码来源:chapter4.py

示例5: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        v_color = MAROON_C
        w_color = BLUE

        definition = TextMobject("""
            The ``span'' of $\\vec{\\textbf{v}}$ and 
            $\\vec{\\textbf{w}}$ is the \\\\ set of all their
            linear combinations.
        """)
        definition.scale_to_fit_width(2*SPACE_WIDTH-1)
        definition.to_edge(UP)
        def_mobs = np.array(definition.split())
        VMobject(*def_mobs[4:4+4]).highlight(PINK)
        VMobject(*def_mobs[11:11+2]).highlight(v_color)
        VMobject(*def_mobs[16:16+2]).highlight(w_color)
        VMobject(*def_mobs[-19:-1]).highlight(YELLOW)

        equation = TexMobject([
            "a", "\\vec{\\textbf{v}}", "+", "b", "\\vec{\\textbf{w}}"
        ])
        equation.arrange_submobjects(buff = 0.1, aligned_edge = DOWN)
        equation.split()[1].highlight(v_color)
        equation.split()[4].highlight(w_color)
        a, b = np.array(equation.split())[[0, 3]]
        equation.scale(2)
        equation.next_to(definition, DOWN, buff = 1)

        vary_words = TextMobject(
            "Let $a$ and $b$ vary \\\\ over all real numbers"
        )
        vary_words.scale(1.5)
        vary_words.next_to(equation, DOWN, buff = 2)
        arrows = [
            Arrow(vary_words, letter)
            for letter in a, b
        ]

        self.play(Write(definition))
        self.play(Write(equation))
        self.dither()
        self.play(
            FadeIn(vary_words),
            ShowCreation(VMobject(*arrows))
        )
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:47,代码来源:chapter2.py

示例6: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        vect_coords = [-1, 2]
        t_matrix = np.array([[2, 2], [-2, 1]])

        #Draw vectors
        self.setup()
        i_label = self.add_transformable_label(
            self.i_hat, "\\hat{\\imath}", animate = False,
            direction = "right", color = X_COLOR
        )
        j_label = self.add_transformable_label(
            self.j_hat, "\\hat{\\jmath}", animate = False,
            direction = "right", color = Y_COLOR
        )
        vect = self.add_vector(vect_coords)
        vect_array = Matrix(["x", "y"], add_background_rectangles = True)
        v_equals = TexMobject(["\\vec{\\textbf{v}}", "="])
        v_equals.split()[0].highlight(YELLOW)
        v_equals.next_to(vect_array, LEFT)
        vect_array.add(v_equals)
        vect_array.to_edge(UP, buff = 0.2)
        background_rect = BackgroundRectangle(vect_array)
        vect_array.get_entries().highlight(YELLOW)
        self.play(ShowCreation(background_rect), Write(vect_array))
        self.add_foreground_mobject(background_rect, vect_array)

        #Show scaled vectors
        x, y = vect_array.get_entries().split()
        scaled_i_label = VMobject(x.copy(), i_label)
        scaled_j_label = VMobject(y.copy(), j_label)
        scaled_i = self.i_hat.copy().scale(vect_coords[0])
        scaled_j = self.j_hat.copy().scale(vect_coords[1])
        for mob in scaled_i, scaled_j:
            mob.fade(0.3)
        scaled_i_label_target = scaled_i_label.copy()
        scaled_i_label_target.arrange_submobjects(buff = 0.1)
        scaled_i_label_target.next_to(scaled_i, DOWN)
        scaled_j_label_target = scaled_j_label.copy()
        scaled_j_label_target.arrange_submobjects(buff = 0.1)
        scaled_j_label_target.next_to(scaled_j, LEFT)

        self.show_scaled_vectors(vect_array, vect_coords, i_label, j_label)
        self.apply_transposed_matrix(t_matrix)
        self.show_scaled_vectors(vect_array, vect_coords, i_label, j_label)
        self.record_basis_coordinates(vect_array, vect)
开发者ID:PythonJedi,项目名称:manim,代码行数:47,代码来源:chapter4.py

示例7: add_brackets

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
 def add_brackets(self):
     bracket_pair = TexMobject("\\big[ \\big]")
     bracket_pair.scale(2)
     bracket_pair.stretch_to_fit_height(self.get_height() + 0.5)
     l_bracket, r_bracket = bracket_pair.split()
     l_bracket.next_to(self, LEFT)
     r_bracket.next_to(self, RIGHT)
     self.add(l_bracket, r_bracket)
     self.brackets = VMobject(l_bracket, r_bracket)
     return self
开发者ID:namkam5,项目名称:manim,代码行数:12,代码来源:matrix.py

示例8: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        self.setup()
        self.add_title(["How much are", "areas", "scaled?"])
        hma, areas, scaled = self.title.split()[1].split()
        areas.highlight(YELLOW)
        blob = Blob().shift(UP+RIGHT)

        label = TextMobject("Area")
        label.highlight(YELLOW)
        label = VMobject(VectorizedPoint(label.get_left()), label)
        label.move_to(blob)
        target_label = TexMobject(["c \\cdot", "\\text{Area}"])
        target_label.split()[1].highlight(YELLOW)

        self.add_transformable_mobject(blob)
        self.add_moving_mobject(label, target_label)
        self.dither()
        self.apply_transposed_matrix([[2, -1], [1, 1]])
        arrow = Arrow(scaled, label.target.split()[0])
        self.play(ShowCreation(arrow))
        self.dither()
开发者ID:xhrwang,项目名称:manim,代码行数:23,代码来源:chapter5.py

示例9: write_old_style_rules

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [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

示例10: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [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

示例11: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        n_terms = 4
        def func((x, y, ignore)):
            z = complex(x, y)                                    
            if (np.abs(x%1 - 0.5)<0.01 and y < 0.01) or np.abs(z)<0.01:
                return ORIGIN
            out_z = 1./(2*np.tan(np.pi*z)*(z**2))
            return out_z.real*RIGHT - out_z.imag*UP
        arrows = Mobject(*[
            Arrow(ORIGIN, np.sqrt(2)*point)
            for point in compass_directions(4, RIGHT+UP)
        ])
        arrows.highlight(YELLOW)
        arrows.ingest_submobjects()
        all_arrows = Mobject(*[
            arrows.copy().scale(0.3/(x)).shift(x*RIGHT)
            for x in range(1, n_terms+2)
        ])
        terms = TexMobject([
            "\\dfrac{1}{%d^2} + "%(x+1)
            for x in range(n_terms)
        ]+["\\cdots"])
        terms.shift(2*UP)
        plane = NumberPlane(color = BLUE_E)
        axes = Mobject(NumberLine(), NumberLine().rotate(np.pi/2))
        axes.highlight(WHITE)

        for term in terms.split():
            self.play(ShimmerIn(term, run_time = 0.5))
        self.dither()
        self.play(ShowCreation(plane), ShowCreation(axes))
        self.play(*[
            Transform(*pair)
            for pair in zip(terms.split(), all_arrows.split())
        ])
        self.play(PhaseFlow(
            func, plane,
            run_time = 5,
            virtual_time = 8
        ))
开发者ID:GodotMisogi,项目名称:manim,代码行数:42,代码来源:misc.py

示例12: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def construct(self):
        point_a = 3*LEFT+3*UP
        point_b = 1.5*RIGHT+3*DOWN
        midpoint = ORIGIN

        lines, arcs, thetas = [], [], []
        counter = it.count(1)
        for point in point_a, point_b:
            line = Line(point, midpoint, color = RED_D)
            angle = np.pi/2-np.abs(np.arctan(line.get_slope()))
            arc = Arc(angle, radius = 0.5).rotate(np.pi/2)
            if point is point_b:
                arc.rotate(np.pi)
                line.reverse_points()
            theta = TexMobject("\\theta_%d"%counter.next())
            theta.scale(0.5)
            theta.shift(2*arc.get_center())
            arc.shift(midpoint)
            theta.shift(midpoint)

            lines.append(line)
            arcs.append(arc)
            thetas.append(theta)
        vert_line = Line(2*UP, 2*DOWN)
        vert_line.shift(midpoint)
        path = Mobject(*lines).ingest_submobjects()
        glass = Region(lambda x, y : y < 0, color = BLUE_E)
        self.add(glass)
        equation = TexMobject([
            "\\dfrac{\\sin(\\theta_1)}{v_{\\text{air}}}",
            "=",            
            "\\dfrac{\\sin(\\theta_2)}{v_{\\text{water}}}",
        ])
        equation.to_corner(UP+RIGHT)
        exp1, equals, exp2 = equation.split()
        snells_law = TextMobject("Snell's Law:")
        snells_law.highlight(YELLOW)
        snells_law.to_edge(UP)

        self.play(ShimmerIn(snells_law))
        self.dither()
        self.play(ShowCreation(path))
        self.play(self.photon_run_along_path(path))
        self.dither()
        self.play(ShowCreation(vert_line))
        self.play(*map(ShowCreation, arcs))
        self.play(*map(GrowFromCenter, thetas))
        self.dither()
        self.play(ShimmerIn(exp1))
        self.dither()
        self.play(*map(ShimmerIn, [equals, exp2]))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:54,代码来源:light.py

示例13: show_symbolic_sum

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def show_symbolic_sum(self, new_array, vector):
        new_mob = TexMobject([
            "(%d)\\hat{\\imath}"%self.vector_coords[0], 
            "+", 
            "(%d)\\hat{\\jmath}"%self.vector_coords[1]
        ])
        new_mob.move_to(new_array)
        new_mob.shift_onto_screen()
        i_hat, plus, j_hat = new_mob.split()
        i_hat.highlight(X_COLOR)
        j_hat.highlight(Y_COLOR)

        self.play(Transform(new_array, new_mob))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:16,代码来源:chapter2.py

示例14: solve_energy

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
    def solve_energy(self):
        loss_in_potential = TextMobject("Loss in potential: ")
        loss_in_potential.shift(2*UP)
        potential = TexMobject("m g y".split())
        potential.next_to(loss_in_potential)
        kinetic = TexMobject([
            "\\dfrac{1}{2}","m","v","^2","="
        ])
        kinetic.next_to(potential, LEFT)
        nudge = 0.1*UP
        kinetic.shift(nudge)
        loss_in_potential.shift(nudge)
        ms = Mobject(kinetic.split()[1], potential.split()[0])
        two = TexMobject("2")
        two.shift(ms.split()[1].get_center())
        half = kinetic.split()[0]
        sqrt = TexMobject("\\sqrt{\\phantom{2mg}}")
        sqrt.shift(potential.get_center())
        nudge = 0.2*LEFT
        sqrt.shift(nudge)
        squared = kinetic.split()[3]
        equals = kinetic.split()[-1]
        new_eq = equals.copy().next_to(kinetic.split()[2])

        self.play(
            Transform(
                Point(loss_in_potential.get_left()),
                loss_in_potential
            ),
            *map(GrowFromCenter, potential.split())
        )
        self.dither(2)
        self.play(
            FadeOut(loss_in_potential),
            GrowFromCenter(kinetic)
        )
        self.dither(2)
        self.play(ApplyMethod(ms.shift, 5*UP))
        self.dither()
        self.play(Transform(
            half, two, 
            path_func = counterclockwise_path()
        ))
        self.dither()
        self.play(
            Transform(
                squared, sqrt, 
                path_func = clockwise_path()
            ),
            Transform(equals, new_eq)
        )
        self.dither(2)
开发者ID:GodotMisogi,项目名称:manim,代码行数:54,代码来源:curves.py

示例15: get_det_text

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import split [as 别名]
def get_det_text(matrix, determinant = None):
    parens = TexMobject(["(", ")"])
    parens.scale(2)
    parens.stretch_to_fit_height(matrix.get_height())
    l_paren, r_paren = parens.split()
    l_paren.next_to(matrix, LEFT, buff = 0.1)
    r_paren.next_to(matrix, RIGHT, buff = 0.1)
    det = TextMobject("det").next_to(l_paren, LEFT, buff = 0.1)
    det.add_background_rectangle()
    det_text = VMobject(det, l_paren, r_paren)
    if determinant is not None:
        eq = TexMobject("=")
        eq.next_to(r_paren, RIGHT, buff = 0.1)
        result = TexMobject(str(determinant))
        result.next_to(eq, RIGHT, buff = 0.2)
        det_text.add(eq, result)
    return det_text
开发者ID:xhrwang,项目名称:manim,代码行数:19,代码来源:chapter5.py


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