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


Python VMobject.center方法代码示例

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


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

示例1: construct

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import center [as 别名]
    def construct(self):
        words = map(TextMobject, [
            "Just brushing up",
            "Has yet to take the course",
            "Supplementing course concurrently",
        ])
        students = VMobject(*[
            Randolph(color = c)
            for c in BLUE_D, BLUE_C, BLUE_E
        ])
        modes = ["pondering", "speaking_looking_left", "sassy"]
        students.arrange_submobjects(RIGHT)
        students.scale(0.8)
        students.center().to_edge(DOWN)

        last_word, last_arrow = None, None
        for word, student, mode in zip(words, students.split(), modes):
            word.shift(2*UP)
            arrow = Arrow(word, student)
            if last_word:
                word_anim = Transform(last_word, word)
                arrow_anim = Transform(last_arrow, arrow)
            else:
                word_anim = Write(word, run_time = 1)
                arrow_anim = ShowCreation(arrow, submobject_mode = "one_at_a_time")
                last_word = word
                last_arrow = arrow
            self.play(
                word_anim, arrow_anim,
                ApplyMethod(student.change_mode, mode)
            )
            self.play(Blink(student))
            self.dither()
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:36,代码来源:chapter0.py

示例2: construct

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import center [as 别名]
    def construct(self):
        matrix = Matrix([list("abc"), list("def"), list("ghi")])
        matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR)
        m1 = Matrix([["e", "f"], ["h", "i"]])
        m1.highlight_columns(Y_COLOR, Z_COLOR)
        m2 = Matrix([["d", "f"], ["g", "i"]])
        m2.highlight_columns(X_COLOR, Z_COLOR)
        m3 = Matrix([["d", "e"], ["g", "h"]])
        m3.highlight_columns(X_COLOR, Y_COLOR)

        for m in matrix, m1, m2, m3:
            m.add(get_det_text(m))
        a, b, c = matrix.get_entries().split()[:3]
        parts = it.starmap(VMobject, [
            [matrix], 
            [TexMobject("="), a.copy(), m1], 
            [TexMobject("-"), b.copy(), m2],
            [TexMobject("+"), c.copy(), m3],
        ])
        parts = list(parts)
        for part in parts:
            part.arrange_submobjects(RIGHT, buff = 0.2)
        parts[1].next_to(parts[0], RIGHT)
        parts[2].next_to(parts[1], DOWN, aligned_edge = LEFT)
        parts[3].next_to(parts[2], DOWN, aligned_edge = LEFT)
        everyone = VMobject(*parts)
        everyone.center().to_edge(UP)
        for part in parts:
            self.play(Write(part))
        self.dither(2)
开发者ID:xhrwang,项目名称:manim,代码行数:32,代码来源:chapter5.py

示例3: handle_mathy

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import center [as 别名]
    def handle_mathy(self, creatures):
        self.fade_all_but(creatures, 2)
        physy, compy, mathy = creatures

        v_color = YELLOW 
        w_color = BLUE
        sum_color = GREEN

        v_arrow = Vector([1, 1])
        w_arrow = Vector([2, 1])
        w_arrow.shift(v_arrow.get_end())
        sum_arrow = Vector(w_arrow.get_end())
        arrows = VMobject(v_arrow, w_arrow, sum_arrow)
        arrows.scale(0.7)
        arrows.to_edge(LEFT, buff = 2)

        v_array = matrix_to_mobject([3, -5])
        w_array = matrix_to_mobject([2, 1])
        sum_array = matrix_to_mobject(["3+2", "-5+1"])
        arrays = VMobject(
            v_array, TexMobject("+"), w_array, TexMobject("="), sum_array
        )
        arrays.arrange_submobjects(RIGHT)
        arrays.scale(0.75)
        arrays.to_edge(RIGHT).shift(UP)

        v_sym = TexMobject("\\vec{\\textbf{v}}")
        w_sym = TexMobject("\\vec{\\textbf{w}}")
        syms = VMobject(v_sym, TexMobject("+"), w_sym)
        syms.arrange_submobjects(RIGHT)
        syms.center().shift(2*UP)

        statement = TextMobject("We'll ignore him \\\\ for now")
        statement.highlight(PINK)
        statement.scale_to_fit_width(arrays.get_width())
        statement.next_to(arrays, DOWN, buff = 1.5)
        circle = Circle()
        circle.shift(syms.get_bottom())

        VMobject(v_arrow, v_array, v_sym).highlight(v_color)
        VMobject(w_arrow, w_array, w_sym).highlight(w_color)
        VMobject(sum_arrow, sum_array).highlight(sum_color)

        self.play(
            Write(syms), Write(arrays),
            ShowCreation(arrows, submobject_mode = "one_at_a_time"),
            ApplyMethod(mathy.change_mode, "pondering"),
            run_time = 2
        )
        self.play(Blink(mathy))
        self.add_scaling(arrows, syms, arrays)
        self.play(Write(statement))
        self.play(ApplyMethod(mathy.change_mode, "sad"))
        self.dither()
        self.play(
            ShowCreation(circle),
            ApplyMethod(mathy.change_mode, "plain")
        )
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:61,代码来源:chapter1.py


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