本文整理汇总了Python中scene.GraphScene类的典型用法代码示例。如果您正苦于以下问题:Python GraphScene类的具体用法?Python GraphScene怎么用?Python GraphScene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GraphScene类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: construct
def construct(self):
time_per_branch = 0.5
text = TextMobject(
"""
In any tree:
$$E + 1 = V$$
"""
)
gs = GraphScene(SampleGraph())
gs.generate_treeified_spanning_tree()
branches = gs.treeified_spanning_tree.to_edge(LEFT).split()
all_dots = [Dot(branches[0].points[0])]
self.add(text, all_dots[0])
for branch in branches:
self.play(ShowCreation(branch), run_time=time_per_branch)
dot = Dot(branch.points[-1])
self.add(dot)
all_dots.append(dot)
self.dither()
self.remove(*all_dots)
self.play(
FadeOut(text),
FadeIn(Mobject(*gs.edges + gs.vertices)),
*[Transform(*pair) for pair in zip(branches, gs.spanning_tree.split())]
)
开发者ID:mherkazandjian,项目名称:manim,代码行数:26,代码来源:eulers_characteristic_formula.py
示例2: GraphWidget
class GraphWidget(QtGui.QGraphicsView):
def __init__(self, index, parent=None):
super(GraphWidget, self).__init__(parent)
self.index = index
self.createWidgets()
self.updateWidgets()
def mouseMoveEvent(self, event):
super(GraphWidget, self).mouseMoveEvent(event)
pt = event.pos()
self.statusBarShowMessage('Coordinate (%2.f, %2.f)' % (pt.x(), pt.y()))
def createWidgets(self):
self.scene = GraphScene(self)
self.scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
self.scene.setSceneRect(-200, -200, 400, 400)
def updateWidgets(self):
self.setObjectName('GraphWidget-%d' % self.index)
self.setScene(self.scene)
self.setRenderHint(QtGui.QPainter.Antialiasing)
self.scale(0.8, 0.8)
self.setMinimumSize(400, 400)
self.setWindowTitle(
QtGui.QApplication.translate('GraphWidget-%d' % self.index,
'Polygon Area',
None,
QtGui.QApplication.UnicodeUTF8))
self.setMouseTracking(True)
def statusBarShowMessage(self, st):
qst = QtCore.QString(st)
mainWindow = QtGui.qApp.mainWindow
mainWindow.statusBar().showMessage(qst)
开发者ID:nycholas,项目名称:polygon-area,代码行数:35,代码来源:graph.py
示例3: construct
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,代码行数:35,代码来源:eulers_characteristic_formula.py
示例4: createWidgets
def createWidgets(self):
self.scene = GraphScene(self)
self.scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
self.scene.setSceneRect(-200, -200, 400, 400)
开发者ID:nycholas,项目名称:polygon-area,代码行数:4,代码来源:graph.py
示例5: __init__
def __init__(self, graph, path, *args, **kwargs):
self.path = path
GraphScene.__init__(self, graph, *args, **kwargs)
开发者ID:mherkazandjian,项目名称:manim,代码行数:3,代码来源:eulers_characteristic_formula.py
注:本文中的scene.GraphScene类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论