.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scene/sensitivity.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_sensitivity.py: Zoom Sensitivity ================ For testing zoom sensitivity on various platforms .. GENERATED FROM PYTHON SOURCE LINES 12-50 .. image-sg:: /gallery/scene/images/sphx_glr_sensitivity_001.png :alt: sensitivity :srcset: /gallery/scene/images/sphx_glr_sensitivity_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import vispy.scene from vispy.scene import visuals canvas = vispy.scene.SceneCanvas(keys='interactive', show=True) vb = canvas.central_widget.add_view() vb.camera = 'panzoom' vb.camera.rect = (-10, -10, 20, 20) centers = np.random.normal(size=(50, 2)) pos = np.random.normal(size=(100000, 2), scale=0.2) indexes = np.random.normal(size=100000, loc=centers.shape[0]/2., scale=centers.shape[0]/3.) indexes = np.clip(indexes, 0, centers.shape[0]-1).astype(int) scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis] pos *= scales pos += centers[indexes] scatter = visuals.Markers() scatter.set_gl_state('translucent', depth_test=False) scatter.set_data(pos, edge_width=0, face_color=(1, 1, 1, 0.3), size=5) vb.add(scatter) @canvas.connect def on_key_press(ev): if ev.key.name in '+=': vb.camera.zoom_factor *= 1.1 elif ev.key.name == '-': vb.camera.zoom_factor /= 1.1 print("Zoom factor: %0.4f" % vb.camera.zoom_factor) if __name__ == '__main__': import sys if sys.flags.interactive != 1: vispy.app.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.231 seconds) .. _sphx_glr_download_gallery_scene_sensitivity.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: sensitivity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: sensitivity.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_