.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/cube_offscreen.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_cube_offscreen.py: Cube offscreen -------------- Render a wgpu example offscreen, and display as an image. .. GENERATED FROM PYTHON SOURCE LINES 7-27 .. code-block:: Python import os import tempfile import webbrowser import imageio.v3 as iio from rendercanvas.offscreen import RenderCanvas from rendercanvas.utils.cube import setup_drawing_sync canvas = RenderCanvas(size=(640, 480), pixel_ratio=2) draw_frame = setup_drawing_sync(canvas) canvas.request_draw(draw_frame) image = canvas.draw() assert image.shape == (960, 1280, 4) filename = os.path.join(tempfile.gettempdir(), "rendercanvasexample.png") iio.imwrite(filename, image) webbrowser.open("file://" + filename) .. _sphx_glr_download_gallery_cube_offscreen.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cube_offscreen.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cube_offscreen.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cube_offscreen.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_