.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_blend_additive.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_additive.py: Additive Blending ================= This example draws overlapping circles of reference colors with additive blending. .. GENERATED FROM PYTHON SOURCE LINES 7-48 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_blend_additive_001.webp :alt: validate blend additive :srcset: /_gallery/validation/images/sphx_glr_validate_blend_additive_001.webp :class: sphx-glr-single-img .. code-block:: Python import numpy as np from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx colors = ["#ff0000", "#00ff00", "#0000ff"] distance_from_center = 0.5 canvas = RenderCanvas() renderer = gfx.WgpuRenderer(canvas, gamma_correction=1.0) camera = gfx.OrthographicCamera() camera.show_rect(-2, 2, -2, 2) scene = gfx.Scene() plane = gfx.sphere_geometry(height_segments=64) N = len(colors) initial_angle = np.pi / 2 for i, color in enumerate(colors): angle = -2 * np.pi * i / N + initial_angle x = distance_from_center * np.cos(angle) y = distance_from_center * np.sin(angle) m = gfx.Mesh( plane, gfx.MeshBasicMaterial( color=color, alpha_mode="add", ), ) m.local.x = x m.local.y = y scene.add(m) canvas.request_draw(lambda: renderer.render(scene, camera)) if __name__ == "__main__": print(__doc__) loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.189 seconds) .. _sphx_glr_download__gallery_validation_validate_blend_additive.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_additive.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_blend_additive.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: validate_blend_additive.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