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


Python TexMobject.to_corner方法代码示例

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


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

示例1: construct

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

示例2: show_proportionality_to_dx_squared

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

示例3: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def construct(self):
        note = TexMobject(
            "{ d(a^", "t", ")", "\\over \\,", "dt}", 
            "=", "a^", "t", "(\\text{Some constant})"
        )
        note.highlight_by_tex("t", YELLOW)
        note.highlight_by_tex("dt", GREEN)
        note.highlight_by_tex("constant", BLUE)
        note.to_corner(UP+LEFT)
        self.add(note)

        self.student_says(
            "Is there a base where\\\\",
            "that constant is 1?"
        )
        self.change_student_modes(
            "pondering", "raise_right_hand", "thinking",
            # look_at_arg = self.get_students()[1].bubble
        )
        self.dither(2)
        self.play(FadeOut(note[-1], run_time = 3))
        self.dither()

        self.teacher_says(
            "There is!\\\\",
            "$e = 2.71828\\dots$",
            target_mode = "hooray"
        )
        self.change_student_modes(*["confused"]*3)
        self.dither(3)
开发者ID:crclayton,项目名称:manim,代码行数:32,代码来源:chapter4.py

示例4: try_specific_dt_values

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def try_specific_dt_values(self):
        expressions = []
        for num_zeros in [1, 2, 4, 7]:
            dt_str = "0." + num_zeros*"0" + "1"
            dt_num = float(dt_str)
            output_num = (self.base**dt_num - 1) / dt_num
            output_str = "%.7f\\dots"%output_num

            expression = TexMobject(
                "{%s^"%self.base_str, "{%s}"%dt_str, "-1", 
                "\\over \\,", "%s}"%dt_str, 
                "=", output_str
            )
            expression.highlight_by_tex(dt_str, GREEN)
            expression.highlight_by_tex(output_str, BLUE)
            expression.to_corner(UP+RIGHT)
            expressions.append(expression)

        curr_expression = expressions[0]
        self.play(
            Write(curr_expression),
            self.pi_creature.change_mode, "pondering"
        )
        self.dither(2)
        for expression in expressions[1:]:
            self.play(Transform(curr_expression, expression))
            self.dither(2)
        return curr_expression[-1]
开发者ID:crclayton,项目名称:manim,代码行数:30,代码来源:chapter4.py

示例5: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def construct(self):
        pascals_triangle = PascalsTriangle()
        pascals_triangle.scale(0.5)
        final_triangle = PascalsTriangle()
        final_triangle.fill_with_n_choose_k()
        pascals_triangle.to_corner(UP+LEFT)
        final_triangle.scale(0.7)
        final_triangle.to_edge(UP)
        equation = TexMobject([
            "{n \\choose k}",
            " = \\dfrac{n!}{(n-k)!k!}"
        ])
        equation.scale(0.5)
        equation.to_corner(UP+RIGHT)
        n_choose_k, formula = equation.split()
        words = TextMobject("Seemingly unrelated")
        words.shift(2*DOWN)
        to_remove = VMobject(*words.split()[:-7])

        self.add(pascals_triangle, n_choose_k, formula)
        self.play(Write(words))
        self.dither()
        self.play(
            Transform(pascals_triangle, final_triangle),
            Transform(n_choose_k, final_triangle),
            FadeOut(formula),
            ApplyMethod(to_remove.shift, 5*DOWN)
        )
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:31,代码来源:intro.py

示例6: construct

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

示例7: introduce_acceleration

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def introduce_acceleration(self):
        a_words = TexMobject(
            "{d^2 s \\over dt^2}(t)",  "\\Leftrightarrow",
            "\\text{Acceleration}"
        )
        a_words.highlight_by_tex("d^2 s", MAROON_B)
        a_words.highlight_by_tex("Acceleration", YELLOW)
        a_words.to_corner(UP+RIGHT )
        self.add(a_words)
        self.show_car_movement()
        self.dither()

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

示例8: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def construct(self):
        top = TOP()
        equation = TexMobject("2^3 = 8")
        equation.to_corner(UP+LEFT)
        two, three, eight = [
            top.put_on_vertex(i, num)
            for i, num in enumerate([2, 3, 8])
        ]

        self.play(FadeIn(equation))
        self.dither()
        self.play(ShowCreation(top))
        for num in two, three, eight:
            self.play(ShowCreation(num), run_time=2)
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:17,代码来源:triangle.py

示例9: introduce_expression

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def introduce_expression(self):
        f_x = TexMobject("f(x)", "=", "2^x")
        f_t = TexMobject("f(t)", "=", "2^t")
        P_t = TexMobject("P(t)", "=", "2^t")
        M_t = TexMobject("M(t)", "=", "2^t")
        functions = VGroup(f_x, f_t, P_t, M_t)
        for function in functions:
            function.scale(1.2)
            function.to_corner(UP+LEFT)
        for function in functions[1:]:
            for i, j in (0, 2), (2, 1):
                function[i][j].highlight(self.time_color)

        t_expression = TexMobject("t", "=", "\\text{Time (in days)}")
        t_expression.to_corner(UP+RIGHT)
        t_expression[0].highlight(self.time_color)

        pop_brace, mass_brace = [
            Brace(function[0], DOWN)
            for function in P_t, M_t
        ]
        for brace, word in (pop_brace, "size"), (mass_brace, "mass"):
            text = brace.get_text("Population %s"%word)
            text.to_edge(LEFT)
            brace.text = text

        self.play(Write(f_x))
        self.dither()
        self.play(
            Transform(f_x, f_t),
            FadeIn(
                t_expression,
                run_time = 2,
                submobject_mode = "lagged_start"
            )
        )
        self.play(Transform(f_x, P_t))
        self.play(
            GrowFromCenter(pop_brace),
            Write(pop_brace.text, run_time = 2)
        )
        self.dither(2)

        self.function = f_x
        self.pop_brace = pop_brace
        self.t_expression = t_expression
        self.mass_function = M_t
        self.mass_brace = mass_brace
开发者ID:crclayton,项目名称:manim,代码行数:50,代码来源:chapter4.py

示例10: show_secant_and_cosecant

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def show_secant_and_cosecant(self):
        sec_group = self.get_line_brace_text("sec")
        csc_group = self.get_line_brace_text("csc")
        sec_line, sec_brace, sec_text = sec_group
        csc_line, csc_brace, csc_text = csc_group

        sec_frac = TexMobject("= \\frac{1}{\\cos(\\theta)}")
        sec_frac.to_corner(UP+LEFT).shift(2*RIGHT)
        csc_frac = TexMobject("= \\frac{1}{\\sin(\\theta)}")
        csc_frac.next_to(sec_frac, DOWN)

        sec_dot, csc_dot = [
            Dot(line.get_end(), color = line.get_color())
            for line in sec_line, csc_line
        ]
        sec_group.add(sec_dot)
        csc_group.add(csc_dot)

        for text, frac in (sec_text, sec_frac), (csc_text, csc_frac):
            frac[-2].highlight(YELLOW)
            frac.scale_in_place(0.7)
            text.save_state()
            text.next_to(frac, LEFT)
            frac.add_to_back(text.copy())
            self.play(
                Write(frac),
                self.pi_creature.change_mode, "erm"
            )
            self.dither()
        self.dither()
        for group in sec_group, csc_group:
            line, brace, text, dot = group
            dot.save_state()
            dot.move_to(text)
            dot.set_fill(opacity = 0)
            self.play(dot.restore)
            self.dither()
            self.play(
                ShowCreation(line),
                GrowFromCenter(brace),
                text.restore,
                self.pi_creature.change_mode, "pondering"
            )
            self.dither()

        mover = VGroup(
            sec_group,
            csc_group,
            self.theta_group,
            self.tangent_line,
        )
        thetas = np.linspace(self.theta_value, self.alt_theta_val, 100)
        targets = []
        for theta in thetas:
            self.theta_value = theta
            new_sec_group = self.get_line_brace_text("sec")
            new_csc_group = self.get_line_brace_text("csc")
            for group in new_sec_group, new_csc_group:
                line = group[0]
                group.add(
                    Dot(line.get_end(), color = line.get_color())
                )
            targets.append(VGroup(
                new_sec_group,
                new_csc_group,
                self.get_theta_group(),
                self.get_tangent_line(),
            ))
        self.play(Succession(
            *[
                Transform(mover, target, rate_func = None)
                for target in targets
            ], 
            run_time = 5, 
            rate_func = there_and_back
        ))
        self.theta_value = thetas[0]

        self.change_mode("confused")
        self.dither(2)

        self.play(*map(FadeOut, [
            sec_group, sec_frac
        ]))
        self.csc_group = csc_group
        self.csc_frac =csc_frac
开发者ID:PythonJedi,项目名称:manim,代码行数:88,代码来源:tattoo.py

示例11: show_tangent_and_cotangent

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def show_tangent_and_cotangent(self):
        tan_group = self.get_line_brace_text("tan")
        cot_group = self.get_line_brace_text("cot")
        tan_text = tan_group[-1]
        cot_text = cot_group[-1]
        line = Line(UP, DOWN).scale(SPACE_HEIGHT)
        line.rotate(self.theta_value)
        line.move_to(self.theta_group[-1])
        line.set_stroke(width = 2)

        sin_tex = "{\\sin(\\theta)}"
        cos_tex = "{\\cos(\\theta)}"
        tan_frac = TexMobject("= \\frac" + sin_tex + cos_tex)
        cot_frac = TexMobject("= \\frac" + cos_tex + sin_tex)
        tan_frac.to_corner(UP+LEFT)
        tan_frac.shift(2*RIGHT)
        cot_frac.next_to(tan_frac, DOWN)


        self.change_mode("pondering")
        for frac, text in (tan_frac, tan_text), (cot_frac, cot_text):
            VGroup(frac[5], frac[-2]).highlight(YELLOW)
            frac.scale_in_place(0.7)
            text.save_state()
            text.next_to(frac, LEFT)
            self.play(Write(VGroup(text, frac)))
            self.dither()
        self.change_mode("confused")
        self.dither()
        self.play(*map(FadeOut, [
            tan_frac, cot_frac, self.sin_group, self.cos_group
        ]))
        self.dither()

        self.play(
            self.theta_group[-1].highlight, YELLOW,
            ShowCreation(line),
            self.pi_creature.change_mode, 'pondering'
        )
        small_lines = VGroup()
        for group in tan_group, cot_group:
            small_line, brace, text = group
            self.play(
                ShowCreation(small_line),
                GrowFromCenter(brace),
                text.restore,
            )
            self.dither()
            small_lines.add(small_line)
        self.play(FadeOut(line), Animation(small_lines))

        mover = VGroup(
            tan_group,
            cot_group,
            self.theta_group,
        )
        thetas = np.linspace(self.theta_value, self.alt_theta_val, 100)
        targets = []
        for theta in thetas:
            self.theta_value = theta
            targets.append(VGroup(
                self.get_line_brace_text("tan"),
                self.get_line_brace_text("cot"),
                self.get_theta_group()
            ))
        self.play(Succession(
            *[
                Transform(mover, target, rate_func = None)
                for target in targets
            ], 
            run_time = 5, 
            rate_func = there_and_back
        ))
        self.theta_value = thetas[0]

        self.change_mode("happy")
        self.dither(2)

        self.tangent_line = self.get_tangent_line()
        self.add(self.tangent_line)
        self.play(*it.chain(*[
            map(FadeOut, [tan_group, cot_group]),
            [Animation(self.theta_group[-1])]
        ]))
开发者ID:PythonJedi,项目名称:manim,代码行数:86,代码来源:tattoo.py

示例12: show_equation

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_corner [as 别名]
    def show_equation(self):
        equation = TexMobject([
            "\\left(\\dfrac{1}{\\phantom{v_air}}\\right)",
            "\\sin(\\theta_1)", 
            "=", 
            "\\left(\\dfrac{1}{\\phantom{v_water}}\\right)",
            "\\sin(\\theta_2)"
        ])
        equation.to_corner(UP+RIGHT)
        frac1, sin1, equals, frac2, sin2 = equation.split()
        v_air, v_water = [
            TexMobject("v_{\\text{%s}}"%s, size = "\\Large")
            for s in "air", "water"
        ]
        v_air.next_to(Point(frac1.get_center()), DOWN)
        v_water.next_to(Point(frac2.get_center()), DOWN)
        frac1.add(v_air)
        frac2.add(v_water)
        f1, f2 = [
            TexMobject("F_%d"%d, size = "\\Large") 
            for d in 1, 2
        ]
        f1.next_to(sin1, LEFT)
        f2.next_to(equals, RIGHT)
        sin2_start = sin2.copy().next_to(f2, RIGHT)
        bar1 = TexMobject("\\dfrac{\\qquad}{\\qquad}")
        bar2 = bar1.copy()
        bar1.next_to(sin1, DOWN)
        bar2.next_to(sin2, DOWN)        
        v_air_copy = v_air.copy().next_to(bar1, DOWN)
        v_water_copy = v_water.copy().next_to(bar2, DOWN)
        bars = Mobject(bar1, bar2)
        new_eq = equals.copy().center().shift(bars.get_center())
        snells = TextMobject("Snell's Law")
        snells.highlight(YELLOW)
        snells.shift(new_eq.get_center()[0]*RIGHT)
        snells.shift(UP)

        anims = []
        for mob in f1, sin1, equals, f2, sin2_start:
            anims.append(ShimmerIn(mob))
        self.play(*anims)
        self.dither()
        for f, frac in (f1, frac1), (f2, frac2):
            target = frac.copy().ingest_submobjects()
            also = []
            if f is f2:
                also.append(Transform(sin2_start, sin2))
                sin2 = sin2_start
            self.play(Transform(f, target), *also)
            self.remove(f)
            self.add(frac)
        self.dither()
        self.play(
            FadeOut(frac1),
            FadeOut(frac2),
            Transform(v_air, v_air_copy),
            Transform(v_water, v_water_copy),
            ShowCreation(bars),
            Transform(equals, new_eq)
        )
        self.dither()
        frac1 = Mobject(sin1, bar1, v_air)
        frac2 = Mobject(sin2, bar2, v_water)
        for frac, vect in (frac1, LEFT), (frac2, RIGHT):
            self.play(ApplyMethod(
                frac.next_to, equals, vect
            ))
        self.dither()
        self.play(ShimmerIn(snells))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:73,代码来源:light.py


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