.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_blend_dither.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_blend_dither.py: Validate dither =============== This example draws a series of semitransparent planes using dither mode. .. GENERATED FROM PYTHON SOURCE LINES 7-61 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_blend_dither_001.webp :alt: validate blend dither :srcset: /_gallery/validation/images/sphx_glr_validate_blend_dither_001.webp :class: sphx-glr-single-img .. code-block:: Python from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx import pylinalg as la canvas = RenderCanvas(size=(600, 600)) renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() sphere = gfx.Mesh(gfx.sphere_geometry(10), gfx.MeshPhongMaterial()) geometry = gfx.plane_geometry(50, 50) plane1 = gfx.Mesh( geometry, gfx.MeshBasicMaterial(alpha_mode="dither", color="r", opacity=0.3) ) plane2 = gfx.Mesh( geometry, gfx.MeshBasicMaterial(alpha_mode="dither", color="g", opacity=0.5) ) plane3 = gfx.Mesh( geometry, gfx.MeshBasicMaterial(alpha_mode="dither", color="b", opacity=0.7) ) plane1.local.rotation = la.quat_from_axis_angle((1, 0, 0), 1.571) plane2.local.rotation = la.quat_from_axis_angle((0, 1, 0), 1.571) plane3.local.rotation = la.quat_from_axis_angle((0, 0, 1), 1.571) t = gfx.Text( text="dither", screen_space=True, font_size=20, material=gfx.TextMaterial(aa=True), ) t.local.position = (0, 40, 0) scene.add(plane1, plane2, plane3, sphere, t) scene.add(gfx.AmbientLight(1, 1)) camera = gfx.PerspectiveCamera(70, 16 / 9, depth_range=(0.1, 2000)) camera.local.position = (30, 40, 50) camera.look_at((0, 0, 0)) def animate(): renderer.render(scene, camera) canvas.request_draw(animate) if __name__ == "__main__": print(__doc__) loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.394 seconds) .. _sphx_glr_download__gallery_validation_validate_blend_dither.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: validate_blend_dither.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_blend_dither.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: validate_blend_dither.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_ .. only:: html Interactive example ------------------- Try this example in your browser using Pyodide. Might not work with all examples and all devices. Check the output and your browser's console for details. .. raw:: html