• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tex_mobject.TexMobject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_polygons

    def add_polygons(self):
        a = self.i_hat.get_end()[0]*RIGHT
        b = self.j_hat.get_end()[0]*RIGHT
        c = self.i_hat.get_end()[1]*UP
        d = self.j_hat.get_end()[1]*UP

        shapes_colors_and_tex = [
            (Polygon(ORIGIN, a, a+c), TEAL, "bd/2"),
            (Polygon(ORIGIN, d+b, d), TEAL, "\\dfrac{bd}{2}"),
            (Polygon(a+c, a+b+c, a+b+c+d), MAROON, "\\dfrac{ac}{2}"),
            (Polygon(b+d, a+b+c+d, b+c+d), MAROON, "ac/2"),
            (Polygon(a, a+b, a+b+c, a+c), PINK, "bc"),
            (Polygon(d, d+b, d+b+c, d+c), PINK, "bc"),
        ]
        everyone = VMobject()
        for shape, color, tex in shapes_colors_and_tex:
            shape.set_stroke(width = 0)
            shape.set_fill(color = color, opacity = 0.7)
            tex_mob = TexMobject(tex)
            tex_mob.scale(0.7)
            tex_mob.move_to(shape.get_center_of_mass())
            everyone.add(shape, tex_mob)
        self.play(FadeIn(
            everyone, 
            submobject_mode = "lagged_start",
            run_time = 1
        ))
开发者ID:xhrwang,项目名称:manim,代码行数:27,代码来源:chapter5.py


示例2: get_subdivision_braces_and_labels

    def get_subdivision_braces_and_labels(
        self, parts, labels, direction,
        buff = SMALL_BUFF,
        min_num_quads = 1
        ):
        label_mobs = VGroup()
        braces = VGroup()
        for label, part in zip(labels, parts):
            brace = Brace(
                part, direction, 
                min_num_quads = min_num_quads, 
                buff = buff
            )
            if isinstance(label, Mobject):
                label_mob = label
            else:
                label_mob = TexMobject(label)
                label_mob.scale(self.default_label_scale_val)
            label_mob.next_to(brace, direction, buff)

            braces.add(brace)
            label_mobs.add(label_mob)
        parts.braces = braces
        parts.labels = label_mobs
        parts.label_kwargs = {
            "labels" : label_mobs.copy(),
            "direction" : direction, 
            "buff" : buff,
        }
        return VGroup(parts.braces, parts.labels)
开发者ID:PythonJedi,项目名称:manim,代码行数:30,代码来源:probability.py


示例3: generate_points

 def generate_points(self):
     self.cell_height = self.height / self.nrows
     self.cell_width = self.width / self.nrows
     self.bottom_left = (self.cell_width * self.nrows / 2.0)*LEFT + \
                        (self.cell_height * self.nrows / 2.0)*DOWN
     num_to_num_mob   = {} 
     self.coords_to_mobs   = {}
     self.coords = [
         (n, k) 
         for n in range(self.nrows) 
         for k in range(n+1)
     ]
     for n, k in self.coords:
         num = choose(n, k)              
         center = self.coords_to_center(n, k)
         num_mob = TexMobject(str(num))
         scale_factor = min(
             1,
             self.portion_to_fill * self.cell_height / num_mob.get_height(),
             self.portion_to_fill * self.cell_width / num_mob.get_width(),
         )
         num_mob.center().scale(scale_factor).shift(center)
         if n not in self.coords_to_mobs:
             self.coords_to_mobs[n] = {}
         self.coords_to_mobs[n][k] = num_mob
     self.add(*[
         self.coords_to_mobs[n][k] 
         for n, k in self.coords
     ])
     return self
开发者ID:GodotMisogi,项目名称:manim,代码行数:30,代码来源:combinatorics.py


示例4: move_matrix_parentheses

    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,代码行数:28,代码来源:chapter4.py


示例5: show_geometry

    def show_geometry(self, slider, vector):
        point_a = self.point_a.get_center()
        horiz_line = Line(point_a, point_a + 6*RIGHT)
        ceil_point = point_a
        ceil_point[0] = slider.get_center()[0]
        vert_brace = Brace(
            Mobject(Point(ceil_point), Point(slider.get_center())),
            RIGHT,
            buff = 0.5
        )
        vect_brace = Brace(slider)
        vect_brace.stretch_to_fit_width(vector.get_length())
        vect_brace.rotate(np.arctan(vector.get_slope()))
        vect_brace.center().shift(vector.get_center())
        nudge = 0.2*(DOWN+LEFT)
        vect_brace.shift(nudge)
        y_mob = TexMobject("y")
        y_mob.next_to(vert_brace)
        sqrt_y = TexMobject("k\\sqrt{y}")
        sqrt_y.scale(0.5)
        sqrt_y.shift(vect_brace.get_center())
        sqrt_y.shift(3*nudge)

        self.play(ShowCreation(horiz_line))
        self.play(
            GrowFromCenter(vert_brace),
            ShimmerIn(y_mob)
        )
        self.play(
            GrowFromCenter(vect_brace),
            ShimmerIn(sqrt_y)
        )
        self.dither(3)
        self.solve_energy()
开发者ID:GodotMisogi,项目名称:manim,代码行数:34,代码来源:curves.py


示例6: specifics_concepts

    def specifics_concepts(self):
        matrix_vector_product = TexMobject(" ".join([
            matrix_to_tex_string(EXAMPLE_TRANFORM),
            matrix_to_tex_string(TRANFORMED_VECTOR),
            "&=",
            matrix_to_tex_string([
                ["1 \\cdot 1 + 0 \\cdot 2"], 
                ["1 \\cdot 1 + (-1)\\cdot 2"]
            ]),
            "\\\\ &=",
            matrix_to_tex_string([[1], [-1]]),
        ]))
        matrix_vector_product.scale_to_fit_width(SPACE_WIDTH-0.5)
        matrix_vector_product.next_to(self.vline, LEFT)

        self.play(
            Write(self.numeric),
            FadeIn(matrix_vector_product),
            run_time = 2
        )
        self.dither()
        self.play(Write(self.geometric, run_time = 2))
        ### Paste in linear transformation
        self.dither()
        digest_locals(self)
开发者ID:PythonJedi,项目名称:manim,代码行数:25,代码来源:chapter0.py


示例7: construct

    def construct(self):
        matrix = Matrix([
            [2, 0],
            [-1, 1],
            [-2, 1],
        ])
        matrix.highlight_columns(X_COLOR, Y_COLOR)
        rows_brace = Brace(matrix, LEFT)
        rows_words = rows_brace.get_text("3", "rows")
        rows_words.highlight(PINK)
        cols_brace = Brace(matrix, UP)
        cols_words = cols_brace.get_text("2", "columns")
        cols_words.highlight(TEAL)
        title = TexMobject("3", "\\times", "2", "\\text{ matrix}")
        title.to_edge(UP)

        self.add(matrix)
        self.play(
            GrowFromCenter(rows_brace),
            Write(rows_words, run_time = 2)
        )
        self.play(
            GrowFromCenter(cols_brace),
            Write(cols_words, run_time = 2)
        )
        self.dither()
        self.play(
            rows_words[0].copy().move_to, title[0],
            cols_words[0].copy().move_to, title[2],
            Write(VMobject(title[1], title[3]))
        )
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:32,代码来源:footnote2.py


示例8: construct

    def construct(self):
        p_tex = "$%s$"%get_vect_tex("p")
        p_mob = TextMobject(p_tex)
        p_mob.scale(1.5)
        p_mob.highlight(P_COLOR)
        input_array = Matrix(list("xyz"))
        dot_product = Group(p_mob, Dot(radius = 0.07), input_array)
        dot_product.arrange_submobjects(buff = MED_BUFF/2)
        equals = TexMobject("=")
        dot_product.next_to(equals, LEFT)
        words = Group(*it.starmap(TextMobject, [
            ("(Length of projection)",),
            ("(Length of ", p_tex, ")",)
        ]))
        times = TexMobject("\\times")
        words[1].highlight_by_tex(p_tex, P_COLOR)
        words[0].next_to(equals, RIGHT)
        words[1].next_to(words[0], DOWN, aligned_edge = LEFT)
        times.next_to(words[0], RIGHT)

        everyone = Group(dot_product, equals, times, words)
        everyone.center().scale_to_fit_width(SPACE_WIDTH - 1)
        self.add(dot_product)
        self.play(Write(equals))
        self.play(Write(words[0]))
        self.dither()
        self.play(
            Write(times),
            Write(words[1])
        )
        self.dither()
开发者ID:scottopell,项目名称:manim,代码行数:31,代码来源:chapter8p2.py


示例9: construct

    def construct(self):
        in_vect = Matrix(self.input_coords)
        out_vect = Matrix(self.output_coords)
        in_vect.highlight(BLUE)
        out_vect.highlight(GREEN)
        func = TexMobject("L(\\vec{\\textbf{v}})")
        point = VectorizedPoint(func.get_center())
        in_vect.next_to(func, LEFT, buff = 1)
        out_vect.next_to(func, RIGHT, buff = 1)
        in_words = TextMobject("Input")
        in_words.next_to(in_vect, DOWN)
        in_words.highlight(BLUE_C)
        out_words = TextMobject("Output")
        out_words.next_to(out_vect, DOWN)
        out_words.highlight(GREEN_C)


        title = TextMobject(self.title)
        title.to_edge(UP)
        self.add(title)

        self.play(Write(func))
        self.play(Write(in_vect), Write(in_words))
        self.dither()
        self.add(in_vect.copy())
        self.play(Transform(in_vect, point, submobject_mode = "lagged_start"))
        self.play(Transform(in_vect, out_vect, submobject_mode = "lagged_start"))
        self.add(out_words)
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:29,代码来源:footnote.py


示例10: construct

    def construct(self):
        point_a, point_b = 3*LEFT, 3*RIGHT
        dots = []
        for point, char in [(point_a, "A"), (point_b, "B")]:
            dot = Dot(point)
            letter = TexMobject(char)
            letter.next_to(dot, UP+LEFT)
            dot.add(letter)
            dots.append(dot)

        path = ParametricFunction(
            lambda t : (t/2 + np.cos(t))*RIGHT + np.sin(t)*UP,
            start = -2*np.pi,
            end = 2*np.pi
        )
        path.scale(6/(2*np.pi))
        path.shift(point_a - path.points[0])
        path.highlight(RED)
        line = Line(point_a, point_b)
        words = TextMobject("Shortest path from $A$ to $B$")
        words.to_edge(UP)

        self.play(
            ShimmerIn(words),
            *map(GrowFromCenter, dots)
        )
        self.play(ShowCreation(path))
        self.play(Transform(
            path, line,
            path_func = path_along_arc(np.pi)
        ))
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:32,代码来源:misc.py


示例11: construct

    def construct(self):
        derivative = TexMobject(
            "\\frac{d(a^t)}{dt} =", "a^t \\ln(a)"
        )
        derivative[0][3].highlight(YELLOW)
        derivative[1][1].highlight(YELLOW)
        derivative[0][2].highlight(BLUE)
        derivative[1][0].highlight(BLUE)
        derivative[1][5].highlight(BLUE)
        derivative.scale(3)
        # derivative.to_edge(UP)
        derivative.shift(DOWN)

        brace = Brace(Line(LEFT, RIGHT), UP)
        brace.scale_to_fit_width(derivative[1].get_width())
        brace.next_to(derivative[1], UP)
        question = TextMobject("Why?")
        question.scale(2.5)
        question.next_to(brace, UP)

        # randy = Randolph()
        # randy.scale(1.3)
        # randy.next_to(ORIGIN, LEFT).to_edge(DOWN)
        # randy.change_mode("pondering")

        # question = TextMobject("What is $e\\,$?")
        # e = question[-2]
        # e.scale(1.2, about_point = e.get_bottom())
        # e.highlight(BLUE)
        # question.scale(1.7)
        # question.next_to(randy, RIGHT, aligned_edge = UP)
        # question.shift(DOWN)
        # randy.look_at(question)

        self.add(derivative, brace, question)
开发者ID:crclayton,项目名称:manim,代码行数:35,代码来源:chapter4.py


示例12: show_snells

    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,代码行数:34,代码来源:graveyard.py


示例13: construct

 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,代码行数:27,代码来源:chapter4.py


示例14: construct

    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,代码行数:25,代码来源:intro.py


示例15: show_derivative

    def show_derivative(self):
        deriv = TexMobject("\\frac{df}{dx}")
        deriv.next_to(self.graph_label, DOWN, MED_LARGE_BUFF)
        deriv.highlight(self.deriv_color)
        ss_group = self.get_secant_slope_group(
            1, self.graph,
            dx = 0.01,
            secant_line_color = self.deriv_color
        )

        self.play(
            Write(deriv),
            *map(ShowCreation, ss_group)
        )
        self.animate_secant_slope_group_change(
            ss_group, target_x = self.x3,
            run_time = 5
        )
        self.dither()
        self.animate_secant_slope_group_change(
            ss_group, target_x = self.x2,
            run_time = 3
        )
        self.dither()

        self.ss_group = ss_group
        self.deriv = deriv
开发者ID:PythonJedi,项目名称:manim,代码行数:27,代码来源:footnote.py


示例16: add_scaling

    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,代码行数:28,代码来源:chapter1.py


示例17: get_label_group

    def get_label_group(self, t):
        graph = self.graph

        v_line = self.get_vertical_line_to_graph(
            t, graph,
            color = YELLOW,
        )
        brace = Brace(v_line, RIGHT)
        height_label = brace.get_text("$2^%d$"%t)

        ss_group = self.get_secant_slope_group(
            t, graph, dx = 0.01,
            df_label = "dM",
            dx_label = "dt",
            dx_line_color = GREEN,
            secant_line_color = RED,
        )
        slope_label = TexMobject(
            "\\text{Slope}", "=", 
            "2^%d"%t,
            "(%.7f\\dots)"%np.log(2)
        )
        slope_label.next_to(
            ss_group.secant_line.point_from_proportion(0.65),
            DOWN+RIGHT,
            buff = 0
        )
        slope_label.highlight_by_tex("Slope", RED)
        return VGroup(
            v_line, brace, height_label,
            ss_group, slope_label
        )
开发者ID:crclayton,项目名称:manim,代码行数:32,代码来源:chapter4.py


示例18: intro_vector

    def intro_vector(self):
        plane = NumberPlane()
        labels = VMobject(*plane.get_coordinate_labels())
        vector = Vector(RIGHT+2*UP, color = YELLOW)
        coordinates = vector_coordinate_label(vector)
        symbol = TexMobject("\\vec{\\textbf{v}}")
        symbol.shift(0.5*(RIGHT+UP))

        self.play(ShowCreation(
            plane, 
            submobject_mode = "lagged_start",
            run_time = 3
        ))
        self.play(ShowCreation(
            vector,
            submobject_mode = "one_at_a_time"
        ))
        self.play(
            Write(labels),
            Write(coordinates),
            Write(symbol)
        )
        self.dither(2)
        self.play(
            FadeOut(plane),
            FadeOut(labels),
            ApplyMethod(vector.shift, 4*LEFT+UP),
            ApplyMethod(coordinates.shift, 2.5*RIGHT+0.5*DOWN),
            ApplyMethod(symbol.shift, 0.5*(UP+LEFT))
        )
        self.remove(plane, labels)
        return vector, symbol, coordinates
开发者ID:namkam5,项目名称:manim,代码行数:32,代码来源:chapter1.py


示例19: side_project

    def side_project(self, morty):
        rect = PictureInPictureFrame()
        rect.next_to(morty, UP+LEFT)
        side_project = TextMobject("Side project")
        side_project.next_to(rect, UP)
        dollar_sign = TexMobject("\\$")
        cross = VGroup(*[
            Line(vect, -vect, color = RED)
            for vect in UP+RIGHT, UP+LEFT
        ])
        cross.scale_to_fit_height(dollar_sign.get_height())
        no_money = VGroup(dollar_sign, cross)
        no_money.next_to(rect, DOWN)

        self.play(
            morty.change_mode, "raise_right_hand",
            morty.look_at, rect
        )
        self.play(
            Write(side_project),
            ShowCreation(rect)
        )
        self.dither()
        self.play(Blink(morty))
        self.dither()
        self.play(Write(dollar_sign))
        self.play(ShowCreation(cross))

        self.screen_title = side_project
        self.cross = cross
开发者ID:aquafemi,项目名称:manim,代码行数:30,代码来源:patreon.py


示例20: generate_points

    def generate_points(self):
        start_angle = np.pi/2 + self.arc_angle/2
        end_angle = np.pi/2 - self.arc_angle/2
        self.add(Arc(
            start_angle = start_angle,
            angle = -self.arc_angle
        ))
        tick_angle_range = np.linspace(start_angle, end_angle, self.num_ticks)
        for index, angle in enumerate(tick_angle_range):
            vect = rotate_vector(RIGHT, angle)
            tick = Line((1-self.tick_length)*vect, vect)
            label = TexMobject(str(10*index))
            label.scale_to_fit_height(self.tick_length)
            label.shift((1+self.tick_length)*vect)
            self.add(tick, label)

        needle = Polygon(
            LEFT, UP, RIGHT,
            stroke_width = 0,
            fill_opacity = 1,
            fill_color = self.needle_color
        )
        needle.stretch_to_fit_width(self.needle_width)
        needle.stretch_to_fit_height(self.needle_height)
        needle.rotate(start_angle - np.pi/2)
        self.add(needle)
        self.needle = needle

        self.center_offset = self.get_center()
开发者ID:crclayton,项目名称:manim,代码行数:29,代码来源:objects.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tex_mobject.TextMobject类代码示例发布时间:2022-05-27
下一篇:
Python mobject.Mobject类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap