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


Python TexMobject.next_to方法代码示例

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


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

示例1: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:34,代码来源:misc.py

示例2: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    def construct(self):
        cycloid = Cycloid()
        index = cycloid.get_num_points()/3
        point = cycloid.points[index]
        vect = cycloid.points[index+1]-point
        vect /= np.linalg.norm(vect)
        vect *= 3
        vect_mob = Vector(point, vect)
        dot = Dot(point)
        xy = TexMobject("\\big( x(t), y(t) \\big)")
        xy.next_to(dot, UP+RIGHT, buff = 0.1)
        vert_line = Line(2*DOWN, 2*UP)
        vert_line.shift(point)
        angle = vect_mob.get_angle() + np.pi/2
        arc = Arc(angle, radius = 1, start_angle = -np.pi/2)
        arc.shift(point)
        theta = TexMobject("\\theta(t)")
        theta.next_to(arc, DOWN, buff = 0.1, aligned_edge = LEFT)
        theta.shift(0.2*RIGHT)

        self.play(ShowCreation(cycloid))
        self.play(ShowCreation(dot))
        self.play(ShimmerIn(xy))
        self.dither()
        self.play(
            FadeOut(xy),
            ShowCreation(vect_mob)
        )
        self.play(
            ShowCreation(arc),
            ShowCreation(vert_line),
            ShimmerIn(theta)
        )
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:36,代码来源:curves.py

示例3: specifics_concepts

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:27,代码来源:chapter0.py

示例4: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    def construct(self):
        eq1 = TexMobject(
            "\\text{secant}(\\theta) = \\frac{1}{\\text{cosine}(\\theta)}"
        )
        eq2 = TexMobject(
            "\\text{cosecant}(\\theta) = \\frac{1}{\\text{sine}(\\theta)}"
        )
        eq1.to_corner(UP+LEFT)
        eq1.to_edge(LEFT)
        eq2.next_to(eq1, DOWN, buff = LARGE_BUFF)
        eqs = VGroup(eq1, eq2)

        self.play(
            self.get_teacher().change_mode, "speaking",
            Write(eqs),
            *[
                ApplyMethod(pi.look_at, eqs)
                for pi in self.get_students()
            ]
        )
        self.random_blink()
        self.play(
            VGroup(*eq1[-9:-7]).highlight, YELLOW,
            VGroup(*eq2[:2]).highlight, YELLOW,
            *[
                ApplyMethod(pi.change_mode, "confused")
                for pi in self.get_students()
            ]
        )
        self.random_blink(2)
开发者ID:PythonJedi,项目名称:manim,代码行数:32,代码来源:tattoo.py

示例5: show_y

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    def show_y(self):
        y_equals = TexMobject(["y", "="])
        y_equals.shift(2*UP)
        y_expression = TexMobject([
            "D ", "\\sin", "^2", "(\\theta)"
        ])
        y_expression.next_to(y_equals)
        y_expression.shift(0.05*UP+0.1*RIGHT)
        temp_expr = self.d_sin_squared_theta.copy()
        temp_expr.rotate(-np.pi/2)
        temp_expr.replace(y_expression)
        y_mob = TexMobject("y")
        y_mob.next_to(self.y_line, RIGHT)
        y_mob.shift(0.2*UP)

        self.play(
            Transform(self.d_sin_squared_theta, temp_expr),
            ShimmerIn(y_mob),
            ShowCreation(y_equals)
        )
        self.remove(self.d_sin_squared_theta)
        self.add(y_expression)

        self.y_equals = y_equals
        self.y_expression = y_expression
开发者ID:GodotMisogi,项目名称:manim,代码行数:27,代码来源:cycloid.py

示例6: get_subdivision_braces_and_labels

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:32,代码来源:probability.py

示例7: get_matrices

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    def get_matrices(self):       
        m1_mob = Matrix(np.array(self.t_matrix1).transpose())
        m2_mob = Matrix(np.array(self.t_matrix2).transpose())
        comp_matrix = Matrix([["?", "?"], ["?", "?"]])        
        m1_mob.highlight(YELLOW)
        m2_mob.highlight(PINK)
        comp_matrix.get_entries().submobject_gradient_highlight(YELLOW, PINK)

        equals = TexMobject("=")
        equals.next_to(comp_matrix, LEFT)
        comp_matrix.add(equals)
        m1_mob = VMobject(BackgroundRectangle(m1_mob), m1_mob)
        m2_mob = VMobject(BackgroundRectangle(m2_mob), m2_mob)
        comp_matrix = VMobject(BackgroundRectangle(comp_matrix), comp_matrix)
        VMobject(
            m2_mob, m1_mob, comp_matrix
        ).arrange_submobjects(buff = 0.1).to_corner(UP+LEFT).shift(DOWN)

        for i, mob in enumerate([m1_mob, m2_mob]):
            brace = Brace(mob, UP)
            text = TexMobject("M_%d"%(i+1))
            text.next_to(brace, UP)
            brace.add_background_rectangle()
            text.add_background_rectangle()
            brace.add(text)
            mob.label = brace
        return m1_mob, m2_mob, comp_matrix
开发者ID:PythonJedi,项目名称:manim,代码行数:29,代码来源:chapter4.py

示例8: show_proportionality_to_dx_squared

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    def show_proportionality_to_dx_squared(self):
        ddf = self.ddf.copy()
        ddf.generate_target()
        ddf.target.next_to(self.ddf, UP, LARGE_BUFF)
        rhs = TexMobject(
            "\\approx", "(\\text{Some constant})", "(dx)^2"
        )
        rhs.scale(0.8)
        rhs.next_to(ddf.target, RIGHT)

        example_dx = TexMobject(
            "dx = 0.01 \\Rightarrow (dx)^2 = 0.0001"
        )
        example_dx.scale(0.8)
        example_dx.to_corner(UP+RIGHT)

        self.play(MoveToTarget(ddf))
        self.play(Write(rhs))
        self.dither()
        self.play(Write(example_dx))
        self.dither(2)
        self.play(FadeOut(example_dx))

        self.ddf = ddf
        self.dx_squared = rhs.get_part_by_tex("dx")
开发者ID:PythonJedi,项目名称:manim,代码行数:27,代码来源:footnote.py

示例9: add_scaling

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

示例10: show_derivative

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:29,代码来源:footnote.py

示例11: get_graph_label

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
 def get_graph_label(
     self, 
     graph, 
     label = "f(x)", 
     x_val = None,
     direction = RIGHT,
     buff = MED_SMALL_BUFF,
     color = None,
     ):
     label = TexMobject(label)
     color = color or graph.get_color()
     label.highlight(color)
     if x_val is None:
         #Search from right to left
         for x in np.linspace(self.x_max, self.x_min, 100):
             point = self.input_to_graph_point(x, graph)
             if point[1] < SPACE_HEIGHT:
                 break
         x_val = x
     label.next_to(
         self.input_to_graph_point(x_val, graph),
         direction,
         buff = buff
     )
     label.shift_onto_screen()
     return label
开发者ID:crclayton,项目名称:manim,代码行数:28,代码来源:graph_scene.py

示例12: get_label_group

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:34,代码来源:chapter4.py

示例13: show_geometry

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:36,代码来源:curves.py

示例14: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    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,代码行数:33,代码来源:chapter8p2.py

示例15: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import next_to [as 别名]
    def construct(self):
        series = VideoSeries()
        series.to_edge(UP)
        this_video = series[3]
        next_video = series[4]
        brace = Brace(this_video, DOWN)
        this_video.save_state()
        this_video.highlight(YELLOW)

        this_tex = TexMobject(
            "{d(", "a^t", ") \\over dt} = ", "a^t", "\\ln(a)"
        )
        this_tex[1][1].highlight(YELLOW)
        this_tex[3][1].highlight(YELLOW)
        this_tex.next_to(brace, DOWN)

        next_tex = VGroup(*map(TextMobject, [
            "Chain rule", "Product rule", "$\\vdots$"
        ]))
        next_tex.arrange_submobjects(DOWN)
        next_tex.next_to(brace, DOWN)
        next_tex.shift(
            next_video.get_center()[0]*RIGHT\
            -next_tex.get_center()[0]*RIGHT
        )

        self.add(series, brace, *this_tex[:3])
        self.change_student_modes(
            "confused", "pondering", "erm",
            look_at_arg = this_tex
        )
        self.play(ReplacementTransform(
            this_tex[1].copy(), this_tex[3]
        ))
        self.dither()
        self.play(
            Write(this_tex[4]),
            ReplacementTransform(
                this_tex[3][0].copy(),
                this_tex[4][3],
                path_arc = np.pi,
                remover = True
            )
        )
        self.dither(2)
        self.play(this_tex.replace, this_video)
        self.play(
            brace.next_to, next_video, DOWN,
            this_video.restore,
            Animation(this_tex),
            next_video.highlight, YELLOW,
            Write(next_tex),
            self.get_teacher().change_mode, "raise_right_hand"
        )
        self.change_student_modes(
            *["pondering"]*3,
            look_at_arg = next_tex
        )
        self.dither(3)
开发者ID:crclayton,项目名称:manim,代码行数:61,代码来源:chapter4.py


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