Python vispy.app.run() Examples
The following are 4
code examples of vispy.app.run().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vispy.app
, or try the search function
.
Example #1
Source File: vispy_draw.py From tyssue with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: userspace.py From p5 with GNU General Public License v3.0 | 5 votes |
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
Example #3
Source File: userspace.py From p5 with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: renderer.py From patch_linemod with BSD 2-Clause "Simplified" License | 4 votes |
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