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


Python GraphScene.construct方法代码示例

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


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

示例1: construct

# 需要导入模块: from scene import GraphScene [as 别名]
# 或者: from scene.GraphScene import construct [as 别名]
    def construct(self):
        GraphScene.construct(self)
        paths = [(1, 2, 4, 5, 6), (6, 7, 1, 3)]
        non_paths = [[(0, 1), (7, 8), (5, 6)], [(5, 0), (0, 2), (0, 1)]]
        valid_path = TextMobject("Valid \\\\ Path").highlight("green")
        not_a_path = TextMobject("Not a \\\\ Path").highlight("red")
        for mob in valid_path, not_a_path:
            mob.to_edge(UP)
        kwargs = {"run_time": 1.0}
        for path, non_path in zip(paths, non_paths):
            path_lines = Mobject(
                *[
                    Line(self.points[path[i]], self.points[path[i + 1]]).highlight("yellow")
                    for i in range(len(path) - 1)
                ]
            )
            non_path_lines = Mobject(
                *[Line(self.points[pp[0]], self.points[pp[1]]).highlight("yellow") for pp in non_path]
            )

            self.remove(not_a_path)
            self.add(valid_path)
            self.play(ShowCreation(path_lines, **kwargs))
            self.dither(2)
            self.remove(path_lines)

            self.remove(valid_path)
            self.add(not_a_path)
            self.play(ShowCreation(non_path_lines, **kwargs))
            self.dither(2)
            self.remove(non_path_lines)
开发者ID:mherkazandjian,项目名称:manim,代码行数:33,代码来源:eulers_characteristic_formula.py

示例2: construct

# 需要导入模块: from scene import GraphScene [as 别名]
# 或者: from scene.GraphScene import construct [as 别名]
    def construct(self):
        GraphScene.construct(self)
        self.generate_dual_graph()

        self.add(TextMobject("Duality").to_edge(UP))
        self.remove(*self.vertices)
        def special_alpha(t):
            if t > 0.5:
                t = 1 - t
            if t < 0.25:
                return smooth(4*t)
            else:
                return 1
        kwargs = {
            "run_time" : 5.0,
            "rate_func" : special_alpha
        }
        self.play(*[
            Transform(*edge_pair, **kwargs)
            for edge_pair in zip(self.edges, self.dual_edges)
        ] + [
            Transform(
                Mobject(*[
                    self.vertices[index]
                    for index in cycle
                ]),
                dv,
                **kwargs
            )
            for cycle, dv in zip(
                self.graph.region_cycles, 
                self.dual_vertices
            )
        ])
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:37,代码来源:eulers_characteristic_formula.py


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