.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_image_colormap.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_validation_validate_image_colormap.py: Simple Colormap =============== Show an image with a simple colormap. * You should see a square image with 3 equally sized vertical bands. * The bands should be red, green, and blue. .. GENERATED FROM PYTHON SOURCE LINES 10-39 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_image_colormap_001.png :alt: validate image colormap :srcset: /_gallery/validation/images/sphx_glr_validate_image_colormap_001.png :class: sphx-glr-single-img .. code-block:: default # test_example = true import numpy as np from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx canvas = WgpuCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() im = np.repeat(np.linspace(0, 1, 99).reshape(1, -1), 99, 0).astype(np.float32) colormap_data = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], np.float32) colormap = gfx.Texture(colormap_data, dim=1) image = gfx.Image( gfx.Geometry(grid=gfx.Texture(im, dim=2)), gfx.ImageBasicMaterial(clim=(0, 1), map=colormap, map_interpolation="nearest"), ) scene.add(image) camera = gfx.OrthographicCamera() camera.show_rect(0.5, 99.5, 0.5, 99.5) canvas.request_draw(lambda: renderer.render(scene, camera)) if __name__ == "__main__": run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.307 seconds) .. _sphx_glr_download__gallery_validation_validate_image_colormap.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_image_colormap.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: validate_image_colormap.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_