{ "cells": [ { "cell_type": "markdown", "id": "f3a10a5c", "metadata": {}, "source": [ "# Vispy example\n", "\n", "**Note that this example depends on the Vispy library, and that you need a bleeding edge version of Vispy to run this.**\n", "\n", "An example showing how jupyter_rfb is used in Vispy. Note that Vispy implements a subclass of `RemoteFrameBuffer` for this to work." ] }, { "cell_type": "code", "execution_count": 1, "id": "be51c953", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0522fb062b3544a8a782a9a7a0511ec8", "version_major": 2, "version_minor": 0 }, "text/plain": [ "RFBOutputContext()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6b5c6862cae9421594551dd8ec206d86", "version_major": 2, "version_minor": 0 }, "text/html": [ "
snapshot
" ], "text/plain": [ "CanvasBackend(css_height='400px')" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from vispy import scene\n", "from vispy.visuals.transforms import STTransform\n", "\n", "canvas = scene.SceneCanvas(\n", " keys=\"interactive\", bgcolor=\"white\", size=(500, 400), show=True, resizable=True\n", ")\n", "\n", "view = canvas.central_widget.add_view()\n", "view.camera = \"arcball\"\n", "\n", "sphere1 = scene.visuals.Sphere(\n", " radius=1, method=\"latitude\", parent=view.scene, edge_color=\"black\"\n", ")\n", "\n", "sphere2 = scene.visuals.Sphere(\n", " radius=1, method=\"ico\", parent=view.scene, edge_color=\"black\"\n", ")\n", "\n", "sphere3 = scene.visuals.Sphere(\n", " radius=1,\n", " rows=10,\n", " cols=10,\n", " depth=10,\n", " method=\"cube\",\n", " parent=view.scene,\n", " edge_color=\"black\",\n", ")\n", "\n", "sphere1.transform = STTransform(translate=[-2.5, 0, 0])\n", "sphere3.transform = STTransform(translate=[2.5, 0, 0])\n", "\n", "view.camera.set_range(x=[-3, 3])\n", "canvas" ] }, { "cell_type": "code", "execution_count": null, "id": "8601aff2", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.9" } }, "nbformat": 4, "nbformat_minor": 5 }