.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_transform.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_transform.py: Validate transforms =================== Apply a variety of transform combinations. .. GENERATED FROM PYTHON SOURCE LINES 7-60 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_transform_001.webp :alt: validate transform :srcset: /_gallery/validation/images/sphx_glr_validate_transform_001.webp :class: sphx-glr-single-img .. code-block:: Python from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx canvas = RenderCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() geometry = gfx.box_geometry(1, 1, 1) material_a = gfx.MeshBasicMaterial( color=(0, 0.5, 0.5), wireframe=True, wireframe_thickness=3 ) material_b = gfx.MeshBasicMaterial(color=(0, 1, 1)) def create_boxes(ttype1, value1, ttype2, value2, ttype3, value3, *, state_basis): box_a = gfx.Mesh(geometry, material_a) box_b = gfx.Group() box_c = gfx.Mesh(geometry, material_b) for box in (box_a, box_b, box_c): box.local.state_basis = state_basis setattr(box_a.local, ttype1, value1) setattr(box_b.local, ttype2, value2) setattr(box_c.local, ttype3, value3) scene.add(box_a.add(box_b.add(box_c))) for i, state_basis in enumerate(["components", "matrix"]): dy = i * 4 for transforms in [ ("position", (0, dy, 0), "position", (0, 1, 0), "scale", (1.0, 1.5, 1.0)), ("position", (2, dy, 0), "scale", (1.0, 1.5, 1.0), "position", (0, 1, 0)), ("position", (4, dy, 0), "position", (0, 1, 0), "euler_z", 0.5), ("position", (6, dy, 0), "euler_z", 0.5, "position", (0, 1, 0)), ("position", (8, dy, 0), "euler_z", 0.5, "scale", (1.0, 1.5, 1.0)), ("position", (10, dy, 0), "scale", (1.0, 1.5, 1.0), "euler_z", 0.5), ]: create_boxes(*transforms, state_basis=state_basis) camera = gfx.OrthographicCamera(5, 5) camera.show_rect(-2, 12, -2, 6) 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.190 seconds) .. _sphx_glr_download__gallery_validation_validate_transform.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: validate_transform.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_transform.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: validate_transform.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