本文整理汇总了Python中vispy.app.run方法的典型用法代码示例。如果您正苦于以下问题:Python app.run方法的具体用法?Python app.run怎么用?Python app.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vispy.app
的用法示例。
在下文中一共展示了app.run方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sheet_view
# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import run [as 别名]
def sheet_view(sheet, coords=None, interactive=True, **draw_specs_kw):
"""Uses VisPy to display an epithelium
"""
draw_specs = sheet_spec()
spec_updater(draw_specs, draw_specs_kw)
if coords is None:
coords = ["x", "y", "z"]
canvas = scene.SceneCanvas(keys="interactive", show=True, size=(1240, 720))
view = canvas.central_widget.add_view()
view.camera = "turntable"
view.camera.aspect = 1
view.bgcolor = vp.color.Color("#222222")
if draw_specs["edge"]["visible"]:
wire = edge_visual(sheet, coords, **draw_specs["edge"])
view.add(wire)
if draw_specs["face"]["visible"]:
mesh = face_visual(sheet, coords, **draw_specs["face"])
view.add(mesh)
canvas.show()
view.camera.set_range()
if interactive:
app.run()
return canvas, view
示例2: setup
# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import run [as 别名]
def setup():
"""Called to setup initial sketch options.
The `setup()` function is run once when the program starts and is
used to define initial environment options for the sketch.
"""
pass
示例3: save_frame
# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import run [as 别名]
def save_frame(filename="screen.png"):
"""Save a numbered sequence of images whenever the function is run.
Saves a numbered sequence of images, one image each time the
function is run. To save an image that is identical to the display
window, run the function at the end of :meth:`p5.draw` or within
mouse and key events such as :meth:`p5.mouse_pressed` and
:meth:`p5.key_pressed`.
If save_frame() is used without parameters, it will save files as
screen-0000.png, screen-0001.png, and so on. Append a file
extension, to indicate the file format to be used. Image files are
saved to the sketch's folder. Alternatively, the files can be
saved to any location on the computer by using an absolute path
(something that starts with / on Unix and Linux, or a drive letter
on Windows).
:param filename: name (or name with path) of the image file.
(defaults to ``screen.png``)
:type filename: str
"""
# todo: allow setting the frame number in the file name of the
# saved image (instead of using the default sequencing) --abhikpal
# (2018-08-14)
p5.sketch.queue_screenshot(filename)
示例4: render
# 需要导入模块: from vispy import app [as 别名]
# 或者: from vispy.app import run [as 别名]
def render(model, im_size, K, R, t, clip_near=100, clip_far=2000,
surf_color=None, bg_color=(0.0, 0.0, 0.0, 0.0),
ambient_weight=0.1, mode='rgb+depth'):
# Process input data
#---------------------------------------------------------------------------
# Make sure vertices and faces are provided in the model
assert({'pts', 'faces'}.issubset(set(model.keys())))
# Set color of vertices
if not surf_color:
if 'colors' in model.keys():
assert(model['pts'].shape[0] == model['colors'].shape[0])
colors = model['colors']
if colors.max() > 1.0:
colors /= 255.0 # Color values are expected to be in range [0, 1]
else:
colors = np.ones((model['pts'].shape[0], 4), np.float32) * 0.5
else:
colors = np.tile(list(surf_color) + [1.0], [model['pts'].shape[0], 1])
vertices_type = [('a_position', np.float32, 3),
#('a_normal', np.float32, 3),
('a_color', np.float32, colors.shape[1])]
vertices = np.array(list(zip(model['pts'], colors)), vertices_type)
# Rendering
#---------------------------------------------------------------------------
render_rgb = mode in ['rgb', 'rgb+depth']
render_depth = mode in ['depth', 'rgb+depth']
c = _Canvas(vertices, model['faces'], im_size, K, R, t, clip_near, clip_far,
bg_color, ambient_weight, render_rgb, render_depth)
app.run()
#---------------------------------------------------------------------------
if mode == 'rgb':
out = c.rgb
elif mode == 'depth':
out = c.depth
elif mode == 'rgb+depth':
out = c.rgb, c.depth
else:
out = None
print('Error: Unknown rendering mode.')
exit(-1)
c.close()
return out