.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scene/one_cam_two_scenes.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_scene_one_cam_two_scenes.py: Share Camera Views ================== Demonstrating two scenes that share the same camera view by linking the cameras. .. GENERATED FROM PYTHON SOURCE LINES 15-56 .. image-sg:: /gallery/scene/images/sphx_glr_one_cam_two_scenes_001.png :alt: one cam two scenes :srcset: /gallery/scene/images/sphx_glr_one_cam_two_scenes_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from vispy import app, scene, io canvas = scene.SceneCanvas(keys='interactive') canvas.size = 800, 600 canvas.show() # Create two ViewBoxes, place side-by-side vb1 = scene.widgets.ViewBox(border_color='yellow', parent=canvas.scene) vb2 = scene.widgets.ViewBox(border_color='blue', parent=canvas.scene) # grid = canvas.central_widget.add_grid() grid.padding = 6 grid.add_widget(vb1, 0, 0) grid.add_widget(vb2, 0, 1) # Create the image im1 = io.load_crate().astype('float32') / 255 # Make gray, smooth, and take derivatives: edge enhancement im2 = im1[:, :, 1] im2 = (im2[1:-1, 1:-1] + im2[0:-2, 1:-1] + im2[2:, 1:-1] + im2[1:-1, 0:-2] + im2[1:-1, 2:]) / 5 im2 = 0.5 + (np.abs(im2[0:-2, 1:-1] - im2[1:-1, 1:-1]) + np.abs(im2[1:-1, 0:-2] - im2[1:-1, 1:-1])) image1 = scene.visuals.Image(im1, parent=vb1.scene) image2 = scene.visuals.Image(im2, parent=vb2.scene) # Set 2D camera (PanZoomCamera, TurnTableCamera) vb1.camera, vb2.camera = scene.PanZoomCamera(), scene.PanZoomCamera() vb1.camera.aspect = vb2.camera.aspect = 1 # no auto-scale vb1.camera.link(vb2.camera) # Set the view bounds to show the entire image with some padding vb1.camera.set_range() if __name__ == '__main__': app.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.622 seconds) .. _sphx_glr_download_gallery_scene_one_cam_two_scenes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: one_cam_two_scenes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: one_cam_two_scenes.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_