From 7bcbea9dfb367b79fc1e1f8bda4c8fc060bec242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 9 Nov 2022 19:39:03 +0100 Subject: [PATCH 01/54] get a basic gallery running --- .gitignore | 1 + docs/conf.py | 6 ++++++ docs/docs_requirements.txt | 2 ++ docs/index.rst | 1 + examples/README.rst | 2 ++ examples/integration_qt.py | 4 ++++ examples/points_basic.py | 5 +++++ examples/text_with_qt.py | 4 ++++ 8 files changed, 25 insertions(+) create mode 100644 examples/README.rst diff --git a/.gitignore b/.gitignore index 90b03461d..62958aea3 100644 --- a/.gitignore +++ b/.gitignore @@ -77,6 +77,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/_gallery # PyBuilder target/ diff --git a/docs/conf.py b/docs/conf.py index 3738da210..3c5aa7189 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,6 +53,7 @@ def _check_objects_are_documented(): extensions = [ "sphinx.ext.autodoc", "sphinx.ext.napoleon", + "sphinx_gallery.gen_gallery", # "nbsphinx", ] @@ -64,6 +65,11 @@ def _check_objects_are_documented(): # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] +sphinx_gallery_conf = { + 'examples_dirs': '../examples', + 'gallery_dirs': '_gallery', +} + # -- Options for HTML output ------------------------------------------------- diff --git a/docs/docs_requirements.txt b/docs/docs_requirements.txt index 12dda3be0..d361288b4 100644 --- a/docs/docs_requirements.txt +++ b/docs/docs_requirements.txt @@ -2,3 +2,5 @@ sphinx numpy wgpu jinja2 +sphinx-gallery + diff --git a/docs/index.rst b/docs/index.rst index 9cbba8db3..3ac84b6f5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,6 +11,7 @@ Contents :maxdepth: 2 Guide + Gallery <_gallery/index.rst> Reference Writing shaders diff --git a/examples/README.rst b/examples/README.rst new file mode 100644 index 000000000..b3250789a --- /dev/null +++ b/examples/README.rst @@ -0,0 +1,2 @@ +Examples that use pygfx +======================= diff --git a/examples/integration_qt.py b/examples/integration_qt.py index a9fc8e27a..3553f9ed4 100644 --- a/examples/integration_qt.py +++ b/examples/integration_qt.py @@ -1,5 +1,9 @@ # run_example = false +""" +Integrate pygfx in Qt +""" + import random from PySide6 import QtWidgets diff --git a/examples/points_basic.py b/examples/points_basic.py index e3fcb0850..6864c4845 100644 --- a/examples/points_basic.py +++ b/examples/points_basic.py @@ -1,3 +1,8 @@ +""" +Render Points +""" + + import numpy as np from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/text_with_qt.py b/examples/text_with_qt.py index 73e2945ce..044132b63 100644 --- a/examples/text_with_qt.py +++ b/examples/text_with_qt.py @@ -1,5 +1,9 @@ # run_example = false +""" +Render Text with Qt +""" + import numpy as np import pygfx as gfx From 06bc73ee7416623d1addc0cfa3a3009c16900858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 9 Nov 2022 21:30:57 +0100 Subject: [PATCH 02/54] make tests pick up subfolders --- examples/introductory/README.rst | 1 + examples/{cube.py => introductory/plot_cube.py} | 6 +++++- examples/tests/testutils.py | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 examples/introductory/README.rst rename examples/{cube.py => introductory/plot_cube.py} (81%) diff --git a/examples/introductory/README.rst b/examples/introductory/README.rst new file mode 100644 index 000000000..dbbeed995 --- /dev/null +++ b/examples/introductory/README.rst @@ -0,0 +1 @@ +.. rubric:: Introductory Examples diff --git a/examples/cube.py b/examples/introductory/plot_cube.py similarity index 81% rename from examples/cube.py rename to examples/introductory/plot_cube.py index 862a98953..e22c68021 100644 --- a/examples/cube.py +++ b/examples/introductory/plot_cube.py @@ -1,5 +1,9 @@ """ -Example showing a single geometric cube. +Hello World +=========== + +In this example, we will have a look the render engine equivalent of a hello +world example: Rendering a 3D Cube on screen. """ from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/tests/testutils.py b/examples/tests/testutils.py index 06d3eb0f8..1f452e007 100644 --- a/examples/tests/testutils.py +++ b/examples/tests/testutils.py @@ -5,13 +5,17 @@ from pathlib import Path import subprocess import sys +from itertools import chain -ROOT = Path(__file__).parent.parent.parent # repo root +ROOT = Path(__file__).parents[2] # repo root examples_dir = ROOT / "examples" screenshots_dir = examples_dir / "screenshots" diffs_dir = screenshots_dir / "diffs" +# examples live in themed sub-folders +example_globs = ["*.py", "introductory/*.py", "feature_demo/*.py", "validation/*.py"] + def wgpu_backend_endswith(query): """ @@ -40,7 +44,7 @@ def wgpu_backend_endswith(query): def find_examples(query=None, negative_query=None, return_stems=False): result = [] - for example_path in examples_dir.glob("*.py"): + for example_path in chain(*(examples_dir.glob(x) for x in example_globs)): example_code = example_path.read_text() query_match = query is None or query in example_code negative_query_match = ( From 050212a67ab85cdf6c609218f2180aacd3548adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 9 Nov 2022 22:19:24 +0100 Subject: [PATCH 03/54] add pgfx scraper for gallery (temporarily in root) --- pygfx/__init__.py | 2 ++ pygfx/scraper.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pygfx/scraper.py diff --git a/pygfx/__init__.py b/pygfx/__init__.py index cf4130693..7966032f1 100644 --- a/pygfx/__init__.py +++ b/pygfx/__init__.py @@ -18,6 +18,8 @@ from .utils.viewport import Viewport from .utils import cm, logger +from .scraper import _get_sg_image_scraper + __version__ = "0.1.9" version_info = tuple(map(int, __version__.split("."))) diff --git a/pygfx/scraper.py b/pygfx/scraper.py new file mode 100644 index 000000000..3e376532d --- /dev/null +++ b/pygfx/scraper.py @@ -0,0 +1,48 @@ +import imageio.v3 as iio +import pygfx as gfx +from sphinx_gallery.scrapers import figure_rst +from wgpu.gui.offscreen import WgpuCanvas, run + + +def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): + """Scrape pygfx images and animations + + Parameters + ---------- + block : tuple + A tuple containing the (label, content, line_number) of the block. + block_vars : dict + Dict of block variables. + gallery_conf : dict + Contains the configuration of Sphinx-Gallery + **kwargs : dict + Additional keyword arguments to pass to + :meth:`~matplotlib.figure.Figure.savefig`, e.g. ``format='svg'``. + The ``format`` kwarg in particular is used to set the file extension + of the output file (currently only 'png', 'jpg', and 'svg' are + supported). + + Returns + ------- + rst : str + The ReSTructuredText that will be rendered to HTML containing + the images. This is often produced by :func:`figure_rst`. + """ + + current_scenes = [] + for var in block_vars["example_globals"].values(): + if isinstance(var, gfx.Scene): + current_scenes.append(var) + + if len(current_scenes) == 0: + return '' # nothing to do + + + + print("") + + return figure_rst([], gallery_conf['src_dir']) + + +def _get_sg_image_scraper(): + return pygfx_scraper \ No newline at end of file From bbcb42e8ba56ccbe32b64c3cd36b0cadfe7ec699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 9 Nov 2022 22:19:46 +0100 Subject: [PATCH 04/54] modify cube example to create scraper --- docs/conf.py | 5 +++-- examples/introductory/plot_cube.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3c5aa7189..e4a3ef4b0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -66,8 +66,9 @@ def _check_objects_are_documented(): exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] sphinx_gallery_conf = { - 'examples_dirs': '../examples', - 'gallery_dirs': '_gallery', + "examples_dirs": "../examples", + "gallery_dirs": "_gallery", + "image_scrapers": ("pygfx",), } diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index e22c68021..b5aff2f07 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -19,6 +19,8 @@ ) scene.add(cube) +# %% +# make a second block camera = gfx.PerspectiveCamera(70, 16 / 9) camera.position.z = 400 From 0be179736ddbdd5ed2196a0429a9bd8f4c535170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Thu, 10 Nov 2022 08:43:45 +0100 Subject: [PATCH 05/54] avoid freezing during example generation --- docs/conf.py | 4 ++++ examples/introductory/plot_cube.py | 2 +- pygfx/scraper.py | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index e4a3ef4b0..b1dabf0de 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,6 +7,10 @@ ROOT_DIR = os.path.abspath(os.path.join(__file__, "..", "..")) sys.path.insert(0, ROOT_DIR) +# Avoid freezing examples +os.environ["WGPU_FORCE_OFFSCREEN"] = "true" + + import pygfx # noqa: E402 diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index b5aff2f07..47b66054e 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -20,7 +20,7 @@ scene.add(cube) # %% -# make a second block +# Bring it to life. camera = gfx.PerspectiveCamera(70, 16 / 9) camera.position.z = 400 diff --git a/pygfx/scraper.py b/pygfx/scraper.py index 3e376532d..90faf6612 100644 --- a/pygfx/scraper.py +++ b/pygfx/scraper.py @@ -29,19 +29,27 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): the images. This is often produced by :func:`figure_rst`. """ - current_scenes = [] + current_scene = None + current_camera = None for var in block_vars["example_globals"].values(): if isinstance(var, gfx.Scene): - current_scenes.append(var) + current_scene = var - if len(current_scenes) == 0: + if isinstance(var, gfx.Camera): + current_camera = var + + + if current_scene is None or current_camera is None: return '' # nothing to do + renderer = gfx.WgpuRenderer(WgpuCanvas()) + renderer.render(current_scene, current_camera) + path_generator = block_vars["image_path_iterator"] + img_path = next(path_generator) + iio.imwrite(img_path, renderer.snapshot()) - print("") - - return figure_rst([], gallery_conf['src_dir']) + return figure_rst([img_path], gallery_conf['src_dir']) def _get_sg_image_scraper(): From 6986c9e2afd0eabc04deef4aab0eaf868293c70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Thu, 10 Nov 2022 19:18:50 +0100 Subject: [PATCH 06/54] start converting examples --- docs/conf.py | 9 +++++++++ examples/feature_demo/README.rst | 1 + .../plot_geometry_klein_bottle.py} | 3 +++ .../plot_clipping_planes.py} | 3 +++ examples/introductory/plot_cube.py | 6 ++---- 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 examples/feature_demo/README.rst rename examples/{geometry_klein_bottle.py => feature_demo/plot_geometry_klein_bottle.py} (94%) rename examples/{clipping_planes.py => introductory/plot_clipping_planes.py} (97%) diff --git a/docs/conf.py b/docs/conf.py index b1dabf0de..3a72b9900 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,6 +2,7 @@ import os import sys +from sphinx_gallery.sorting import ExplicitOrder ROOT_DIR = os.path.abspath(os.path.join(__file__, "..", "..")) @@ -72,7 +73,15 @@ def _check_objects_are_documented(): sphinx_gallery_conf = { "examples_dirs": "../examples", "gallery_dirs": "_gallery", + "backreferences_dir": "_gallery/backreferences", + "doc_module": ("pygfx",), "image_scrapers": ("pygfx",), + "subsection_order": ExplicitOrder( + [ + "../examples/introductory", + "../examples/feature_demo", + ] + ), } diff --git a/examples/feature_demo/README.rst b/examples/feature_demo/README.rst new file mode 100644 index 000000000..c83bf3372 --- /dev/null +++ b/examples/feature_demo/README.rst @@ -0,0 +1 @@ +.. rubric:: Feature Examples diff --git a/examples/geometry_klein_bottle.py b/examples/feature_demo/plot_geometry_klein_bottle.py similarity index 94% rename from examples/geometry_klein_bottle.py rename to examples/feature_demo/plot_geometry_klein_bottle.py index b44d79904..43d784a95 100644 --- a/examples/geometry_klein_bottle.py +++ b/examples/feature_demo/plot_geometry_klein_bottle.py @@ -1,4 +1,7 @@ """ +Klein Bottle Geometry +===================== + Example showing a Klein Bottle. """ diff --git a/examples/clipping_planes.py b/examples/introductory/plot_clipping_planes.py similarity index 97% rename from examples/clipping_planes.py rename to examples/introductory/plot_clipping_planes.py index 1bff200bb..f294c6c04 100644 --- a/examples/clipping_planes.py +++ b/examples/introductory/plot_clipping_planes.py @@ -1,4 +1,7 @@ """ +Clipping Planes +=============== + Example demonstrating clipping planes on a mesh. """ diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index 47b66054e..5a1f26806 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -2,8 +2,8 @@ Hello World =========== -In this example, we will have a look the render engine equivalent of a hello -world example: Rendering a 3D Cube on screen. +In this example shows how to do the rendering world's hello world: Show a 3D +Cube on screen. """ from wgpu.gui.auto import WgpuCanvas, run @@ -19,8 +19,6 @@ ) scene.add(cube) -# %% -# Bring it to life. camera = gfx.PerspectiveCamera(70, 16 / 9) camera.position.z = 400 From 76904f3cd2d9fcc15d4bd2a60322ef4a00eb6bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Thu, 10 Nov 2022 22:32:39 +0100 Subject: [PATCH 07/54] convert some examples to sphinx gallery items --- .../plot_collection_line.py} | 3 +++ .../plot_colormap_channels.py} | 3 +++ .../{colormap_image.py => feature_demo/plot_colormap_image.py} | 3 +++ .../{colormap_mesh.py => feature_demo/plot_colormap_mesh.py} | 3 +++ .../{custom_object1.py => feature_demo/plot_custom_object1.py} | 3 +++ .../{custom_object2.py => feature_demo/plot_custom_object2.py} | 3 +++ .../{custom_object3.py => feature_demo/plot_custom_object3.py} | 3 +++ examples/{cylinder.py => feature_demo/plot_cylinder.py} | 3 +++ .../plot_flat_shaded_torus.py} | 3 +++ .../{geometry_cubes.py => feature_demo/plot_geometry_cubes.py} | 3 +++ .../{geometry_image.py => feature_demo/plot_geometry_image.py} | 3 +++ .../{geometry_plane.py => feature_demo/plot_geometry_plane.py} | 3 +++ .../plot_geometry_polyhedron.py} | 3 +++ .../plot_geometry_polyhedron_subdivisions.py} | 3 +++ .../plot_geometry_torus_knot.py} | 3 +++ .../{helpers_gizmo.py => feature_demo/plot_helpers_gizmo.py} | 3 +++ .../plot_image_click_events.py} | 3 +++ .../plot_image_plus_points.py} | 3 +++ .../plot_instancing_mesh.py} | 3 +++ .../{hello_triangle.py => introductory/plot_hello_triangle.py} | 3 +++ 20 files changed, 60 insertions(+) rename examples/{collection_line.py => feature_demo/plot_collection_line.py} (96%) rename examples/{colormap_channels.py => feature_demo/plot_colormap_channels.py} (98%) rename examples/{colormap_image.py => feature_demo/plot_colormap_image.py} (98%) rename examples/{colormap_mesh.py => feature_demo/plot_colormap_mesh.py} (99%) rename examples/{custom_object1.py => feature_demo/plot_custom_object1.py} (98%) rename examples/{custom_object2.py => feature_demo/plot_custom_object2.py} (98%) rename examples/{custom_object3.py => feature_demo/plot_custom_object3.py} (99%) rename examples/{cylinder.py => feature_demo/plot_cylinder.py} (98%) rename examples/{flat_shaded_torus.py => feature_demo/plot_flat_shaded_torus.py} (96%) rename examples/{geometry_cubes.py => feature_demo/plot_geometry_cubes.py} (97%) rename examples/{geometry_image.py => feature_demo/plot_geometry_image.py} (94%) rename examples/{geometry_plane.py => feature_demo/plot_geometry_plane.py} (97%) rename examples/{geometry_polyhedron.py => feature_demo/plot_geometry_polyhedron.py} (96%) rename examples/{geometry_polyhedron_subdivisions.py => feature_demo/plot_geometry_polyhedron_subdivisions.py} (95%) rename examples/{geometry_torus_knot.py => feature_demo/plot_geometry_torus_knot.py} (97%) rename examples/{helpers_gizmo.py => feature_demo/plot_helpers_gizmo.py} (94%) rename examples/{image_click_events.py => feature_demo/plot_image_click_events.py} (98%) rename examples/{image_plus_points.py => feature_demo/plot_image_plus_points.py} (94%) rename examples/{instancing_mesh.py => feature_demo/plot_instancing_mesh.py} (98%) rename examples/{hello_triangle.py => introductory/plot_hello_triangle.py} (94%) diff --git a/examples/collection_line.py b/examples/feature_demo/plot_collection_line.py similarity index 96% rename from examples/collection_line.py rename to examples/feature_demo/plot_collection_line.py index 7178e8397..e698b402e 100644 --- a/examples/collection_line.py +++ b/examples/feature_demo/plot_collection_line.py @@ -1,4 +1,7 @@ """ +Peformance of drawing many Lines +================================ + Display a lot of line objects. Because of the architecture of wgpu, this is still performant. """ diff --git a/examples/colormap_channels.py b/examples/feature_demo/plot_colormap_channels.py similarity index 98% rename from examples/colormap_channels.py rename to examples/feature_demo/plot_colormap_channels.py index 00e1a28e7..87673450a 100644 --- a/examples/colormap_channels.py +++ b/examples/feature_demo/plot_colormap_channels.py @@ -1,4 +1,7 @@ """ +Colormap Channels +================= + Example demonstrating colormaps in 4 modes: grayscale, gray+alpha, RGB, RGBA. """ diff --git a/examples/colormap_image.py b/examples/feature_demo/plot_colormap_image.py similarity index 98% rename from examples/colormap_image.py rename to examples/feature_demo/plot_colormap_image.py index 6a5ab0988..f2727c1b3 100644 --- a/examples/colormap_image.py +++ b/examples/feature_demo/plot_colormap_image.py @@ -1,4 +1,7 @@ """ +Colormap Image +============== + Example demonstrating different colormap dimensions on an image. """ diff --git a/examples/colormap_mesh.py b/examples/feature_demo/plot_colormap_mesh.py similarity index 99% rename from examples/colormap_mesh.py rename to examples/feature_demo/plot_colormap_mesh.py index 1a7197bde..ab7736218 100644 --- a/examples/colormap_mesh.py +++ b/examples/feature_demo/plot_colormap_mesh.py @@ -1,4 +1,7 @@ """ +Colormap Mesh +============= + Example demonstrating different colormap dimensions on a mesh, and per-vertex colors as a bonus. diff --git a/examples/custom_object1.py b/examples/feature_demo/plot_custom_object1.py similarity index 98% rename from examples/custom_object1.py rename to examples/feature_demo/plot_custom_object1.py index cd3d5aa28..58ab6e176 100644 --- a/examples/custom_object1.py +++ b/examples/feature_demo/plot_custom_object1.py @@ -1,4 +1,7 @@ """ +Minimal Custom Object +===================== + Example that implements a minimal custom object and renders it. This example simply draws a triangle at the bottomleft of the screen. diff --git a/examples/custom_object2.py b/examples/feature_demo/plot_custom_object2.py similarity index 98% rename from examples/custom_object2.py rename to examples/feature_demo/plot_custom_object2.py index 74dc75367..3f622036b 100644 --- a/examples/custom_object2.py +++ b/examples/feature_demo/plot_custom_object2.py @@ -1,4 +1,7 @@ """ +Simple Custom Object +==================== + Example that implements a simple custom object and renders it. This example draws a triangle at the appropriate position; the object's diff --git a/examples/custom_object3.py b/examples/feature_demo/plot_custom_object3.py similarity index 99% rename from examples/custom_object3.py rename to examples/feature_demo/plot_custom_object3.py index 074a8acfb..0db1fd752 100644 --- a/examples/custom_object3.py +++ b/examples/feature_demo/plot_custom_object3.py @@ -1,4 +1,7 @@ """ +Custom Object +============= + Example that implements a custom object and renders it. This example draws multiple triangles. This is more or a full-fledged object. diff --git a/examples/cylinder.py b/examples/feature_demo/plot_cylinder.py similarity index 98% rename from examples/cylinder.py rename to examples/feature_demo/plot_cylinder.py index 99bb18a94..4e332e26f 100644 --- a/examples/cylinder.py +++ b/examples/feature_demo/plot_cylinder.py @@ -1,4 +1,7 @@ """ +Types of Cylinders +================== + Example showing different types of geometric cylinders. """ diff --git a/examples/flat_shaded_torus.py b/examples/feature_demo/plot_flat_shaded_torus.py similarity index 96% rename from examples/flat_shaded_torus.py rename to examples/feature_demo/plot_flat_shaded_torus.py index 508d2afd0..0e38f2c35 100644 --- a/examples/flat_shaded_torus.py +++ b/examples/feature_demo/plot_flat_shaded_torus.py @@ -1,4 +1,7 @@ """ +Flat Shading +============ + Example showing a Torus knot, using flat shading. """ diff --git a/examples/geometry_cubes.py b/examples/feature_demo/plot_geometry_cubes.py similarity index 97% rename from examples/geometry_cubes.py rename to examples/feature_demo/plot_geometry_cubes.py index 398948cf7..8784a0935 100644 --- a/examples/geometry_cubes.py +++ b/examples/feature_demo/plot_geometry_cubes.py @@ -1,4 +1,7 @@ """ +Geometry Cubes +============== + Example showing multiple rotating cubes. This also tests the depth buffer. """ diff --git a/examples/geometry_image.py b/examples/feature_demo/plot_geometry_image.py similarity index 94% rename from examples/geometry_image.py rename to examples/feature_demo/plot_geometry_image.py index 8142f38ac..e2167c0ca 100644 --- a/examples/geometry_image.py +++ b/examples/feature_demo/plot_geometry_image.py @@ -1,4 +1,7 @@ """ +Geometry Image +============== + Show an image. """ diff --git a/examples/geometry_plane.py b/examples/feature_demo/plot_geometry_plane.py similarity index 97% rename from examples/geometry_plane.py rename to examples/feature_demo/plot_geometry_plane.py index cc9de4de0..f7d1aedd2 100644 --- a/examples/geometry_plane.py +++ b/examples/feature_demo/plot_geometry_plane.py @@ -1,4 +1,7 @@ """ +Geometry Plane +============== + Use a plane geometry to show a texture, which is continuously updated to show video. """ diff --git a/examples/geometry_polyhedron.py b/examples/feature_demo/plot_geometry_polyhedron.py similarity index 96% rename from examples/geometry_polyhedron.py rename to examples/feature_demo/plot_geometry_polyhedron.py index f6d436881..721e82a3a 100644 --- a/examples/geometry_polyhedron.py +++ b/examples/feature_demo/plot_geometry_polyhedron.py @@ -1,4 +1,7 @@ """ +Rotating Polyhedra +================== + Example showing multiple rotating polyhedrons. """ diff --git a/examples/geometry_polyhedron_subdivisions.py b/examples/feature_demo/plot_geometry_polyhedron_subdivisions.py similarity index 95% rename from examples/geometry_polyhedron_subdivisions.py rename to examples/feature_demo/plot_geometry_polyhedron_subdivisions.py index 7e38b5754..539fa497c 100644 --- a/examples/geometry_polyhedron_subdivisions.py +++ b/examples/feature_demo/plot_geometry_polyhedron_subdivisions.py @@ -1,4 +1,7 @@ """ +Subdivision +=========== + Example showing subdivided polyhedrons. """ diff --git a/examples/geometry_torus_knot.py b/examples/feature_demo/plot_geometry_torus_knot.py similarity index 97% rename from examples/geometry_torus_knot.py rename to examples/feature_demo/plot_geometry_torus_knot.py index 52d4d2a21..684b70581 100644 --- a/examples/geometry_torus_knot.py +++ b/examples/feature_demo/plot_geometry_torus_knot.py @@ -1,4 +1,7 @@ """ +Torus knot +========== + Example showing a Torus knot, with a texture and lighting. """ diff --git a/examples/helpers_gizmo.py b/examples/feature_demo/plot_helpers_gizmo.py similarity index 94% rename from examples/helpers_gizmo.py rename to examples/feature_demo/plot_helpers_gizmo.py index e42154d14..ddcca87e7 100644 --- a/examples/helpers_gizmo.py +++ b/examples/feature_demo/plot_helpers_gizmo.py @@ -1,4 +1,7 @@ """ +Gizmo to transform world objects +================================ + Example to demonstrate the Gizmo that can be used to transform world objects. Click the center sphere to toggle between object-space, world-space, and screen-space. """ diff --git a/examples/image_click_events.py b/examples/feature_demo/plot_image_click_events.py similarity index 98% rename from examples/image_click_events.py rename to examples/feature_demo/plot_image_click_events.py index b00cf70bf..dc0cd874a 100644 --- a/examples/image_click_events.py +++ b/examples/feature_demo/plot_image_click_events.py @@ -1,4 +1,7 @@ """ +Image Click Events +================== + Show an image and print the x, y image data coordinates for click events. """ diff --git a/examples/image_plus_points.py b/examples/feature_demo/plot_image_plus_points.py similarity index 94% rename from examples/image_plus_points.py rename to examples/feature_demo/plot_image_plus_points.py index c402beae2..571d50deb 100644 --- a/examples/image_plus_points.py +++ b/examples/feature_demo/plot_image_plus_points.py @@ -1,4 +1,7 @@ """ +Image with Points Overlaid +========================== + Show an image with points overlaid. """ diff --git a/examples/instancing_mesh.py b/examples/feature_demo/plot_instancing_mesh.py similarity index 98% rename from examples/instancing_mesh.py rename to examples/feature_demo/plot_instancing_mesh.py index 60e478625..54a24ab55 100644 --- a/examples/instancing_mesh.py +++ b/examples/feature_demo/plot_instancing_mesh.py @@ -1,4 +1,7 @@ """ +Instancing +========== + Example rendering the same mesh object multiple times, using instancing. """ diff --git a/examples/hello_triangle.py b/examples/introductory/plot_hello_triangle.py similarity index 94% rename from examples/hello_triangle.py rename to examples/introductory/plot_hello_triangle.py index 68e63f188..7f0ae4f5a 100644 --- a/examples/hello_triangle.py +++ b/examples/introductory/plot_hello_triangle.py @@ -1,4 +1,7 @@ """ +Render a Triangle +================= + Replicating the WGPU triangle example, but with about 10x less code. """ From 341071456c8d891386c0f8941cb6c6172d12e0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 11 Nov 2022 13:36:31 +0100 Subject: [PATCH 08/54] rewrite more examples --- .../plot_light_directional_shadow.py} | 12 ++++++++---- .../plot_light_shadow.py} | 8 ++++++-- .../plot_light_spotlight_shadows.py} | 5 +++++ .../plot_light_spotlights.py} | 5 +++++ .../plot_line_basic.py} | 4 ++++ .../plot_line_performance.py} | 3 +++ .../plot_line_segments.py} | 4 ++++ .../plot_line_thick.py} | 3 +++ .../plot_manual_matrix_update.py} | 4 ++++ .../plot_mesh_depth_material.py} | 3 +++ .../plot_mesh_slice.py} | 3 +++ .../plot_multi_select.py} | 4 ++++ .../plot_multi_slice1.py} | 3 +++ .../plot_multi_slice2.py} | 4 ++++ .../plot_panzoom_camera.py} | 3 +++ examples/{pbr.py => feature_demo/plot_pbr.py} | 4 ++++ examples/{pbr2.py => feature_demo/plot_pbr2.py} | 8 ++++++-- .../plot_physical_color.py} | 4 ++++ .../plot_picking_color.py} | 3 +++ .../plot_picking_mesh.py} | 3 +++ .../plot_picking_points.py} | 3 +++ .../plot_post_processing1.py} | 4 ++++ .../plot_post_processing2.py} | 3 +++ .../plot_light_basic.py} | 4 ++++ .../plot_object_bounding_box.py} | 3 +++ .../{offscreen.py => introductory/plot_offscreen.py} | 3 +++ .../plot_orbit_camera.py} | 3 +++ examples/{ => introductory}/points_basic.py | 4 ++++ examples/light_view.py | 3 +++ 29 files changed, 112 insertions(+), 8 deletions(-) rename examples/{light_directional_shadow.py => feature_demo/plot_light_directional_shadow.py} (83%) rename examples/{light_shadow.py => feature_demo/plot_light_shadow.py} (94%) rename examples/{light_spotlight_shadows.py => feature_demo/plot_light_spotlight_shadows.py} (99%) rename examples/{light_spotlights.py => feature_demo/plot_light_spotlights.py} (99%) rename examples/{line_basic.py => feature_demo/plot_line_basic.py} (97%) rename examples/{line_performance.py => feature_demo/plot_line_performance.py} (93%) rename examples/{line_segments.py => feature_demo/plot_line_segments.py} (96%) rename examples/{line_thick.py => feature_demo/plot_line_thick.py} (97%) rename examples/{manual_matrix_update.py => feature_demo/plot_manual_matrix_update.py} (94%) rename examples/{mesh_depth_material.py => feature_demo/plot_mesh_depth_material.py} (99%) rename examples/{mesh_slice.py => feature_demo/plot_mesh_slice.py} (97%) rename examples/{multi_select.py => feature_demo/plot_multi_select.py} (98%) rename examples/{multi_slice1.py => feature_demo/plot_multi_slice1.py} (97%) rename examples/{multi_slice2.py => feature_demo/plot_multi_slice2.py} (97%) rename examples/{panzoom_camera.py => feature_demo/plot_panzoom_camera.py} (97%) rename examples/{pbr.py => feature_demo/plot_pbr.py} (98%) rename examples/{pbr2.py => feature_demo/plot_pbr2.py} (95%) rename examples/{physical_color.py => feature_demo/plot_physical_color.py} (97%) rename examples/{picking_color.py => feature_demo/plot_picking_color.py} (97%) rename examples/{picking_mesh.py => feature_demo/plot_picking_mesh.py} (98%) rename examples/{picking_points.py => feature_demo/plot_picking_points.py} (97%) rename examples/{post_processing1.py => feature_demo/plot_post_processing1.py} (98%) rename examples/{post_processing2.py => feature_demo/plot_post_processing2.py} (96%) rename examples/{light_basic.py => introductory/plot_light_basic.py} (98%) rename examples/{object_bounding_box.py => introductory/plot_object_bounding_box.py} (95%) rename examples/{offscreen.py => introductory/plot_offscreen.py} (97%) rename examples/{orbit_camera.py => introductory/plot_orbit_camera.py} (98%) rename examples/{ => introductory}/points_basic.py (95%) diff --git a/examples/light_directional_shadow.py b/examples/feature_demo/plot_light_directional_shadow.py similarity index 83% rename from examples/light_directional_shadow.py rename to examples/feature_demo/plot_light_directional_shadow.py index 7f3ba138f..c83bd8939 100644 --- a/examples/light_directional_shadow.py +++ b/examples/feature_demo/plot_light_directional_shadow.py @@ -1,8 +1,12 @@ """ -This example demonstrates directional light shadows and their helper. -The cubes within the view frustum of the shadow camera have complete shadows, -the cubes at the edge of the view frustum of the camera have partial shadows, -while the cubes outside the view frustum of the camera will not cast shadows. + +Directional Shadow 1 +==================== + +This example demonstrates directional light shadows and their helper. The cubes +within the view frustum of the shadow camera have complete shadows, the cubes at +the edge of the view frustum of the camera have partial shadows, while the cubes +outside the view frustum of the camera will not cast shadows. """ import math diff --git a/examples/light_shadow.py b/examples/feature_demo/plot_light_shadow.py similarity index 94% rename from examples/light_shadow.py rename to examples/feature_demo/plot_light_shadow.py index c6ccebf9d..e97fc0e35 100644 --- a/examples/light_shadow.py +++ b/examples/feature_demo/plot_light_shadow.py @@ -1,6 +1,10 @@ """ -This example demonstrates the effects of directional light shadows (from DirectionalLight) -and omnidirectional shadows (from PointLight). + +Directional Shadow 2 +==================== + +This example demonstrates the effects of directional light shadows (from +DirectionalLight) and omnidirectional shadows (from PointLight). """ import time diff --git a/examples/light_spotlight_shadows.py b/examples/feature_demo/plot_light_spotlight_shadows.py similarity index 99% rename from examples/light_spotlight_shadows.py rename to examples/feature_demo/plot_light_spotlight_shadows.py index afc11f707..ffe38c160 100644 --- a/examples/light_spotlight_shadows.py +++ b/examples/feature_demo/plot_light_spotlight_shadows.py @@ -1,4 +1,9 @@ """ + +Spotlight Shadow +================ + + Spotlights and shadows examnple """ diff --git a/examples/light_spotlights.py b/examples/feature_demo/plot_light_spotlights.py similarity index 99% rename from examples/light_spotlights.py rename to examples/feature_demo/plot_light_spotlights.py index 75ab6a255..1b5a3c754 100644 --- a/examples/light_spotlights.py +++ b/examples/feature_demo/plot_light_spotlights.py @@ -1,4 +1,9 @@ """ + +Spotlights +========== + + Spotlights example. """ diff --git a/examples/line_basic.py b/examples/feature_demo/plot_line_basic.py similarity index 97% rename from examples/line_basic.py rename to examples/feature_demo/plot_line_basic.py index ad6fd19fa..edf9d4f1f 100644 --- a/examples/line_basic.py +++ b/examples/feature_demo/plot_line_basic.py @@ -1,4 +1,8 @@ """ +Line Drawing +============ + + Some basic line drawing. """ diff --git a/examples/line_performance.py b/examples/feature_demo/plot_line_performance.py similarity index 93% rename from examples/line_performance.py rename to examples/feature_demo/plot_line_performance.py index 9ee549c30..e70f4c112 100644 --- a/examples/line_performance.py +++ b/examples/feature_demo/plot_line_performance.py @@ -1,4 +1,7 @@ """ +Line Drawing Performance +======================== + Display a line depicting a noisy signal consisting of a lot of points. """ diff --git a/examples/line_segments.py b/examples/feature_demo/plot_line_segments.py similarity index 96% rename from examples/line_segments.py rename to examples/feature_demo/plot_line_segments.py index ae451c28c..cce7ca2d9 100644 --- a/examples/line_segments.py +++ b/examples/feature_demo/plot_line_segments.py @@ -1,4 +1,8 @@ """ + +Line Segments +============= + Display line segments. Can be useful e.g. for visializing vector fields. """ diff --git a/examples/line_thick.py b/examples/feature_demo/plot_line_thick.py similarity index 97% rename from examples/line_thick.py rename to examples/feature_demo/plot_line_thick.py index 6de6f3063..24146431e 100644 --- a/examples/line_thick.py +++ b/examples/feature_demo/plot_line_thick.py @@ -1,4 +1,7 @@ """ +Thick Lines +=========== + Display very thick lines to show how lines stay pretty on large scales. """ diff --git a/examples/manual_matrix_update.py b/examples/feature_demo/plot_manual_matrix_update.py similarity index 94% rename from examples/manual_matrix_update.py rename to examples/feature_demo/plot_manual_matrix_update.py index e30ff7e8d..6a8757a53 100644 --- a/examples/manual_matrix_update.py +++ b/examples/feature_demo/plot_manual_matrix_update.py @@ -1,4 +1,8 @@ """ +Transform Control without Matrix Updating +========================================= + + Example showing transform control flow without matrix auto updating. """ diff --git a/examples/mesh_depth_material.py b/examples/feature_demo/plot_mesh_depth_material.py similarity index 99% rename from examples/mesh_depth_material.py rename to examples/feature_demo/plot_mesh_depth_material.py index 0944b03eb..8944fdd5b 100644 --- a/examples/mesh_depth_material.py +++ b/examples/feature_demo/plot_mesh_depth_material.py @@ -1,4 +1,7 @@ """ +Depth Material +============== + A custom material for drawing geometry by depth """ diff --git a/examples/mesh_slice.py b/examples/feature_demo/plot_mesh_slice.py similarity index 97% rename from examples/mesh_slice.py rename to examples/feature_demo/plot_mesh_slice.py index 2231e8e85..00c42dd36 100644 --- a/examples/mesh_slice.py +++ b/examples/feature_demo/plot_mesh_slice.py @@ -1,4 +1,7 @@ """ +Mesh Slice Material +=================== + Example showing off the mesh slice material. """ diff --git a/examples/multi_select.py b/examples/feature_demo/plot_multi_select.py similarity index 98% rename from examples/multi_select.py rename to examples/feature_demo/plot_multi_select.py index f4e147991..3f5427570 100644 --- a/examples/multi_select.py +++ b/examples/feature_demo/plot_multi_select.py @@ -1,4 +1,8 @@ """ +Multi-Object Selection +====================== + + Example demonstrating multi object selection using mouse events. Hovering the mouse over a cube will highlight it with a bounding box. diff --git a/examples/multi_slice1.py b/examples/feature_demo/plot_multi_slice1.py similarity index 97% rename from examples/multi_slice1.py rename to examples/feature_demo/plot_multi_slice1.py index 25c0ed9d2..22a71e9b7 100644 --- a/examples/multi_slice1.py +++ b/examples/feature_demo/plot_multi_slice1.py @@ -1,4 +1,7 @@ """ +Volume and Mesh Slicing 1 +========================= + Slice a volume and a mesh through the three primary planes (XY, XZ, YZ). This example uses a mesh object with custom texture coordinates. This is a generic approach. See multi_slice2.py for a simpler way. diff --git a/examples/multi_slice2.py b/examples/feature_demo/plot_multi_slice2.py similarity index 97% rename from examples/multi_slice2.py rename to examples/feature_demo/plot_multi_slice2.py index 51c772876..5fff95a44 100644 --- a/examples/multi_slice2.py +++ b/examples/feature_demo/plot_multi_slice2.py @@ -1,4 +1,8 @@ """ +Mesh and Volume Slicing 2 +========================= + + Slice a volume and a mesh through the three primary planes (XY, XZ, YZ). This example uses Volume object with a VolumeSliceMaterial, which produces an implicit geometry defined by the volume data. diff --git a/examples/panzoom_camera.py b/examples/feature_demo/plot_panzoom_camera.py similarity index 97% rename from examples/panzoom_camera.py rename to examples/feature_demo/plot_panzoom_camera.py index f805308d3..39a4d01df 100644 --- a/examples/panzoom_camera.py +++ b/examples/feature_demo/plot_panzoom_camera.py @@ -1,4 +1,7 @@ """ +Panzoom Camera +============== + Example showing orbit camera controller. Press 's' to save the state, and diff --git a/examples/pbr.py b/examples/feature_demo/plot_pbr.py similarity index 98% rename from examples/pbr.py rename to examples/feature_demo/plot_pbr.py index 6a23dfde9..5643fabf8 100644 --- a/examples/pbr.py +++ b/examples/feature_demo/plot_pbr.py @@ -1,4 +1,8 @@ """ +PBR Rendering 1 +=============== + + This example shows a complete PBR rendering effect. The cubemap of skybox is also the environment cubemap of the helmet. """ diff --git a/examples/pbr2.py b/examples/feature_demo/plot_pbr2.py similarity index 95% rename from examples/pbr2.py rename to examples/feature_demo/plot_pbr2.py index d197c8773..168528665 100644 --- a/examples/pbr2.py +++ b/examples/feature_demo/plot_pbr2.py @@ -1,6 +1,10 @@ """ -This example shows the lighting rendering affect of materials with different metalness and roughness. -Every second sphere has an IBL environment map on it. + +PBR Rendering 2 +=============== + +This example shows the lighting rendering affect of materials with different +metalness and roughness. Every second sphere has an IBL environment map on it. """ # run_example = false diff --git a/examples/physical_color.py b/examples/feature_demo/plot_physical_color.py similarity index 97% rename from examples/physical_color.py rename to examples/feature_demo/plot_physical_color.py index 2a5829f4e..ac3e1de9b 100644 --- a/examples/physical_color.py +++ b/examples/feature_demo/plot_physical_color.py @@ -1,4 +1,8 @@ """ + +Physical Color +============== + PyGfx by default assumes that all colors are in the sRGB colorspace. This example shows how you can also provide colors in physical colorspace (a.k.a. linear-srgb). This example shows 3 images: diff --git a/examples/picking_color.py b/examples/feature_demo/plot_picking_color.py similarity index 97% rename from examples/picking_color.py rename to examples/feature_demo/plot_picking_color.py index 7cf810d90..3b1747121 100644 --- a/examples/picking_color.py +++ b/examples/feature_demo/plot_picking_color.py @@ -1,4 +1,7 @@ """ +Color Picking +============= + Example showing picking the color from the scene. Depending on the object being clicked, more detailed picking info is available. """ diff --git a/examples/picking_mesh.py b/examples/feature_demo/plot_picking_mesh.py similarity index 98% rename from examples/picking_mesh.py rename to examples/feature_demo/plot_picking_mesh.py index ddb87cf20..a98dae2b1 100644 --- a/examples/picking_mesh.py +++ b/examples/feature_demo/plot_picking_mesh.py @@ -1,4 +1,7 @@ """ +Mesh Picking +============ + Example showing picking a mesh. Showing two meshes that can be clicked on. Upon clicking, the vertex closest to the pick location is moved. """ diff --git a/examples/picking_points.py b/examples/feature_demo/plot_picking_points.py similarity index 97% rename from examples/picking_points.py rename to examples/feature_demo/plot_picking_points.py index 9409c59fc..a40069d65 100644 --- a/examples/picking_points.py +++ b/examples/feature_demo/plot_picking_points.py @@ -1,4 +1,7 @@ """ +Point Picking +============= + Example showing picking points. When clicking on a point, it's location is changed. With a small change, a line is shown instead. """ diff --git a/examples/post_processing1.py b/examples/feature_demo/plot_post_processing1.py similarity index 98% rename from examples/post_processing1.py rename to examples/feature_demo/plot_post_processing1.py index 0cf915b14..b62d43360 100644 --- a/examples/post_processing1.py +++ b/examples/feature_demo/plot_post_processing1.py @@ -1,4 +1,8 @@ """ +Full-Screen Post Processing 1 +============================= + + Example full-screen post processing. The idea is to render a scene to a texture, and then rendering diff --git a/examples/post_processing2.py b/examples/feature_demo/plot_post_processing2.py similarity index 96% rename from examples/post_processing2.py rename to examples/feature_demo/plot_post_processing2.py index 71faaa15a..ba9a9cc84 100644 --- a/examples/post_processing2.py +++ b/examples/feature_demo/plot_post_processing2.py @@ -1,4 +1,7 @@ """ +Fullscreen Postprocessing 2 +=========================== + Example showing post-processing effects by modifying the flusher object. This example is a placeholder for how post-processing *could* work if diff --git a/examples/light_basic.py b/examples/introductory/plot_light_basic.py similarity index 98% rename from examples/light_basic.py rename to examples/introductory/plot_light_basic.py index 6e54a9e95..899a268e6 100644 --- a/examples/light_basic.py +++ b/examples/introductory/plot_light_basic.py @@ -1,4 +1,8 @@ """ +Lights +====== + + Simple light example. This example shows a cube with MeshPhongMaterial illuminated by a point light and a directional light. """ diff --git a/examples/object_bounding_box.py b/examples/introductory/plot_object_bounding_box.py similarity index 95% rename from examples/object_bounding_box.py rename to examples/introductory/plot_object_bounding_box.py index 84e969bce..319ca4878 100644 --- a/examples/object_bounding_box.py +++ b/examples/introductory/plot_object_bounding_box.py @@ -1,4 +1,7 @@ """ +Boundary Boxes +============== + Demonstrates visualizing object bounding boxes """ from pathlib import Path diff --git a/examples/offscreen.py b/examples/introductory/plot_offscreen.py similarity index 97% rename from examples/offscreen.py rename to examples/introductory/plot_offscreen.py index 9242ff683..b2b5463de 100644 --- a/examples/offscreen.py +++ b/examples/introductory/plot_offscreen.py @@ -1,4 +1,7 @@ """ +Offscreen Rendering +=================== + Example demonstrating off-screen rendering. This uses wgpu's offscreen canvas to obtain the frames as a numpy array. diff --git a/examples/orbit_camera.py b/examples/introductory/plot_orbit_camera.py similarity index 98% rename from examples/orbit_camera.py rename to examples/introductory/plot_orbit_camera.py index 4644ce8c8..893a68d2e 100644 --- a/examples/orbit_camera.py +++ b/examples/introductory/plot_orbit_camera.py @@ -1,4 +1,7 @@ """ +Orbit Camera +============ + Example showing orbit camera controller. Press 's' to save the state, and diff --git a/examples/points_basic.py b/examples/introductory/points_basic.py similarity index 95% rename from examples/points_basic.py rename to examples/introductory/points_basic.py index 6864c4845..0988981fe 100644 --- a/examples/points_basic.py +++ b/examples/introductory/points_basic.py @@ -1,4 +1,8 @@ """ +Rendering Points +================ + + Render Points """ diff --git a/examples/light_view.py b/examples/light_view.py index 20f130de3..2a346be64 100644 --- a/examples/light_view.py +++ b/examples/light_view.py @@ -1,4 +1,7 @@ """ +Light Effects +============= + Lighting effect demonstration examples with adjustable parameters """ From 3c60a844684e0835bfee80164c17cf00f0a34735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 11 Nov 2022 13:52:07 +0100 Subject: [PATCH 09/54] rename final examples --- docs/conf.py | 1 + .../plot_scene_in_a_scene.py} | 3 +++ .../{scene_overlay.py => feature_demo/plot_scene_overlay.py} | 3 +++ .../plot_scene_subplots1.py} | 3 +++ .../plot_scene_subplots2.py} | 3 +++ .../plot_scene_subplots_video.py} | 3 +++ examples/{show_image.py => feature_demo/plot_show_image.py} | 3 +++ examples/{show_scene.py => feature_demo/plot_show_scene.py} | 3 +++ examples/{show_stl.py => feature_demo/plot_show_stl.py} | 3 +++ examples/{show_util.py => feature_demo/plot_show_util.py} | 3 +++ examples/{skybox.py => feature_demo/plot_skybox.py} | 3 +++ examples/{spheres.py => feature_demo/plot_spheres.py} | 3 +++ .../{sponza_scene.py => feature_demo/plot_sponza_scene.py} | 3 +++ .../{synced_video.py => feature_demo/plot_synced_video.py} | 3 +++ .../{transparency1.py => feature_demo/plot_transparency1.py} | 3 +++ .../{transparency2.py => feature_demo/plot_transparency2.py} | 3 +++ .../{two_canvases.py => feature_demo/plot_two_canvases.py} | 3 +++ .../{volume_render1.py => feature_demo/plot_volume_render1.py} | 3 +++ .../{volume_render2.py => feature_demo/plot_volume_render2.py} | 3 +++ .../{volume_slice1.py => feature_demo/plot_volume_slice1.py} | 3 +++ .../{volume_slice2.py => feature_demo/plot_volume_slice2.py} | 3 +++ .../{volume_slice3.py => feature_demo/plot_volume_slice3.py} | 3 +++ .../{volume_slice4.py => feature_demo/plot_volume_slice4.py} | 3 +++ examples/{wireframe1.py => feature_demo/plot_wireframe1.py} | 3 +++ examples/{wireframe2.py => feature_demo/plot_wireframe2.py} | 3 +++ .../plot_wireframe_material.py} | 3 +++ .../plot_world_bounding_box.py} | 3 +++ examples/validation/README.rst | 1 + examples/{validate_box.py => validation/plot_validate_box.py} | 3 +++ .../{validate_color.py => validation/plot_validate_color.py} | 3 +++ .../plot_validate_culling.py} | 3 +++ .../plot_validate_depth_clipping.py} | 3 +++ .../plot_validate_helpers1.py} | 3 +++ .../plot_validate_helpers2.py} | 3 +++ .../{validate_image1.py => validation/plot_validate_image1.py} | 3 +++ .../{validate_image2.py => validation/plot_validate_image2.py} | 3 +++ .../plot_validate_image_colormap.py} | 3 +++ .../plot_validate_light_shadow.py} | 3 +++ .../plot_validate_mesh_colormap.py} | 3 +++ examples/{validate_ndc.py => validation/plot_validate_ndc.py} | 3 +++ .../{validate_volume.py => validation/plot_validate_volume.py} | 3 +++ 41 files changed, 119 insertions(+) rename examples/{scene_in_a_scene.py => feature_demo/plot_scene_in_a_scene.py} (98%) rename examples/{scene_overlay.py => feature_demo/plot_scene_overlay.py} (98%) rename examples/{scene_subplots1.py => feature_demo/plot_scene_subplots1.py} (98%) rename examples/{scene_subplots2.py => feature_demo/plot_scene_subplots2.py} (99%) rename examples/{scene_subplots_video.py => feature_demo/plot_scene_subplots_video.py} (98%) rename examples/{show_image.py => feature_demo/plot_show_image.py} (96%) rename examples/{show_scene.py => feature_demo/plot_show_scene.py} (91%) rename examples/{show_stl.py => feature_demo/plot_show_stl.py} (86%) rename examples/{show_util.py => feature_demo/plot_show_util.py} (88%) rename examples/{skybox.py => feature_demo/plot_skybox.py} (98%) rename examples/{spheres.py => feature_demo/plot_spheres.py} (97%) rename examples/{sponza_scene.py => feature_demo/plot_sponza_scene.py} (98%) rename examples/{synced_video.py => feature_demo/plot_synced_video.py} (96%) rename examples/{transparency1.py => feature_demo/plot_transparency1.py} (97%) rename examples/{transparency2.py => feature_demo/plot_transparency2.py} (98%) rename examples/{two_canvases.py => feature_demo/plot_two_canvases.py} (98%) rename examples/{volume_render1.py => feature_demo/plot_volume_render1.py} (97%) rename examples/{volume_render2.py => feature_demo/plot_volume_render2.py} (97%) rename examples/{volume_slice1.py => feature_demo/plot_volume_slice1.py} (97%) rename examples/{volume_slice2.py => feature_demo/plot_volume_slice2.py} (97%) rename examples/{volume_slice3.py => feature_demo/plot_volume_slice3.py} (97%) rename examples/{volume_slice4.py => feature_demo/plot_volume_slice4.py} (97%) rename examples/{wireframe1.py => feature_demo/plot_wireframe1.py} (97%) rename examples/{wireframe2.py => feature_demo/plot_wireframe2.py} (97%) rename examples/{wireframe_material.py => feature_demo/plot_wireframe_material.py} (99%) rename examples/{world_bounding_box.py => feature_demo/plot_world_bounding_box.py} (95%) create mode 100644 examples/validation/README.rst rename examples/{validate_box.py => validation/plot_validate_box.py} (96%) rename examples/{validate_color.py => validation/plot_validate_color.py} (97%) rename examples/{validate_culling.py => validation/plot_validate_culling.py} (99%) rename examples/{validate_depth_clipping.py => validation/plot_validate_depth_clipping.py} (98%) rename examples/{validate_helpers1.py => validation/plot_validate_helpers1.py} (95%) rename examples/{validate_helpers2.py => validation/plot_validate_helpers2.py} (97%) rename examples/{validate_image1.py => validation/plot_validate_image1.py} (96%) rename examples/{validate_image2.py => validation/plot_validate_image2.py} (97%) rename examples/{validate_image_colormap.py => validation/plot_validate_image_colormap.py} (96%) rename examples/{validate_light_shadow.py => validation/plot_validate_light_shadow.py} (98%) rename examples/{validate_mesh_colormap.py => validation/plot_validate_mesh_colormap.py} (98%) rename examples/{validate_ndc.py => validation/plot_validate_ndc.py} (98%) rename examples/{validate_volume.py => validation/plot_validate_volume.py} (97%) diff --git a/docs/conf.py b/docs/conf.py index 3a72b9900..428fb8579 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,6 +80,7 @@ def _check_objects_are_documented(): [ "../examples/introductory", "../examples/feature_demo", + "../examples/validation", ] ), } diff --git a/examples/scene_in_a_scene.py b/examples/feature_demo/plot_scene_in_a_scene.py similarity index 98% rename from examples/scene_in_a_scene.py rename to examples/feature_demo/plot_scene_in_a_scene.py index f8ba7d453..35fd209b2 100644 --- a/examples/scene_in_a_scene.py +++ b/examples/feature_demo/plot_scene_in_a_scene.py @@ -1,4 +1,7 @@ """ +Nested Scenes +============= + Example of a scene rendered to a texture, which is shown in another scene. Inception style. Since both the outer and inner scenes are lit, this diff --git a/examples/scene_overlay.py b/examples/feature_demo/plot_scene_overlay.py similarity index 98% rename from examples/scene_overlay.py rename to examples/feature_demo/plot_scene_overlay.py index 1dad71bc9..04d843b9f 100644 --- a/examples/scene_overlay.py +++ b/examples/feature_demo/plot_scene_overlay.py @@ -1,4 +1,7 @@ """ +Scene Overlay +============= + Example showing a 3D scene with a 2D overlay. The idea is to render both scenes, but clear the depth before rendering diff --git a/examples/scene_subplots1.py b/examples/feature_demo/plot_scene_subplots1.py similarity index 98% rename from examples/scene_subplots1.py rename to examples/feature_demo/plot_scene_subplots1.py index 1a6a1f638..73cf263ee 100644 --- a/examples/scene_subplots1.py +++ b/examples/feature_demo/plot_scene_subplots1.py @@ -1,4 +1,7 @@ """ +Subplots 1 +========== + Example showing how to render to a subregion of a canvas. This is a feature necessary to implement e.g. subplots. This example diff --git a/examples/scene_subplots2.py b/examples/feature_demo/plot_scene_subplots2.py similarity index 99% rename from examples/scene_subplots2.py rename to examples/feature_demo/plot_scene_subplots2.py index 6892ad374..24f9046e0 100644 --- a/examples/scene_subplots2.py +++ b/examples/feature_demo/plot_scene_subplots2.py @@ -1,4 +1,7 @@ """ +Subplots 2 +========== + Like scene_side_by_side, but now with a more plot-like idea, and mouse interaction. """ diff --git a/examples/scene_subplots_video.py b/examples/feature_demo/plot_scene_subplots_video.py similarity index 98% rename from examples/scene_subplots_video.py rename to examples/feature_demo/plot_scene_subplots_video.py index 3397d57ef..93205d5ba 100644 --- a/examples/scene_subplots_video.py +++ b/examples/feature_demo/plot_scene_subplots_video.py @@ -1,4 +1,7 @@ """ +Subplots Video +============== + An example combining `synced_video.py` with subplots. Double click to re-center the images. """ diff --git a/examples/show_image.py b/examples/feature_demo/plot_show_image.py similarity index 96% rename from examples/show_image.py rename to examples/feature_demo/plot_show_image.py index c947740ea..0fdefc78f 100644 --- a/examples/show_image.py +++ b/examples/feature_demo/plot_show_image.py @@ -1,4 +1,7 @@ """ +Show Image +========== + Use camera.show_object to ensure the Image is in view. """ diff --git a/examples/show_scene.py b/examples/feature_demo/plot_show_scene.py similarity index 91% rename from examples/show_scene.py rename to examples/feature_demo/plot_show_scene.py index f4c9a8117..5b3cbe207 100644 --- a/examples/show_scene.py +++ b/examples/feature_demo/plot_show_scene.py @@ -1,4 +1,7 @@ """ +Use gfx.show to show a Scene +============================ + Demonstrates show utility for a scene """ diff --git a/examples/show_stl.py b/examples/feature_demo/plot_show_stl.py similarity index 86% rename from examples/show_stl.py rename to examples/feature_demo/plot_show_stl.py index d5635e0a3..2abd7ac67 100644 --- a/examples/show_stl.py +++ b/examples/feature_demo/plot_show_stl.py @@ -1,4 +1,7 @@ """ +Show STL File via gfx.show +========================== + Demonstrates show utility with an STL file """ from pathlib import Path diff --git a/examples/show_util.py b/examples/feature_demo/plot_show_util.py similarity index 88% rename from examples/show_util.py rename to examples/feature_demo/plot_show_util.py index 53bae9fca..55074f44f 100644 --- a/examples/show_util.py +++ b/examples/feature_demo/plot_show_util.py @@ -1,4 +1,7 @@ """ +Use gfx.show +============ + Demonstrates show utility """ diff --git a/examples/skybox.py b/examples/feature_demo/plot_skybox.py similarity index 98% rename from examples/skybox.py rename to examples/feature_demo/plot_skybox.py index 6b06edb4f..505381511 100644 --- a/examples/skybox.py +++ b/examples/feature_demo/plot_skybox.py @@ -1,4 +1,7 @@ """ +Use a Skybox +============ + Example with a skybox background. Inspired by https://github.com/gfx-rs/wgpu-rs/blob/master/examples/skybox/main.rs diff --git a/examples/spheres.py b/examples/feature_demo/plot_spheres.py similarity index 97% rename from examples/spheres.py rename to examples/feature_demo/plot_spheres.py index 29b7c4df8..82aad0577 100644 --- a/examples/spheres.py +++ b/examples/feature_demo/plot_spheres.py @@ -1,4 +1,7 @@ """ +Sphere Geometry +=============== + Example showing different types of geometric cylinders. """ diff --git a/examples/sponza_scene.py b/examples/feature_demo/plot_sponza_scene.py similarity index 98% rename from examples/sponza_scene.py rename to examples/feature_demo/plot_sponza_scene.py index 5ec110626..11fdc9a64 100644 --- a/examples/sponza_scene.py +++ b/examples/feature_demo/plot_sponza_scene.py @@ -1,4 +1,7 @@ """ +Sponza Scene +============ + This example shows how to load the Sponza scene. """ # run_example = false - because it depends on external files diff --git a/examples/synced_video.py b/examples/feature_demo/plot_synced_video.py similarity index 96% rename from examples/synced_video.py rename to examples/feature_demo/plot_synced_video.py index 45964b982..7d3f39d50 100644 --- a/examples/synced_video.py +++ b/examples/feature_demo/plot_synced_video.py @@ -1,4 +1,7 @@ """ +Synced Video Rendering +====================== + Example demonstrating synced video rendering """ diff --git a/examples/transparency1.py b/examples/feature_demo/plot_transparency1.py similarity index 97% rename from examples/transparency1.py rename to examples/feature_demo/plot_transparency1.py index 57d9df6bc..ef97b4d88 100644 --- a/examples/transparency1.py +++ b/examples/feature_demo/plot_transparency1.py @@ -1,4 +1,7 @@ """ +Transparency 1 +============== + Example showing transparency using three overlapping planes. Press space to toggle the order of the planes. Press 1-6 to select the blend mode. diff --git a/examples/transparency2.py b/examples/feature_demo/plot_transparency2.py similarity index 98% rename from examples/transparency2.py rename to examples/feature_demo/plot_transparency2.py index 2cf928d45..e750e0c51 100644 --- a/examples/transparency2.py +++ b/examples/feature_demo/plot_transparency2.py @@ -1,4 +1,7 @@ """ +Transparency 2 +============== + Example showing transparency using three orthogonal planes. Press space to toggle the order of the planes. Press 1-6 to select the blend mode. diff --git a/examples/two_canvases.py b/examples/feature_demo/plot_two_canvases.py similarity index 98% rename from examples/two_canvases.py rename to examples/feature_demo/plot_two_canvases.py index 3d2783b97..89498ab5f 100644 --- a/examples/two_canvases.py +++ b/examples/feature_demo/plot_two_canvases.py @@ -1,4 +1,7 @@ """ +Two Canvases +============ + Example demonstrating rendering the same scene into two different canvases. """ diff --git a/examples/volume_render1.py b/examples/feature_demo/plot_volume_render1.py similarity index 97% rename from examples/volume_render1.py rename to examples/feature_demo/plot_volume_render1.py index be3371d2a..b4756c239 100644 --- a/examples/volume_render1.py +++ b/examples/feature_demo/plot_volume_render1.py @@ -1,4 +1,7 @@ """ +Volume Rendering 1 +================== + Render a volume. Shift-click to draw white blobs inside the volume. """ diff --git a/examples/volume_render2.py b/examples/feature_demo/plot_volume_render2.py similarity index 97% rename from examples/volume_render2.py rename to examples/feature_demo/plot_volume_render2.py index 7fa3cd181..8a0e9483c 100644 --- a/examples/volume_render2.py +++ b/examples/feature_demo/plot_volume_render2.py @@ -1,4 +1,7 @@ """ +Volume Rendering 2 +================== + Render three volumes using different world transforms. """ diff --git a/examples/volume_slice1.py b/examples/feature_demo/plot_volume_slice1.py similarity index 97% rename from examples/volume_slice1.py rename to examples/feature_demo/plot_volume_slice1.py index 9404daa35..9aac22aa8 100644 --- a/examples/volume_slice1.py +++ b/examples/feature_demo/plot_volume_slice1.py @@ -1,4 +1,7 @@ """ +Volume Slice 1 +============== + Render slices through a volume, by uploading to a 2D texture. Simple and ... slow. """ diff --git a/examples/volume_slice2.py b/examples/feature_demo/plot_volume_slice2.py similarity index 97% rename from examples/volume_slice2.py rename to examples/feature_demo/plot_volume_slice2.py index c2f3a84eb..9c76b6958 100644 --- a/examples/volume_slice2.py +++ b/examples/feature_demo/plot_volume_slice2.py @@ -1,4 +1,7 @@ """ +Volume Slice 2 +============== + Render slices through a volume, by creating a 3D texture, with 2D views. Simple and relatively fast, but no subslices. """ diff --git a/examples/volume_slice3.py b/examples/feature_demo/plot_volume_slice3.py similarity index 97% rename from examples/volume_slice3.py rename to examples/feature_demo/plot_volume_slice3.py index 7579bf7e9..1fdb7bf82 100644 --- a/examples/volume_slice3.py +++ b/examples/feature_demo/plot_volume_slice3.py @@ -1,4 +1,7 @@ """ +Volume Slice 3 +============== + Render slices through a volume, by creating a 3D texture, and sampling onto a plane geometry. Simple, fast and subpixel! """ diff --git a/examples/volume_slice4.py b/examples/feature_demo/plot_volume_slice4.py similarity index 97% rename from examples/volume_slice4.py rename to examples/feature_demo/plot_volume_slice4.py index 3c7d6b629..e18f90edf 100644 --- a/examples/volume_slice4.py +++ b/examples/feature_demo/plot_volume_slice4.py @@ -1,4 +1,7 @@ """ +Volume Slice 4 +============== + Render slices through a volume, by creating a 3D texture, and viewing it with a VolumeSliceMaterial. Easy because we can just define the view plane. """ diff --git a/examples/wireframe1.py b/examples/feature_demo/plot_wireframe1.py similarity index 97% rename from examples/wireframe1.py rename to examples/feature_demo/plot_wireframe1.py index f81474655..914453d45 100644 --- a/examples/wireframe1.py +++ b/examples/feature_demo/plot_wireframe1.py @@ -1,4 +1,7 @@ """ +Wireframe 1 +=========== + Example showing a Torus knot, with a wireframe overlay. In this case the wireframe is lit while the solid mesh is not, diff --git a/examples/wireframe2.py b/examples/feature_demo/plot_wireframe2.py similarity index 97% rename from examples/wireframe2.py rename to examples/feature_demo/plot_wireframe2.py index b139911e5..3b7b6da5f 100644 --- a/examples/wireframe2.py +++ b/examples/feature_demo/plot_wireframe2.py @@ -1,4 +1,7 @@ """ +Wireframe 2 +=========== + Example showing a Torus knot, as a wireframe. We create two wireframes, one for the front, bright blue and lit, and one for the back, unlit and gray. diff --git a/examples/wireframe_material.py b/examples/feature_demo/plot_wireframe_material.py similarity index 99% rename from examples/wireframe_material.py rename to examples/feature_demo/plot_wireframe_material.py index 328de1b51..49aa2f093 100644 --- a/examples/wireframe_material.py +++ b/examples/feature_demo/plot_wireframe_material.py @@ -1,4 +1,7 @@ """ +Wireframe Material +================== + Example showing a custom wireframe material, together with the builtin option to render a wireframe. Notice that in the former the wires are not of equal thickness. diff --git a/examples/world_bounding_box.py b/examples/feature_demo/plot_world_bounding_box.py similarity index 95% rename from examples/world_bounding_box.py rename to examples/feature_demo/plot_world_bounding_box.py index 52d29fc59..f0d7a8cb1 100644 --- a/examples/world_bounding_box.py +++ b/examples/feature_demo/plot_world_bounding_box.py @@ -1,4 +1,7 @@ """ +Bounding Box Coordinates +======================== + Render two volumes using different world transforms. Prints the world bounding box of the scene which used to trigger an Exception. diff --git a/examples/validation/README.rst b/examples/validation/README.rst new file mode 100644 index 000000000..d3a206c11 --- /dev/null +++ b/examples/validation/README.rst @@ -0,0 +1 @@ +.. rubric:: Validation Examples diff --git a/examples/validate_box.py b/examples/validation/plot_validate_box.py similarity index 96% rename from examples/validate_box.py rename to examples/validation/plot_validate_box.py index 05f8a7a66..27b880e81 100644 --- a/examples/validate_box.py +++ b/examples/validation/plot_validate_box.py @@ -1,4 +1,7 @@ """ +Box Geometry +============ + Example showing the box geometry. """ # test_example = true diff --git a/examples/validate_color.py b/examples/validation/plot_validate_color.py similarity index 97% rename from examples/validate_color.py rename to examples/validation/plot_validate_color.py index 5e7270a45..750b69440 100644 --- a/examples/validate_color.py +++ b/examples/validation/plot_validate_color.py @@ -1,4 +1,7 @@ """ +Reference Color +=============== + This example draws squares of reference colors. These can be compared to similar output from e.g. Matplotlib. """ diff --git a/examples/validate_culling.py b/examples/validation/plot_validate_culling.py similarity index 99% rename from examples/validate_culling.py rename to examples/validation/plot_validate_culling.py index ed1dd545d..f351316f4 100644 --- a/examples/validate_culling.py +++ b/examples/validation/plot_validate_culling.py @@ -1,4 +1,7 @@ """ +Culling +======= + Example test to validate winding and culling. * The top red knot should look normal and well lit. diff --git a/examples/validate_depth_clipping.py b/examples/validation/plot_validate_depth_clipping.py similarity index 98% rename from examples/validate_depth_clipping.py rename to examples/validation/plot_validate_depth_clipping.py index fc8ce08eb..cbbdbe514 100644 --- a/examples/validate_depth_clipping.py +++ b/examples/validation/plot_validate_depth_clipping.py @@ -1,4 +1,7 @@ """ +Depth Clipping +============== + Example (and test) for camera depth clipping planes. This draws four rectangles near the near and far clipping planes. diff --git a/examples/validate_helpers1.py b/examples/validation/plot_validate_helpers1.py similarity index 95% rename from examples/validate_helpers1.py rename to examples/validation/plot_validate_helpers1.py index b67274df5..5eec61328 100644 --- a/examples/validate_helpers1.py +++ b/examples/validation/plot_validate_helpers1.py @@ -1,4 +1,7 @@ """ +Axes Helper 1 +============= + Example showing the axes helper. * The axes must be centered in the middle. diff --git a/examples/validate_helpers2.py b/examples/validation/plot_validate_helpers2.py similarity index 97% rename from examples/validate_helpers2.py rename to examples/validation/plot_validate_helpers2.py index a5d541357..f4f443e6f 100644 --- a/examples/validate_helpers2.py +++ b/examples/validation/plot_validate_helpers2.py @@ -1,4 +1,7 @@ """ +Axis Helper 2 +============= + Example showing the axes and grid helpers with a perspective camera. * The grid spans the x-z plane (red and blue axis). diff --git a/examples/validate_image1.py b/examples/validation/plot_validate_image1.py similarity index 96% rename from examples/validate_image1.py rename to examples/validation/plot_validate_image1.py index d88e7f409..3421675bb 100644 --- a/examples/validate_image1.py +++ b/examples/validation/plot_validate_image1.py @@ -1,4 +1,7 @@ """ +Image on Plane Geometry 1 +========================= + Show an image using a plane geometry. For historic reasons, image data (usually) has the first rows representing the top of the image. But the plane gemeometry is such that it is reversed again. diff --git a/examples/validate_image2.py b/examples/validation/plot_validate_image2.py similarity index 97% rename from examples/validate_image2.py rename to examples/validation/plot_validate_image2.py index 5e063d46a..6b5f57bd0 100644 --- a/examples/validate_image2.py +++ b/examples/validation/plot_validate_image2.py @@ -1,4 +1,7 @@ """ +Image Material +============== + Show an image displayed the correct way. * The green dots should be at the corners that are darker/brighter. diff --git a/examples/validate_image_colormap.py b/examples/validation/plot_validate_image_colormap.py similarity index 96% rename from examples/validate_image_colormap.py rename to examples/validation/plot_validate_image_colormap.py index 6682fbd35..a60d0f870 100644 --- a/examples/validate_image_colormap.py +++ b/examples/validation/plot_validate_image_colormap.py @@ -1,4 +1,7 @@ """ +Simple Colormap +=============== + Show an image with a simple colormap. * You should see a square image with 3 equally sized vertical bands. diff --git a/examples/validate_light_shadow.py b/examples/validation/plot_validate_light_shadow.py similarity index 98% rename from examples/validate_light_shadow.py rename to examples/validation/plot_validate_light_shadow.py index b0a0094bf..7d63d9b04 100644 --- a/examples/validate_light_shadow.py +++ b/examples/validation/plot_validate_light_shadow.py @@ -1,4 +1,7 @@ """ +Light and Shadow +================ + This example combines MeshPhongMaterial and MeshStandardMaterial with PointLight, AmbientLight, SpotLight and DirectionalLight to check that all combinations are working properly. diff --git a/examples/validate_mesh_colormap.py b/examples/validation/plot_validate_mesh_colormap.py similarity index 98% rename from examples/validate_mesh_colormap.py rename to examples/validation/plot_validate_mesh_colormap.py index 1696ce65a..d083ad0c4 100644 --- a/examples/validate_mesh_colormap.py +++ b/examples/validation/plot_validate_mesh_colormap.py @@ -1,4 +1,7 @@ """ +Mesh Colormaps +============== + Show meshes with 1D, 2D, and 3D colormaps, and per-vertex colors too. * You should see four cylinders with block-pattern colors. diff --git a/examples/validate_ndc.py b/examples/validation/plot_validate_ndc.py similarity index 98% rename from examples/validate_ndc.py rename to examples/validation/plot_validate_ndc.py index 2b0e59659..181bd9f40 100644 --- a/examples/validate_ndc.py +++ b/examples/validation/plot_validate_ndc.py @@ -1,4 +1,7 @@ """ +NDC Coordinates +=============== + Example (and test) for the NDC coordinates. Draws a square that falls partly out of visible range. * The scene should show a band from the bottom left to the upper right. diff --git a/examples/validate_volume.py b/examples/validation/plot_validate_volume.py similarity index 97% rename from examples/validate_volume.py rename to examples/validation/plot_validate_volume.py index 3f184d764..2b8e4beac 100644 --- a/examples/validate_volume.py +++ b/examples/validation/plot_validate_volume.py @@ -1,4 +1,7 @@ """ +Volume and Volume Slice Rendering +================================= + Render a volume and volume slices. You should see: * On the left: a raycasted volume fit snugly inside a red box. * On the right: three orthogonal slices inside - and through the middle of - a green box. From c631e03f9e5cdd6e2c7585fe405881a46b5bf223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 11 Nov 2022 17:03:47 +0100 Subject: [PATCH 10/54] titles for Qt examples --- examples/cube_qt.py | 3 +++ examples/cube_wx.py | 3 +++ examples/integration_qt.py | 1 + examples/text_with_qt.py | 1 + 4 files changed, 8 insertions(+) diff --git a/examples/cube_qt.py b/examples/cube_qt.py index 44ad21686..a00845269 100644 --- a/examples/cube_qt.py +++ b/examples/cube_qt.py @@ -1,4 +1,7 @@ """ +Simple Cube with Qt +=================== + Example showing a single geometric cube. """ # run_example = false diff --git a/examples/cube_wx.py b/examples/cube_wx.py index 88bf40f3e..40cf5574e 100644 --- a/examples/cube_wx.py +++ b/examples/cube_wx.py @@ -1,4 +1,7 @@ """ +Simple Cube with WX +=================== + Example showing a single geometric cube. """ # run_example = false diff --git a/examples/integration_qt.py b/examples/integration_qt.py index 3553f9ed4..712d3645b 100644 --- a/examples/integration_qt.py +++ b/examples/integration_qt.py @@ -2,6 +2,7 @@ """ Integrate pygfx in Qt +===================== """ import random diff --git a/examples/text_with_qt.py b/examples/text_with_qt.py index 044132b63..ad6f28dbc 100644 --- a/examples/text_with_qt.py +++ b/examples/text_with_qt.py @@ -2,6 +2,7 @@ """ Render Text with Qt +=================== """ import numpy as np From eab0437d4df82497f9a6477258b8d37585445b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sat, 12 Nov 2022 07:29:40 +0100 Subject: [PATCH 11/54] update model paths in examples --- examples/feature_demo/plot_pbr.py | 2 +- examples/feature_demo/plot_show_stl.py | 2 +- examples/introductory/plot_object_bounding_box.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/feature_demo/plot_pbr.py b/examples/feature_demo/plot_pbr.py index 5643fabf8..0e4e7cad4 100644 --- a/examples/feature_demo/plot_pbr.py +++ b/examples/feature_demo/plot_pbr.py @@ -44,7 +44,7 @@ # Load meshes, and apply env map # Note that this lits the helmet already gltf_path = ( - Path(__file__).parent / "models" / "DamagedHelmet" / "glTF" / "DamagedHelmet.gltf" + Path(__file__).parents[1] / "models" / "DamagedHelmet" / "glTF" / "DamagedHelmet.gltf" ) meshes = gfx.load_scene(gltf_path) scene.add(*meshes) diff --git a/examples/feature_demo/plot_show_stl.py b/examples/feature_demo/plot_show_stl.py index 2abd7ac67..981262332 100644 --- a/examples/feature_demo/plot_show_stl.py +++ b/examples/feature_demo/plot_show_stl.py @@ -11,7 +11,7 @@ import pygfx as gfx -TEAPOT = Path(__file__).parent / "models" / "teapot.stl" +TEAPOT = Path(__file__).parents[1] / "models" / "teapot.stl" teapot = trimesh.load(TEAPOT) diff --git a/examples/introductory/plot_object_bounding_box.py b/examples/introductory/plot_object_bounding_box.py index 319ca4878..e55579593 100644 --- a/examples/introductory/plot_object_bounding_box.py +++ b/examples/introductory/plot_object_bounding_box.py @@ -11,7 +11,7 @@ import pygfx as gfx -teapot = trimesh.load(Path(__file__).parent / "models" / "teapot.stl") +teapot = trimesh.load(Path(__file__).parents[1] / "models" / "teapot.stl") scene = gfx.Scene() From e3bee5f652518ee92ee772c96930fe2f18ecf967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sat, 12 Nov 2022 07:32:08 +0100 Subject: [PATCH 12/54] styling (flake & black) --- examples/feature_demo/plot_pbr.py | 6 +++++- pygfx/scraper.py | 11 +++++------ setup.cfg | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/feature_demo/plot_pbr.py b/examples/feature_demo/plot_pbr.py index 0e4e7cad4..6449e3747 100644 --- a/examples/feature_demo/plot_pbr.py +++ b/examples/feature_demo/plot_pbr.py @@ -44,7 +44,11 @@ # Load meshes, and apply env map # Note that this lits the helmet already gltf_path = ( - Path(__file__).parents[1] / "models" / "DamagedHelmet" / "glTF" / "DamagedHelmet.gltf" + Path(__file__).parents[1] + / "models" + / "DamagedHelmet" + / "glTF" + / "DamagedHelmet.gltf" ) meshes = gfx.load_scene(gltf_path) scene.add(*meshes) diff --git a/pygfx/scraper.py b/pygfx/scraper.py index 90faf6612..21535e6b1 100644 --- a/pygfx/scraper.py +++ b/pygfx/scraper.py @@ -1,7 +1,7 @@ import imageio.v3 as iio import pygfx as gfx from sphinx_gallery.scrapers import figure_rst -from wgpu.gui.offscreen import WgpuCanvas, run +from wgpu.gui.offscreen import WgpuCanvas def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): @@ -38,19 +38,18 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): if isinstance(var, gfx.Camera): current_camera = var - if current_scene is None or current_camera is None: - return '' # nothing to do + return "" # nothing to do renderer = gfx.WgpuRenderer(WgpuCanvas()) renderer.render(current_scene, current_camera) - + path_generator = block_vars["image_path_iterator"] img_path = next(path_generator) iio.imwrite(img_path, renderer.snapshot()) - return figure_rst([img_path], gallery_conf['src_dir']) + return figure_rst([img_path], gallery_conf["src_dir"]) def _get_sg_image_scraper(): - return pygfx_scraper \ No newline at end of file + return pygfx_scraper diff --git a/setup.cfg b/setup.cfg index 90a56ddfc..66cb43f7a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] max_line_length = 88 extend-ignore = E203, E231, E501, F541, D -exclude = build,dist,*.egg-info,.venv +exclude = build,dist,*.egg-info,.venv,docs/_gallery per-file-ignores = pygfx/linalg/*: F821 From ec8dba3abd57cf457db0ffaa90929bc052479919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 11:43:36 +0100 Subject: [PATCH 13/54] introduce config comments --- docs/conf.py | 1 + examples/introductory/plot_clipping_planes.py | 2 + examples/introductory/plot_cube.py | 1 + examples/introductory/plot_hello_triangle.py | 2 + pygfx/__init__.py | 2 +- pygfx/scraper.py | 55 ------------ pygfx/utils/gallery_scraper.py | 89 +++++++++++++++++++ 7 files changed, 96 insertions(+), 56 deletions(-) delete mode 100644 pygfx/scraper.py create mode 100644 pygfx/utils/gallery_scraper.py diff --git a/docs/conf.py b/docs/conf.py index 428fb8579..3f6832c17 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -83,6 +83,7 @@ def _check_objects_are_documented(): "../examples/validation", ] ), + "remove_config_comments": True, } diff --git a/examples/introductory/plot_clipping_planes.py b/examples/introductory/plot_clipping_planes.py index f294c6c04..717fd505c 100644 --- a/examples/introductory/plot_clipping_planes.py +++ b/examples/introductory/plot_clipping_planes.py @@ -4,6 +4,8 @@ Example demonstrating clipping planes on a mesh. """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "canvas" from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index 42955e6a1..56dc4bb26 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -5,6 +5,7 @@ In this example shows how to do the rendering world's hello world: Show a 3D Cube on screen. """ +# sphinx_gallery_pygfx_render = True import pygfx as gfx diff --git a/examples/introductory/plot_hello_triangle.py b/examples/introductory/plot_hello_triangle.py index 7f0ae4f5a..e296c3133 100644 --- a/examples/introductory/plot_hello_triangle.py +++ b/examples/introductory/plot_hello_triangle.py @@ -4,6 +4,8 @@ Replicating the WGPU triangle example, but with about 10x less code. """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "canvas" from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/pygfx/__init__.py b/pygfx/__init__.py index 571795bd3..7d2fe3e81 100644 --- a/pygfx/__init__.py +++ b/pygfx/__init__.py @@ -18,7 +18,7 @@ from .utils.viewport import Viewport from .utils import cm, logger -from .scraper import _get_sg_image_scraper +from .utils.gallery_scraper import _get_sg_image_scraper __version__ = "0.1.9" diff --git a/pygfx/scraper.py b/pygfx/scraper.py deleted file mode 100644 index 21535e6b1..000000000 --- a/pygfx/scraper.py +++ /dev/null @@ -1,55 +0,0 @@ -import imageio.v3 as iio -import pygfx as gfx -from sphinx_gallery.scrapers import figure_rst -from wgpu.gui.offscreen import WgpuCanvas - - -def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): - """Scrape pygfx images and animations - - Parameters - ---------- - block : tuple - A tuple containing the (label, content, line_number) of the block. - block_vars : dict - Dict of block variables. - gallery_conf : dict - Contains the configuration of Sphinx-Gallery - **kwargs : dict - Additional keyword arguments to pass to - :meth:`~matplotlib.figure.Figure.savefig`, e.g. ``format='svg'``. - The ``format`` kwarg in particular is used to set the file extension - of the output file (currently only 'png', 'jpg', and 'svg' are - supported). - - Returns - ------- - rst : str - The ReSTructuredText that will be rendered to HTML containing - the images. This is often produced by :func:`figure_rst`. - """ - - current_scene = None - current_camera = None - for var in block_vars["example_globals"].values(): - if isinstance(var, gfx.Scene): - current_scene = var - - if isinstance(var, gfx.Camera): - current_camera = var - - if current_scene is None or current_camera is None: - return "" # nothing to do - - renderer = gfx.WgpuRenderer(WgpuCanvas()) - renderer.render(current_scene, current_camera) - - path_generator = block_vars["image_path_iterator"] - img_path = next(path_generator) - iio.imwrite(img_path, renderer.snapshot()) - - return figure_rst([img_path], gallery_conf["src_dir"]) - - -def _get_sg_image_scraper(): - return pygfx_scraper diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py new file mode 100644 index 000000000..e88bbd30c --- /dev/null +++ b/pygfx/utils/gallery_scraper.py @@ -0,0 +1,89 @@ +import imageio.v3 as iio + +from .show import Display +from ..renderers import Renderer + + +# The scraper's default configuration. An example code-block +# may overwrite these values by setting comments of the form +# +# # sphinx_gallery_pygfx_ = +# +# inside the code block. These comments will not be shown in the generated +# gallery example and will be reset after each code block. +default_config = { + "render": False, # if True, render an image + "animate": False, # if True, render a GIF (TODO) + "target_name": "disp", # the display to use + # GIF settings + "duration": 3, # how many seconds to record + "loop": 0, # loop forever +} + + +def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): + """Scrape pygfx images and animations + + Parameters + ---------- + block : tuple + A tuple containing the (label, content, line_number) of the block. + block_vars : dict + Dict of block variables. + gallery_conf : dict + Contains the configuration of Sphinx-Gallery + **kwargs : dict + Additional keyword arguments to pass to + :meth:`~matplotlib.figure.Figure.savefig`, e.g. ``format='svg'``. + The ``format`` kwarg in particular is used to set the file extension + of the output file (currently only 'png', 'jpg', and 'svg' are + supported). + + Returns + ------- + rst : str + The ReSTructuredText that will be rendered to HTML containing + the images. This is often produced by :func:`figure_rst`. + """ + + # import locally, to keep sphinx an optional dependency + from sphinx_gallery.scrapers import figure_rst + + # parse block-level config + scraper_config = default_config.copy() + config_prefix = "# sphinx_gallery_pygfx_" + for line in block[1].split("\n"): + if not line.startswith(config_prefix): + continue + + name, value = line[len(config_prefix) :].split(" = ") + scraper_config[name] = eval(value) + + if not scraper_config["render"] and not scraper_config["animate"]: + return "" # nothing to do + + target = block_vars["example_globals"][scraper_config["target_name"]] + if isinstance(target, Display): + canvas = target.canvas + elif isinstance(target, Renderer): + canvas = target.target + else: + # @almarklein: Where can I find the base class of Canvas? + canvas = target + + images = [] + + if scraper_config["render"]: + path_generator = block_vars["image_path_iterator"] + img_path = next(path_generator) + iio.imwrite(img_path, canvas.draw()) + images.append(img_path) + + if scraper_config["animate"]: + pass # TODO: code to generate an ainmated GIF + + return figure_rst(images, gallery_conf["src_dir"]) + + +def _get_sg_image_scraper(): + return pygfx_scraper From 026912eaeee5cb80a88edf531d5ac287f3abc00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 12:09:31 +0100 Subject: [PATCH 14/54] update introductory examples --- examples/introductory/plot_clipping_planes.py | 1 - examples/introductory/plot_cube.py | 1 + examples/introductory/plot_hello_triangle.py | 1 - examples/introductory/plot_light_basic.py | 1 + .../introductory/plot_object_bounding_box.py | 32 +++++++++++++++++-- examples/introductory/plot_offscreen.py | 1 + examples/introductory/plot_orbit_camera.py | 1 + .../{points_basic.py => plot_points_basic.py} | 1 + pygfx/utils/gallery_scraper.py | 2 +- 9 files changed, 35 insertions(+), 6 deletions(-) rename examples/introductory/{points_basic.py => plot_points_basic.py} (95%) diff --git a/examples/introductory/plot_clipping_planes.py b/examples/introductory/plot_clipping_planes.py index 717fd505c..cd5d72c4a 100644 --- a/examples/introductory/plot_clipping_planes.py +++ b/examples/introductory/plot_clipping_planes.py @@ -5,7 +5,6 @@ Example demonstrating clipping planes on a mesh. """ # sphinx_gallery_pygfx_render = True -# sphinx_gallery_pygfx_target_name = "canvas" from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index 56dc4bb26..e1870c3e2 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -6,6 +6,7 @@ Cube on screen. """ # sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "disp" import pygfx as gfx diff --git a/examples/introductory/plot_hello_triangle.py b/examples/introductory/plot_hello_triangle.py index e296c3133..faf20a6b3 100644 --- a/examples/introductory/plot_hello_triangle.py +++ b/examples/introductory/plot_hello_triangle.py @@ -5,7 +5,6 @@ Replicating the WGPU triangle example, but with about 10x less code. """ # sphinx_gallery_pygfx_render = True -# sphinx_gallery_pygfx_target_name = "canvas" from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/introductory/plot_light_basic.py b/examples/introductory/plot_light_basic.py index 899a268e6..49d73c62c 100644 --- a/examples/introductory/plot_light_basic.py +++ b/examples/introductory/plot_light_basic.py @@ -6,6 +6,7 @@ Simple light example. This example shows a cube with MeshPhongMaterial illuminated by a point light and a directional light. """ +# sphinx_gallery_pygfx_render = True import time import math diff --git a/examples/introductory/plot_object_bounding_box.py b/examples/introductory/plot_object_bounding_box.py index e55579593..ac507bc26 100644 --- a/examples/introductory/plot_object_bounding_box.py +++ b/examples/introductory/plot_object_bounding_box.py @@ -4,16 +4,41 @@ Demonstrates visualizing object bounding boxes """ + +################################################################################ +# .. warning:: +# An external model is needed to run this example. +# +# To run this example, you need a model from the source repo's example +# folder. If you are running this example from a local copy of the code (dev +# install) no further actions are needed. Otherwise, you may have to replace +# the path below to point to the location of the model. + +import os from pathlib import Path -import trimesh +try: + # modify this line if your model is located elsewhere + model_dir = Path(__file__).parents[1] / "models" +except NameError: + # compatibility with sphinx-gallery + model_dir = Path(os.getcwd()).parent / "models" + +################################################################################ +# Once the path is set correctly, you can use the model as follow: + +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "disp" + +import trimesh import pygfx as gfx -teapot = trimesh.load(Path(__file__).parents[1] / "models" / "teapot.stl") +teapot = trimesh.load(model_dir / "teapot.stl") scene = gfx.Scene() +scene.add(gfx.AmbientLight(), gfx.DirectionalLight()) mesh = gfx.Mesh( gfx.trimesh_geometry(teapot), @@ -32,4 +57,5 @@ if __name__ == "__main__": - gfx.show(scene, up=gfx.linalg.Vector3(0, 0, 1)) + disp = gfx.Display() + disp.show(scene, up=gfx.linalg.Vector3(0, 0, 1)) diff --git a/examples/introductory/plot_offscreen.py b/examples/introductory/plot_offscreen.py index b2b5463de..ef4019f32 100644 --- a/examples/introductory/plot_offscreen.py +++ b/examples/introductory/plot_offscreen.py @@ -8,6 +8,7 @@ Note that one can also render to a ``pygfx.Texture`` and use that texture to decorate an object in another scene. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio import pygfx as gfx diff --git a/examples/introductory/plot_orbit_camera.py b/examples/introductory/plot_orbit_camera.py index 893a68d2e..e38516ef7 100644 --- a/examples/introductory/plot_orbit_camera.py +++ b/examples/introductory/plot_orbit_camera.py @@ -7,6 +7,7 @@ Press 's' to save the state, and press 'l' to load the last saved state. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/introductory/points_basic.py b/examples/introductory/plot_points_basic.py similarity index 95% rename from examples/introductory/points_basic.py rename to examples/introductory/plot_points_basic.py index 0988981fe..069de76c6 100644 --- a/examples/introductory/points_basic.py +++ b/examples/introductory/plot_points_basic.py @@ -5,6 +5,7 @@ Render Points """ +# sphinx_gallery_pygfx_render = True import numpy as np diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index e88bbd30c..c6f841cea 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -14,7 +14,7 @@ default_config = { "render": False, # if True, render an image "animate": False, # if True, render a GIF (TODO) - "target_name": "disp", # the display to use + "target_name": "renderer", # the display to use # GIF settings "duration": 3, # how many seconds to record "loop": 0, # loop forever From f984904c5a563f459f9e94e4240260dd9ecb486c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 13:25:16 +0100 Subject: [PATCH 15/54] fix broken gallery examples --- examples/dynamic_env_map.py | 3 ++ examples/feature_demo/plot_pbr.py | 31 ++++++++++++++----- examples/feature_demo/plot_show_stl.py | 31 +++++++++++++++++-- .../introductory/plot_object_bounding_box.py | 2 +- ...ost_processing1.py => post_processing1.py} | 0 ...ost_processing2.py => post_processing2.py} | 0 .../plot_sponza_scene.py => sponza_scene.py} | 0 7 files changed, 56 insertions(+), 11 deletions(-) rename examples/{feature_demo/plot_post_processing1.py => post_processing1.py} (100%) rename examples/{feature_demo/plot_post_processing2.py => post_processing2.py} (100%) rename examples/{feature_demo/plot_sponza_scene.py => sponza_scene.py} (100%) diff --git a/examples/dynamic_env_map.py b/examples/dynamic_env_map.py index 03c943be2..1b3fecc86 100644 --- a/examples/dynamic_env_map.py +++ b/examples/dynamic_env_map.py @@ -1,4 +1,7 @@ """ +Dynamic Environment Map +======================= + This example shows a dynamic environment map used for MeshStandardMaterial. The environment map is automatically be updated from the scene by a CubeCamera. """ diff --git a/examples/feature_demo/plot_pbr.py b/examples/feature_demo/plot_pbr.py index 3fe9447b7..5ba93db5e 100644 --- a/examples/feature_demo/plot_pbr.py +++ b/examples/feature_demo/plot_pbr.py @@ -7,8 +7,31 @@ The cubemap of skybox is also the environment cubemap of the helmet. """ +################################################################################ +# .. warning:: +# An external model is needed to run this example. +# +# To run this example, you need a model from the source repo's example +# folder. If you are running this example from a local copy of the code (dev +# install) no further actions are needed. Otherwise, you may have to replace +# the path below to point to the location of the model. + +import os from pathlib import Path +try: + # modify this line if your model is located elsewhere + model_dir = Path(__file__).parents[1] / "models" +except NameError: + # compatibility with sphinx-gallery + model_dir = Path(os.getcwd()).parent / "models" + + +################################################################################ +# Once the path is set correctly, you can use the model as follows: + +# sphinx_gallery_pygfx_render = True + import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx @@ -44,13 +67,7 @@ # Load meshes, and apply env map # Note that this lits the helmet already -gltf_path = ( - Path(__file__).parents[1] - / "models" - / "DamagedHelmet" - / "glTF" - / "DamagedHelmet.gltf" -) +gltf_path = model_dir / "DamagedHelmet" / "glTF" / "DamagedHelmet.gltf" meshes = gfx.load_scene(gltf_path) scene.add(*meshes) m = meshes[0] # this example has just one mesh diff --git a/examples/feature_demo/plot_show_stl.py b/examples/feature_demo/plot_show_stl.py index 981262332..0f8491df8 100644 --- a/examples/feature_demo/plot_show_stl.py +++ b/examples/feature_demo/plot_show_stl.py @@ -4,14 +4,38 @@ Demonstrates show utility with an STL file """ + +################################################################################ +# .. warning:: +# An external model is needed to run this example. +# +# To run this example, you need a model from the source repo's example +# folder. If you are running this example from a local copy of the code (dev +# install) no further actions are needed. Otherwise, you may have to replace +# the path below to point to the location of the model. + +import os from pathlib import Path -import trimesh +try: + # modify this line if your model is located elsewhere + model_dir = Path(__file__).parents[1] / "models" +except NameError: + # compatibility with sphinx-gallery + model_dir = Path(os.getcwd()).parent / "models" + +################################################################################ +# Once the path is set correctly, you can use the model as follows: + +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "disp" + +import trimesh import pygfx as gfx -TEAPOT = Path(__file__).parents[1] / "models" / "teapot.stl" +TEAPOT = model_dir / "teapot.stl" teapot = trimesh.load(TEAPOT) @@ -21,4 +45,5 @@ ) if __name__ == "__main__": - gfx.show(mesh, up=gfx.linalg.Vector3(0, 0, 1)) + disp = gfx.Display() + disp.show(mesh, up=gfx.linalg.Vector3(0, 0, 1)) diff --git a/examples/introductory/plot_object_bounding_box.py b/examples/introductory/plot_object_bounding_box.py index ac507bc26..cf28e0a74 100644 --- a/examples/introductory/plot_object_bounding_box.py +++ b/examples/introductory/plot_object_bounding_box.py @@ -26,7 +26,7 @@ ################################################################################ -# Once the path is set correctly, you can use the model as follow: +# Once the path is set correctly, you can use the model as follows: # sphinx_gallery_pygfx_render = True # sphinx_gallery_pygfx_target_name = "disp" diff --git a/examples/feature_demo/plot_post_processing1.py b/examples/post_processing1.py similarity index 100% rename from examples/feature_demo/plot_post_processing1.py rename to examples/post_processing1.py diff --git a/examples/feature_demo/plot_post_processing2.py b/examples/post_processing2.py similarity index 100% rename from examples/feature_demo/plot_post_processing2.py rename to examples/post_processing2.py diff --git a/examples/feature_demo/plot_sponza_scene.py b/examples/sponza_scene.py similarity index 100% rename from examples/feature_demo/plot_sponza_scene.py rename to examples/sponza_scene.py From 42f7f3e5a21a9585074f5b65e31b1751517b8d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 14:21:42 +0100 Subject: [PATCH 16/54] add gallery render comment to examples --- examples/feature_demo/plot_collection_line.py | 2 ++ examples/feature_demo/plot_colormap_channels.py | 2 ++ examples/feature_demo/plot_colormap_image.py | 2 ++ examples/feature_demo/plot_colormap_mesh.py | 2 ++ examples/feature_demo/plot_custom_object1.py | 1 + examples/feature_demo/plot_custom_object2.py | 2 ++ examples/feature_demo/plot_custom_object3.py | 2 ++ examples/feature_demo/plot_cylinder.py | 2 ++ examples/feature_demo/plot_flat_shaded_torus.py | 2 ++ examples/feature_demo/plot_geometry_cubes.py | 2 ++ examples/feature_demo/plot_geometry_image.py | 2 ++ examples/feature_demo/plot_geometry_klein_bottle.py | 2 ++ examples/feature_demo/plot_geometry_plane.py | 2 ++ examples/feature_demo/plot_geometry_polyhedron.py | 1 + .../feature_demo/plot_geometry_polyhedron_subdivisions.py | 6 +++++- examples/feature_demo/plot_geometry_torus_knot.py | 1 + examples/feature_demo/plot_helpers_gizmo.py | 1 + examples/feature_demo/plot_image_click_events.py | 2 ++ examples/feature_demo/plot_image_plus_points.py | 2 ++ examples/feature_demo/plot_instancing_mesh.py | 1 + examples/feature_demo/plot_light_directional_shadow.py | 1 + examples/feature_demo/plot_light_shadow.py | 1 + examples/feature_demo/plot_light_spotlight_shadows.py | 4 +++- examples/feature_demo/plot_light_spotlights.py | 4 +++- examples/feature_demo/plot_line_basic.py | 2 ++ examples/feature_demo/plot_line_performance.py | 1 + examples/feature_demo/plot_line_segments.py | 1 + examples/feature_demo/plot_line_thick.py | 1 + examples/feature_demo/plot_manual_matrix_update.py | 1 + examples/feature_demo/plot_mesh_depth_material.py | 2 ++ examples/feature_demo/plot_mesh_slice.py | 1 + examples/feature_demo/plot_multi_select.py | 1 + examples/feature_demo/plot_multi_slice1.py | 1 + examples/feature_demo/plot_multi_slice2.py | 1 + examples/feature_demo/plot_panzoom_camera.py | 1 + examples/feature_demo/plot_pbr2.py | 1 + examples/feature_demo/plot_physical_color.py | 1 + examples/feature_demo/plot_picking_color.py | 1 + examples/feature_demo/plot_picking_mesh.py | 1 + examples/feature_demo/plot_picking_points.py | 1 + examples/feature_demo/plot_scene_in_a_scene.py | 2 ++ examples/feature_demo/plot_scene_overlay.py | 1 + examples/feature_demo/plot_scene_subplots1.py | 1 + examples/feature_demo/plot_scene_subplots2.py | 1 + examples/feature_demo/plot_scene_subplots_video.py | 1 + examples/feature_demo/plot_show_image.py | 1 + examples/feature_demo/plot_show_scene.py | 5 ++++- examples/feature_demo/plot_skybox.py | 1 + examples/feature_demo/plot_spheres.py | 1 + examples/feature_demo/plot_synced_video.py | 1 + examples/feature_demo/plot_transparency1.py | 1 + examples/feature_demo/plot_transparency2.py | 1 + examples/feature_demo/plot_volume_render1.py | 1 + examples/feature_demo/plot_volume_render2.py | 1 + examples/feature_demo/plot_volume_slice1.py | 1 + examples/feature_demo/plot_volume_slice2.py | 1 + examples/feature_demo/plot_volume_slice3.py | 1 + examples/feature_demo/plot_volume_slice4.py | 1 + examples/feature_demo/plot_wireframe1.py | 1 + examples/feature_demo/plot_wireframe2.py | 1 + examples/feature_demo/plot_wireframe_material.py | 2 ++ examples/feature_demo/plot_world_bounding_box.py | 1 + examples/{feature_demo => introductory}/plot_show_util.py | 5 ++++- .../{feature_demo/plot_two_canvases.py => two_canvases.py} | 0 examples/validation/plot_validate_box.py | 1 + examples/validation/plot_validate_color.py | 1 + examples/validation/plot_validate_culling.py | 1 + examples/validation/plot_validate_depth_clipping.py | 2 ++ examples/validation/plot_validate_helpers1.py | 1 + examples/validation/plot_validate_helpers2.py | 1 + examples/validation/plot_validate_image1.py | 1 + examples/validation/plot_validate_image2.py | 1 + examples/validation/plot_validate_image_colormap.py | 1 + examples/validation/plot_validate_light_shadow.py | 1 + examples/validation/plot_validate_mesh_colormap.py | 1 + examples/validation/plot_validate_ndc.py | 2 ++ examples/validation/plot_validate_volume.py | 1 + 77 files changed, 110 insertions(+), 5 deletions(-) rename examples/{feature_demo => introductory}/plot_show_util.py (62%) rename examples/{feature_demo/plot_two_canvases.py => two_canvases.py} (100%) diff --git a/examples/feature_demo/plot_collection_line.py b/examples/feature_demo/plot_collection_line.py index e698b402e..092f9a68e 100644 --- a/examples/feature_demo/plot_collection_line.py +++ b/examples/feature_demo/plot_collection_line.py @@ -7,6 +7,8 @@ """ # run_example = false - because it takes too long and times out +# sphinx_gallery_pygfx_render = True + import time # noqa import numpy as np diff --git a/examples/feature_demo/plot_colormap_channels.py b/examples/feature_demo/plot_colormap_channels.py index 87673450a..e21485ce7 100644 --- a/examples/feature_demo/plot_colormap_channels.py +++ b/examples/feature_demo/plot_colormap_channels.py @@ -5,6 +5,8 @@ Example demonstrating colormaps in 4 modes: grayscale, gray+alpha, RGB, RGBA. """ +# sphinx_gallery_pygfx_render = True + import numpy as np from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_colormap_image.py b/examples/feature_demo/plot_colormap_image.py index f2727c1b3..7dd17ce34 100644 --- a/examples/feature_demo/plot_colormap_image.py +++ b/examples/feature_demo/plot_colormap_image.py @@ -5,6 +5,8 @@ Example demonstrating different colormap dimensions on an image. """ +# sphinx_gallery_pygfx_render = True + import numpy as np import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_colormap_mesh.py b/examples/feature_demo/plot_colormap_mesh.py index ab7736218..3835547c7 100644 --- a/examples/feature_demo/plot_colormap_mesh.py +++ b/examples/feature_demo/plot_colormap_mesh.py @@ -9,6 +9,8 @@ this can also be applied for points and lines. """ +# sphinx_gallery_pygfx_render = True + import numpy as np import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_custom_object1.py b/examples/feature_demo/plot_custom_object1.py index 58ab6e176..c3e79dff4 100644 --- a/examples/feature_demo/plot_custom_object1.py +++ b/examples/feature_demo/plot_custom_object1.py @@ -96,6 +96,7 @@ def code_fragment(self): # %% Setup scene +# sphinx_gallery_pygfx_render = True renderer = gfx.WgpuRenderer(WgpuCanvas()) camera = gfx.NDCCamera() # This material does not actually use the camera diff --git a/examples/feature_demo/plot_custom_object2.py b/examples/feature_demo/plot_custom_object2.py index 3f622036b..680727ffd 100644 --- a/examples/feature_demo/plot_custom_object2.py +++ b/examples/feature_demo/plot_custom_object2.py @@ -128,6 +128,8 @@ def code_fragment(self): # %% Setup scene +# sphinx_gallery_pygfx_render = True + renderer = gfx.WgpuRenderer(WgpuCanvas()) camera = gfx.OrthographicCamera(10, 10) diff --git a/examples/feature_demo/plot_custom_object3.py b/examples/feature_demo/plot_custom_object3.py index 0db1fd752..e0b960a8f 100644 --- a/examples/feature_demo/plot_custom_object3.py +++ b/examples/feature_demo/plot_custom_object3.py @@ -168,6 +168,8 @@ def code_fragment(self): # %% Setup scene +# sphinx_gallery_pygfx_render = True + renderer = gfx.WgpuRenderer(WgpuCanvas()) camera = gfx.OrthographicCamera(10, 10) diff --git a/examples/feature_demo/plot_cylinder.py b/examples/feature_demo/plot_cylinder.py index 4e332e26f..e1d99b6ff 100644 --- a/examples/feature_demo/plot_cylinder.py +++ b/examples/feature_demo/plot_cylinder.py @@ -5,6 +5,8 @@ Example showing different types of geometric cylinders. """ +# sphinx_gallery_pygfx_render = True + import numpy as np from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_flat_shaded_torus.py b/examples/feature_demo/plot_flat_shaded_torus.py index 0e38f2c35..b80b8884a 100644 --- a/examples/feature_demo/plot_flat_shaded_torus.py +++ b/examples/feature_demo/plot_flat_shaded_torus.py @@ -5,6 +5,8 @@ Example showing a Torus knot, using flat shading. """ +# sphinx_gallery_pygfx_render = True + from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_geometry_cubes.py b/examples/feature_demo/plot_geometry_cubes.py index 8784a0935..b09239815 100644 --- a/examples/feature_demo/plot_geometry_cubes.py +++ b/examples/feature_demo/plot_geometry_cubes.py @@ -5,6 +5,8 @@ Example showing multiple rotating cubes. This also tests the depth buffer. """ +# sphinx_gallery_pygfx_render = True + import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_geometry_image.py b/examples/feature_demo/plot_geometry_image.py index e2167c0ca..ee38035ee 100644 --- a/examples/feature_demo/plot_geometry_image.py +++ b/examples/feature_demo/plot_geometry_image.py @@ -5,6 +5,8 @@ Show an image. """ +# sphinx_gallery_pygfx_render = True + import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_geometry_klein_bottle.py b/examples/feature_demo/plot_geometry_klein_bottle.py index 43d784a95..ead86bb0f 100644 --- a/examples/feature_demo/plot_geometry_klein_bottle.py +++ b/examples/feature_demo/plot_geometry_klein_bottle.py @@ -5,6 +5,8 @@ Example showing a Klein Bottle. """ +# sphinx_gallery_pygfx_render = True + from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_geometry_plane.py b/examples/feature_demo/plot_geometry_plane.py index f7d1aedd2..6fa0b6dd2 100644 --- a/examples/feature_demo/plot_geometry_plane.py +++ b/examples/feature_demo/plot_geometry_plane.py @@ -5,6 +5,8 @@ Use a plane geometry to show a texture, which is continuously updated to show video. """ +# sphinx_gallery_pygfx_render = True + import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_geometry_polyhedron.py b/examples/feature_demo/plot_geometry_polyhedron.py index 721e82a3a..5adccb0ee 100644 --- a/examples/feature_demo/plot_geometry_polyhedron.py +++ b/examples/feature_demo/plot_geometry_polyhedron.py @@ -4,6 +4,7 @@ Example showing multiple rotating polyhedrons. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_geometry_polyhedron_subdivisions.py b/examples/feature_demo/plot_geometry_polyhedron_subdivisions.py index 539fa497c..0c980d817 100644 --- a/examples/feature_demo/plot_geometry_polyhedron_subdivisions.py +++ b/examples/feature_demo/plot_geometry_polyhedron_subdivisions.py @@ -5,6 +5,9 @@ Example showing subdivided polyhedrons. """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "disp" + import pygfx as gfx @@ -23,4 +26,5 @@ if __name__ == "__main__": - gfx.show(scene, up=gfx.linalg.Vector3(0, 0, 1)) + disp = gfx.Display() + disp.show(scene, up=gfx.linalg.Vector3(0, 0, 1)) diff --git a/examples/feature_demo/plot_geometry_torus_knot.py b/examples/feature_demo/plot_geometry_torus_knot.py index 684b70581..72d33110c 100644 --- a/examples/feature_demo/plot_geometry_torus_knot.py +++ b/examples/feature_demo/plot_geometry_torus_knot.py @@ -4,6 +4,7 @@ Example showing a Torus knot, with a texture and lighting. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_helpers_gizmo.py b/examples/feature_demo/plot_helpers_gizmo.py index ddcca87e7..06edc44f2 100644 --- a/examples/feature_demo/plot_helpers_gizmo.py +++ b/examples/feature_demo/plot_helpers_gizmo.py @@ -5,6 +5,7 @@ Example to demonstrate the Gizmo that can be used to transform world objects. Click the center sphere to toggle between object-space, world-space, and screen-space. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_image_click_events.py b/examples/feature_demo/plot_image_click_events.py index dc0cd874a..b89355382 100644 --- a/examples/feature_demo/plot_image_click_events.py +++ b/examples/feature_demo/plot_image_click_events.py @@ -16,6 +16,8 @@ # %% add image +# sphinx_gallery_pygfx_render = True + im = iio.imread("imageio:astronaut.png") image = gfx.Image( diff --git a/examples/feature_demo/plot_image_plus_points.py b/examples/feature_demo/plot_image_plus_points.py index 571d50deb..55c6ab7c9 100644 --- a/examples/feature_demo/plot_image_plus_points.py +++ b/examples/feature_demo/plot_image_plus_points.py @@ -25,6 +25,8 @@ # %% add points +# sphinx_gallery_pygfx_render = True + xx = [182, 180, 161, 153, 191, 237, 293, 300, 272, 267, 254] yy = [145, 131, 112, 59, 29, 14, 48, 91, 136, 137, 172] diff --git a/examples/feature_demo/plot_instancing_mesh.py b/examples/feature_demo/plot_instancing_mesh.py index 54a24ab55..7356fcf31 100644 --- a/examples/feature_demo/plot_instancing_mesh.py +++ b/examples/feature_demo/plot_instancing_mesh.py @@ -4,6 +4,7 @@ Example rendering the same mesh object multiple times, using instancing. """ +# sphinx_gallery_pygfx_render = True import numpy as np import imageio.v3 as iio diff --git a/examples/feature_demo/plot_light_directional_shadow.py b/examples/feature_demo/plot_light_directional_shadow.py index c83bd8939..9279fb275 100644 --- a/examples/feature_demo/plot_light_directional_shadow.py +++ b/examples/feature_demo/plot_light_directional_shadow.py @@ -8,6 +8,7 @@ the edge of the view frustum of the camera have partial shadows, while the cubes outside the view frustum of the camera will not cast shadows. """ +# sphinx_gallery_pygfx_render = True import math diff --git a/examples/feature_demo/plot_light_shadow.py b/examples/feature_demo/plot_light_shadow.py index e97fc0e35..f56ff9461 100644 --- a/examples/feature_demo/plot_light_shadow.py +++ b/examples/feature_demo/plot_light_shadow.py @@ -6,6 +6,7 @@ This example demonstrates the effects of directional light shadows (from DirectionalLight) and omnidirectional shadows (from PointLight). """ +# sphinx_gallery_pygfx_render = True import time import math diff --git a/examples/feature_demo/plot_light_spotlight_shadows.py b/examples/feature_demo/plot_light_spotlight_shadows.py index ffe38c160..54519d991 100644 --- a/examples/feature_demo/plot_light_spotlight_shadows.py +++ b/examples/feature_demo/plot_light_spotlight_shadows.py @@ -6,6 +6,7 @@ Spotlights and shadows examnple """ +# sphinx_gallery_pygfx_render = True import time import math @@ -160,8 +161,9 @@ def animate(): renderer.request_draw() renderer.request_draw(animate) + return renderer if __name__ == "__main__": - init_scene() + renderer = init_scene() run() diff --git a/examples/feature_demo/plot_light_spotlights.py b/examples/feature_demo/plot_light_spotlights.py index 1b5a3c754..55104b844 100644 --- a/examples/feature_demo/plot_light_spotlights.py +++ b/examples/feature_demo/plot_light_spotlights.py @@ -6,6 +6,7 @@ Spotlights example. """ +# sphinx_gallery_pygfx_render = True import time import math @@ -147,8 +148,9 @@ def animate(): renderer.request_draw() renderer.request_draw(animate) + return renderer if __name__ == "__main__": - init_scene() + renderer = init_scene() run() diff --git a/examples/feature_demo/plot_line_basic.py b/examples/feature_demo/plot_line_basic.py index edf9d4f1f..b1bfb6608 100644 --- a/examples/feature_demo/plot_line_basic.py +++ b/examples/feature_demo/plot_line_basic.py @@ -5,6 +5,8 @@ Some basic line drawing. """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "canvas" import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_line_performance.py b/examples/feature_demo/plot_line_performance.py index e70f4c112..79d2fb741 100644 --- a/examples/feature_demo/plot_line_performance.py +++ b/examples/feature_demo/plot_line_performance.py @@ -4,6 +4,7 @@ Display a line depicting a noisy signal consisting of a lot of points. """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_line_segments.py b/examples/feature_demo/plot_line_segments.py index cce7ca2d9..59c7a105d 100644 --- a/examples/feature_demo/plot_line_segments.py +++ b/examples/feature_demo/plot_line_segments.py @@ -5,6 +5,7 @@ Display line segments. Can be useful e.g. for visializing vector fields. """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_line_thick.py b/examples/feature_demo/plot_line_thick.py index 24146431e..2bc3c25b2 100644 --- a/examples/feature_demo/plot_line_thick.py +++ b/examples/feature_demo/plot_line_thick.py @@ -4,6 +4,7 @@ Display very thick lines to show how lines stay pretty on large scales. """ +# sphinx_gallery_pygfx_render = True import random from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_manual_matrix_update.py b/examples/feature_demo/plot_manual_matrix_update.py index 6a8757a53..ed8210a61 100644 --- a/examples/feature_demo/plot_manual_matrix_update.py +++ b/examples/feature_demo/plot_manual_matrix_update.py @@ -5,6 +5,7 @@ Example showing transform control flow without matrix auto updating. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_mesh_depth_material.py b/examples/feature_demo/plot_mesh_depth_material.py index 8944fdd5b..cd9a1b1fd 100644 --- a/examples/feature_demo/plot_mesh_depth_material.py +++ b/examples/feature_demo/plot_mesh_depth_material.py @@ -104,6 +104,8 @@ def code_fragment(self): # %% Setup scene +# sphinx_gallery_pygfx_render = True + renderer = gfx.WgpuRenderer(WgpuCanvas(size=(640, 480))) camera = gfx.PerspectiveCamera(45, 640 / 480, 8, 12) camera.position.z = 10 diff --git a/examples/feature_demo/plot_mesh_slice.py b/examples/feature_demo/plot_mesh_slice.py index 00c42dd36..88b4b0008 100644 --- a/examples/feature_demo/plot_mesh_slice.py +++ b/examples/feature_demo/plot_mesh_slice.py @@ -4,6 +4,7 @@ Example showing off the mesh slice material. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_multi_select.py b/examples/feature_demo/plot_multi_select.py index 3f5427570..ec5f5580c 100644 --- a/examples/feature_demo/plot_multi_select.py +++ b/examples/feature_demo/plot_multi_select.py @@ -10,6 +10,7 @@ all the items from that group (because the group has a double-click event handler). Holding shift will add to the selection. """ +# sphinx_gallery_pygfx_render = True from functools import partial from random import randint, random diff --git a/examples/feature_demo/plot_multi_slice1.py b/examples/feature_demo/plot_multi_slice1.py index 22a71e9b7..0b3277ada 100644 --- a/examples/feature_demo/plot_multi_slice1.py +++ b/examples/feature_demo/plot_multi_slice1.py @@ -6,6 +6,7 @@ This example uses a mesh object with custom texture coordinates. This is a generic approach. See multi_slice2.py for a simpler way. """ +# sphinx_gallery_pygfx_render = True from time import time diff --git a/examples/feature_demo/plot_multi_slice2.py b/examples/feature_demo/plot_multi_slice2.py index 5fff95a44..b24a97833 100644 --- a/examples/feature_demo/plot_multi_slice2.py +++ b/examples/feature_demo/plot_multi_slice2.py @@ -8,6 +8,7 @@ produces an implicit geometry defined by the volume data. See multi_slice1.py for a more generic approach. """ +# sphinx_gallery_pygfx_render = True from time import time diff --git a/examples/feature_demo/plot_panzoom_camera.py b/examples/feature_demo/plot_panzoom_camera.py index 39a4d01df..607aa7809 100644 --- a/examples/feature_demo/plot_panzoom_camera.py +++ b/examples/feature_demo/plot_panzoom_camera.py @@ -7,6 +7,7 @@ Press 's' to save the state, and press 'l' to load the last saved state. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_pbr2.py b/examples/feature_demo/plot_pbr2.py index 04cfc03ba..25c35c95e 100644 --- a/examples/feature_demo/plot_pbr2.py +++ b/examples/feature_demo/plot_pbr2.py @@ -7,6 +7,7 @@ metalness and roughness. Every second sphere has an IBL environment map on it. """ # run_example = false +# sphinx_gallery_pygfx_render = True import time import math diff --git a/examples/feature_demo/plot_physical_color.py b/examples/feature_demo/plot_physical_color.py index ac3e1de9b..ca9a314af 100644 --- a/examples/feature_demo/plot_physical_color.py +++ b/examples/feature_demo/plot_physical_color.py @@ -10,6 +10,7 @@ * An image in physical colorspace, shows up too dark. * An image in physical colorspace, rendered correctly. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_picking_color.py b/examples/feature_demo/plot_picking_color.py index 3b1747121..5beae1984 100644 --- a/examples/feature_demo/plot_picking_color.py +++ b/examples/feature_demo/plot_picking_color.py @@ -5,6 +5,7 @@ Example showing picking the color from the scene. Depending on the object being clicked, more detailed picking info is available. """ +# sphinx_gallery_pygfx_render = True import numpy as np import imageio.v3 as iio diff --git a/examples/feature_demo/plot_picking_mesh.py b/examples/feature_demo/plot_picking_mesh.py index a98dae2b1..c29f26923 100644 --- a/examples/feature_demo/plot_picking_mesh.py +++ b/examples/feature_demo/plot_picking_mesh.py @@ -5,6 +5,7 @@ Example showing picking a mesh. Showing two meshes that can be clicked on. Upon clicking, the vertex closest to the pick location is moved. """ +# sphinx_gallery_pygfx_render = True # todo: if we have per-vertex coloring, we can paint on the mesh instead :D diff --git a/examples/feature_demo/plot_picking_points.py b/examples/feature_demo/plot_picking_points.py index a40069d65..034c33077 100644 --- a/examples/feature_demo/plot_picking_points.py +++ b/examples/feature_demo/plot_picking_points.py @@ -5,6 +5,7 @@ Example showing picking points. When clicking on a point, it's location is changed. With a small change, a line is shown instead. """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_scene_in_a_scene.py b/examples/feature_demo/plot_scene_in_a_scene.py index 35fd209b2..a07d0bb1e 100644 --- a/examples/feature_demo/plot_scene_in_a_scene.py +++ b/examples/feature_demo/plot_scene_in_a_scene.py @@ -11,6 +11,8 @@ The sub-scene is rendered to a texture, and that texture is used for the surface of the cube in the outer scene. """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "renderer2" import numpy as np import imageio.v3 as iio diff --git a/examples/feature_demo/plot_scene_overlay.py b/examples/feature_demo/plot_scene_overlay.py index 04d843b9f..4b80b01fd 100644 --- a/examples/feature_demo/plot_scene_overlay.py +++ b/examples/feature_demo/plot_scene_overlay.py @@ -7,6 +7,7 @@ The idea is to render both scenes, but clear the depth before rendering the overlay, so that it's always on top. """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_scene_subplots1.py b/examples/feature_demo/plot_scene_subplots1.py index 73cf263ee..fb708fc30 100644 --- a/examples/feature_demo/plot_scene_subplots1.py +++ b/examples/feature_demo/plot_scene_subplots1.py @@ -8,6 +8,7 @@ uses a low-level approach without using the Viewport object. See scene_subplot2.py for a slightly higher-level approach. """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_scene_subplots2.py b/examples/feature_demo/plot_scene_subplots2.py index 24f9046e0..d6e7afcbc 100644 --- a/examples/feature_demo/plot_scene_subplots2.py +++ b/examples/feature_demo/plot_scene_subplots2.py @@ -4,6 +4,7 @@ Like scene_side_by_side, but now with a more plot-like idea, and mouse interaction. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_scene_subplots_video.py b/examples/feature_demo/plot_scene_subplots_video.py index 93205d5ba..a9db90f27 100644 --- a/examples/feature_demo/plot_scene_subplots_video.py +++ b/examples/feature_demo/plot_scene_subplots_video.py @@ -5,6 +5,7 @@ An example combining `synced_video.py` with subplots. Double click to re-center the images. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_show_image.py b/examples/feature_demo/plot_show_image.py index 0fdefc78f..c5bacdf36 100644 --- a/examples/feature_demo/plot_show_image.py +++ b/examples/feature_demo/plot_show_image.py @@ -4,6 +4,7 @@ Use camera.show_object to ensure the Image is in view. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_show_scene.py b/examples/feature_demo/plot_show_scene.py index 5b3cbe207..837693c41 100644 --- a/examples/feature_demo/plot_show_scene.py +++ b/examples/feature_demo/plot_show_scene.py @@ -4,6 +4,8 @@ Demonstrates show utility for a scene """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "disp" import imageio.v3 as iio import pygfx as gfx @@ -24,4 +26,5 @@ scene.add(background) if __name__ == "__main__": - gfx.show(scene) + disp = gfx.Display() + disp.show(scene) diff --git a/examples/feature_demo/plot_skybox.py b/examples/feature_demo/plot_skybox.py index 505381511..9b9cec30e 100644 --- a/examples/feature_demo/plot_skybox.py +++ b/examples/feature_demo/plot_skybox.py @@ -6,6 +6,7 @@ Inspired by https://github.com/gfx-rs/wgpu-rs/blob/master/examples/skybox/main.rs """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_spheres.py b/examples/feature_demo/plot_spheres.py index 82aad0577..f175f1d67 100644 --- a/examples/feature_demo/plot_spheres.py +++ b/examples/feature_demo/plot_spheres.py @@ -4,6 +4,7 @@ Example showing different types of geometric cylinders. """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_synced_video.py b/examples/feature_demo/plot_synced_video.py index 7d3f39d50..f45a4a6b6 100644 --- a/examples/feature_demo/plot_synced_video.py +++ b/examples/feature_demo/plot_synced_video.py @@ -4,6 +4,7 @@ Example demonstrating synced video rendering """ +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_transparency1.py b/examples/feature_demo/plot_transparency1.py index ef97b4d88..9c6c1cee6 100644 --- a/examples/feature_demo/plot_transparency1.py +++ b/examples/feature_demo/plot_transparency1.py @@ -6,6 +6,7 @@ Press space to toggle the order of the planes. Press 1-6 to select the blend mode. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_transparency2.py b/examples/feature_demo/plot_transparency2.py index e750e0c51..6e620d9e3 100644 --- a/examples/feature_demo/plot_transparency2.py +++ b/examples/feature_demo/plot_transparency2.py @@ -6,6 +6,7 @@ Press space to toggle the order of the planes. Press 1-6 to select the blend mode. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_volume_render1.py b/examples/feature_demo/plot_volume_render1.py index b4756c239..1946afa89 100644 --- a/examples/feature_demo/plot_volume_render1.py +++ b/examples/feature_demo/plot_volume_render1.py @@ -4,6 +4,7 @@ Render a volume. Shift-click to draw white blobs inside the volume. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio import numpy as np diff --git a/examples/feature_demo/plot_volume_render2.py b/examples/feature_demo/plot_volume_render2.py index 8a0e9483c..325b0a901 100644 --- a/examples/feature_demo/plot_volume_render2.py +++ b/examples/feature_demo/plot_volume_render2.py @@ -4,6 +4,7 @@ Render three volumes using different world transforms. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio import numpy as np diff --git a/examples/feature_demo/plot_volume_slice1.py b/examples/feature_demo/plot_volume_slice1.py index 9aac22aa8..b8d227f34 100644 --- a/examples/feature_demo/plot_volume_slice1.py +++ b/examples/feature_demo/plot_volume_slice1.py @@ -5,6 +5,7 @@ Render slices through a volume, by uploading to a 2D texture. Simple and ... slow. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_volume_slice2.py b/examples/feature_demo/plot_volume_slice2.py index 9c76b6958..22c6c6e63 100644 --- a/examples/feature_demo/plot_volume_slice2.py +++ b/examples/feature_demo/plot_volume_slice2.py @@ -5,6 +5,7 @@ Render slices through a volume, by creating a 3D texture, with 2D views. Simple and relatively fast, but no subslices. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_volume_slice3.py b/examples/feature_demo/plot_volume_slice3.py index 1fdb7bf82..0c97c5a6a 100644 --- a/examples/feature_demo/plot_volume_slice3.py +++ b/examples/feature_demo/plot_volume_slice3.py @@ -5,6 +5,7 @@ Render slices through a volume, by creating a 3D texture, and sampling onto a plane geometry. Simple, fast and subpixel! """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio import numpy as np diff --git a/examples/feature_demo/plot_volume_slice4.py b/examples/feature_demo/plot_volume_slice4.py index e18f90edf..70247368a 100644 --- a/examples/feature_demo/plot_volume_slice4.py +++ b/examples/feature_demo/plot_volume_slice4.py @@ -5,6 +5,7 @@ Render slices through a volume, by creating a 3D texture, and viewing it with a VolumeSliceMaterial. Easy because we can just define the view plane. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/feature_demo/plot_wireframe1.py b/examples/feature_demo/plot_wireframe1.py index 914453d45..8bd6af9be 100644 --- a/examples/feature_demo/plot_wireframe1.py +++ b/examples/feature_demo/plot_wireframe1.py @@ -8,6 +8,7 @@ producing a look of a metalic frame around a soft tube. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_wireframe2.py b/examples/feature_demo/plot_wireframe2.py index 3b7b6da5f..14d6f64c5 100644 --- a/examples/feature_demo/plot_wireframe2.py +++ b/examples/feature_demo/plot_wireframe2.py @@ -6,6 +6,7 @@ one for the front, bright blue and lit, and one for the back, unlit and gray. """ +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/feature_demo/plot_wireframe_material.py b/examples/feature_demo/plot_wireframe_material.py index 49aa2f093..0d9e653f4 100644 --- a/examples/feature_demo/plot_wireframe_material.py +++ b/examples/feature_demo/plot_wireframe_material.py @@ -150,6 +150,8 @@ def code_fragment(self): # %% Setup scene +# sphinx_gallery_pygfx_render = True + renderer = gfx.WgpuRenderer(WgpuCanvas(size=(640, 480))) camera = gfx.PerspectiveCamera(45, 640 / 480, 0.1, 100) camera.position.z = 10 diff --git a/examples/feature_demo/plot_world_bounding_box.py b/examples/feature_demo/plot_world_bounding_box.py index f0d7a8cb1..7679bbcac 100644 --- a/examples/feature_demo/plot_world_bounding_box.py +++ b/examples/feature_demo/plot_world_bounding_box.py @@ -6,6 +6,7 @@ Prints the world bounding box of the scene which used to trigger an Exception. """ +# sphinx_gallery_pygfx_render = True import imageio.v3 as iio import numpy as np diff --git a/examples/feature_demo/plot_show_util.py b/examples/introductory/plot_show_util.py similarity index 62% rename from examples/feature_demo/plot_show_util.py rename to examples/introductory/plot_show_util.py index 55074f44f..633bb72a2 100644 --- a/examples/feature_demo/plot_show_util.py +++ b/examples/introductory/plot_show_util.py @@ -4,6 +4,8 @@ Demonstrates show utility """ +# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_target_name = "disp" import pygfx as gfx @@ -13,4 +15,5 @@ ) if __name__ == "__main__": - gfx.show(cube) + disp = gfx.Display() + disp.show(cube) diff --git a/examples/feature_demo/plot_two_canvases.py b/examples/two_canvases.py similarity index 100% rename from examples/feature_demo/plot_two_canvases.py rename to examples/two_canvases.py diff --git a/examples/validation/plot_validate_box.py b/examples/validation/plot_validate_box.py index 27b880e81..03141665c 100644 --- a/examples/validation/plot_validate_box.py +++ b/examples/validation/plot_validate_box.py @@ -5,6 +5,7 @@ Example showing the box geometry. """ # test_example = true +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/validation/plot_validate_color.py b/examples/validation/plot_validate_color.py index 750b69440..1193a666c 100644 --- a/examples/validation/plot_validate_color.py +++ b/examples/validation/plot_validate_color.py @@ -6,6 +6,7 @@ similar output from e.g. Matplotlib. """ # test_example = true +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/validation/plot_validate_culling.py b/examples/validation/plot_validate_culling.py index f351316f4..706f31682 100644 --- a/examples/validation/plot_validate_culling.py +++ b/examples/validation/plot_validate_culling.py @@ -10,6 +10,7 @@ """ # test_example = true +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/validation/plot_validate_depth_clipping.py b/examples/validation/plot_validate_depth_clipping.py index cbbdbe514..4dd0adf11 100644 --- a/examples/validation/plot_validate_depth_clipping.py +++ b/examples/validation/plot_validate_depth_clipping.py @@ -37,6 +37,8 @@ # %% Create four planes near the z-clipping planes +# sphinx_gallery_pygfx_render = True + geometry = gfx.plane_geometry(1, 1) green_material = gfx.MeshBasicMaterial(color=(0, 0.8, 0.2, 1)) greener_material = gfx.MeshBasicMaterial(color=(0, 1, 0, 1)) diff --git a/examples/validation/plot_validate_helpers1.py b/examples/validation/plot_validate_helpers1.py index 5eec61328..13b00a8fd 100644 --- a/examples/validation/plot_validate_helpers1.py +++ b/examples/validation/plot_validate_helpers1.py @@ -10,6 +10,7 @@ * The blue axes (z) is not visible. """ # test_example = true +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/validation/plot_validate_helpers2.py b/examples/validation/plot_validate_helpers2.py index f4f443e6f..8504c4dd7 100644 --- a/examples/validation/plot_validate_helpers2.py +++ b/examples/validation/plot_validate_helpers2.py @@ -9,6 +9,7 @@ * The red box fits snugly around the grid. """ # test_example = true +# sphinx_gallery_pygfx_render = True from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx diff --git a/examples/validation/plot_validate_image1.py b/examples/validation/plot_validate_image1.py index 3421675bb..f7fbd3d3e 100644 --- a/examples/validation/plot_validate_image1.py +++ b/examples/validation/plot_validate_image1.py @@ -11,6 +11,7 @@ * The darker corner is in the top left. """ # test_example = true +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/validation/plot_validate_image2.py b/examples/validation/plot_validate_image2.py index 6b5f57bd0..379e31892 100644 --- a/examples/validation/plot_validate_image2.py +++ b/examples/validation/plot_validate_image2.py @@ -9,6 +9,7 @@ * The darker corner is in the bottom left. """ # test_example = true +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/validation/plot_validate_image_colormap.py b/examples/validation/plot_validate_image_colormap.py index a60d0f870..d7dfad345 100644 --- a/examples/validation/plot_validate_image_colormap.py +++ b/examples/validation/plot_validate_image_colormap.py @@ -8,6 +8,7 @@ * The bands should be red, green, and blue. """ # test_example = true +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/validation/plot_validate_light_shadow.py b/examples/validation/plot_validate_light_shadow.py index 7d63d9b04..37d1d615f 100644 --- a/examples/validation/plot_validate_light_shadow.py +++ b/examples/validation/plot_validate_light_shadow.py @@ -7,6 +7,7 @@ that all combinations are working properly. """ # test_example = true +# sphinx_gallery_pygfx_render = True import math diff --git a/examples/validation/plot_validate_mesh_colormap.py b/examples/validation/plot_validate_mesh_colormap.py index d083ad0c4..b42e562b0 100644 --- a/examples/validation/plot_validate_mesh_colormap.py +++ b/examples/validation/plot_validate_mesh_colormap.py @@ -8,6 +8,7 @@ * The right-most cylinder is smoothly colored matching its normal. """ # test_example = true +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run diff --git a/examples/validation/plot_validate_ndc.py b/examples/validation/plot_validate_ndc.py index 181bd9f40..8c1a7c134 100644 --- a/examples/validation/plot_validate_ndc.py +++ b/examples/validation/plot_validate_ndc.py @@ -84,6 +84,8 @@ def code_fragment(self): # %% Setup scene +# sphinx_gallery_pygfx_render = True + canvas = WgpuCanvas() renderer = gfx.WgpuRenderer(canvas) diff --git a/examples/validation/plot_validate_volume.py b/examples/validation/plot_validate_volume.py index 2b8e4beac..459a455f4 100644 --- a/examples/validation/plot_validate_volume.py +++ b/examples/validation/plot_validate_volume.py @@ -8,6 +8,7 @@ * The volume has its corners darker and its very center is brighter. """ # test_example = true +# sphinx_gallery_pygfx_render = True import numpy as np from wgpu.gui.auto import WgpuCanvas, run From 099b605680a61afea2a8c678c0b78590e324ecb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 14:22:59 +0100 Subject: [PATCH 17/54] sort new example --- .../plot_dynamic_env_map.py} | 2 ++ 1 file changed, 2 insertions(+) rename examples/{dynamic_env_map.py => feature_demo/plot_dynamic_env_map.py} (98%) diff --git a/examples/dynamic_env_map.py b/examples/feature_demo/plot_dynamic_env_map.py similarity index 98% rename from examples/dynamic_env_map.py rename to examples/feature_demo/plot_dynamic_env_map.py index 1b3fecc86..aaf30f076 100644 --- a/examples/dynamic_env_map.py +++ b/examples/feature_demo/plot_dynamic_env_map.py @@ -6,6 +6,8 @@ The environment map is automatically be updated from the scene by a CubeCamera. """ +# sphinx_gallery_pygfx_render = True + import time import math From 1d19b0eb4343732aa2fb3b42d4362553f0505af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 14:26:59 +0100 Subject: [PATCH 18/54] reorganize page layout --- docs/conf.py | 1 + examples/feature_demo/README.rst | 2 +- examples/other/README.rst | 5 +++++ examples/{ => other}/cube_qt.py | 0 examples/{ => other}/cube_wx.py | 0 examples/{ => other}/integration_qt.py | 0 examples/{ => other}/light_view.py | 0 examples/{ => other}/post_processing1.py | 0 examples/{ => other}/post_processing2.py | 0 examples/{ => other}/sponza_scene.py | 0 examples/{ => other}/text_with_qt.py | 0 examples/{ => other}/two_canvases.py | 0 12 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 examples/other/README.rst rename examples/{ => other}/cube_qt.py (100%) rename examples/{ => other}/cube_wx.py (100%) rename examples/{ => other}/integration_qt.py (100%) rename examples/{ => other}/light_view.py (100%) rename examples/{ => other}/post_processing1.py (100%) rename examples/{ => other}/post_processing2.py (100%) rename examples/{ => other}/sponza_scene.py (100%) rename examples/{ => other}/text_with_qt.py (100%) rename examples/{ => other}/two_canvases.py (100%) diff --git a/docs/conf.py b/docs/conf.py index 3f6832c17..618497fec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -81,6 +81,7 @@ def _check_objects_are_documented(): "../examples/introductory", "../examples/feature_demo", "../examples/validation", + "../examples/other", ] ), "remove_config_comments": True, diff --git a/examples/feature_demo/README.rst b/examples/feature_demo/README.rst index c83bf3372..147d11c11 100644 --- a/examples/feature_demo/README.rst +++ b/examples/feature_demo/README.rst @@ -1 +1 @@ -.. rubric:: Feature Examples +.. rubric:: Feature Demos diff --git a/examples/other/README.rst b/examples/other/README.rst new file mode 100644 index 000000000..cc20b3cfa --- /dev/null +++ b/examples/other/README.rst @@ -0,0 +1,5 @@ +.. rubric:: Other Examples + +.. note:: + The examples in this section are not rendered. Typically because they use a + backend that is not available on the CI runner. diff --git a/examples/cube_qt.py b/examples/other/cube_qt.py similarity index 100% rename from examples/cube_qt.py rename to examples/other/cube_qt.py diff --git a/examples/cube_wx.py b/examples/other/cube_wx.py similarity index 100% rename from examples/cube_wx.py rename to examples/other/cube_wx.py diff --git a/examples/integration_qt.py b/examples/other/integration_qt.py similarity index 100% rename from examples/integration_qt.py rename to examples/other/integration_qt.py diff --git a/examples/light_view.py b/examples/other/light_view.py similarity index 100% rename from examples/light_view.py rename to examples/other/light_view.py diff --git a/examples/post_processing1.py b/examples/other/post_processing1.py similarity index 100% rename from examples/post_processing1.py rename to examples/other/post_processing1.py diff --git a/examples/post_processing2.py b/examples/other/post_processing2.py similarity index 100% rename from examples/post_processing2.py rename to examples/other/post_processing2.py diff --git a/examples/sponza_scene.py b/examples/other/sponza_scene.py similarity index 100% rename from examples/sponza_scene.py rename to examples/other/sponza_scene.py diff --git a/examples/text_with_qt.py b/examples/other/text_with_qt.py similarity index 100% rename from examples/text_with_qt.py rename to examples/other/text_with_qt.py diff --git a/examples/two_canvases.py b/examples/other/two_canvases.py similarity index 100% rename from examples/two_canvases.py rename to examples/other/two_canvases.py From 1e02ffd04d98cf240154eb9cd6cb538235abe56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 17:18:17 +0100 Subject: [PATCH 19/54] update path to validation examples --- examples/tests/test_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index 4b2d81eff..76a79cddb 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -80,7 +80,7 @@ def test_examples_screenshots(module, pytestconfig, force_offscreen, mock_time): """Run every example marked for testing.""" # render - example = importlib.import_module(f"examples.{module}") + example = importlib.import_module(f"examples.validation.{module}") img = example.renderer.target.draw() # check if _something_ was rendered From 4bf5f56f6e7e86f25c8083dea0b5ba254ead9561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 17:47:45 +0100 Subject: [PATCH 20/54] install lavapipe in doc builds --- .github/workflows/ci.yml | 6 ++++++ docs/docs_requirements.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea5d4f86f..f18f4b338 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,12 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.9 + - name: Install llvmpipe and lavapipe for offscreen canvas + run: | + sudo apt-get update -y -qq + sudo add-apt-repository ppa:oibaf/graphics-drivers -y + sudo apt-get update -y -qq + sudo apt install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers - name: Install dev dependencies run: | python -m pip install --upgrade pip diff --git a/docs/docs_requirements.txt b/docs/docs_requirements.txt index d361288b4..a0731048a 100644 --- a/docs/docs_requirements.txt +++ b/docs/docs_requirements.txt @@ -3,4 +3,4 @@ numpy wgpu jinja2 sphinx-gallery - +imageio From cac81df3e1949c7ec2d3b32a3405a5f5389adbec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 17:56:19 +0100 Subject: [PATCH 21/54] add matplotlib dependency This is a bit weird. may need to track down where it comes from later --- docs/docs_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs_requirements.txt b/docs/docs_requirements.txt index a0731048a..d571e2283 100644 --- a/docs/docs_requirements.txt +++ b/docs/docs_requirements.txt @@ -4,3 +4,4 @@ wgpu jinja2 sphinx-gallery imageio +matplotlib From 121fa15e0dc98f0bfec2f0c034d46ed084d47ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Sun, 27 Nov 2022 18:48:22 +0100 Subject: [PATCH 22/54] add example dependencies --- docs/docs_requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/docs_requirements.txt b/docs/docs_requirements.txt index d571e2283..cf694c78f 100644 --- a/docs/docs_requirements.txt +++ b/docs/docs_requirements.txt @@ -5,3 +5,6 @@ jinja2 sphinx-gallery imageio matplotlib +imageio-ffmpeg>=0.4.7 +scikit-image +trimesh From d0769f785ccd6406d8e2b11049e3b385d3f2dbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 28 Nov 2022 09:45:56 +0100 Subject: [PATCH 23/54] rename validation images to match filename --- .../{validate_box.png => plot_validate_box.png} | Bin .../{validate_color.png => plot_validate_color.png} | Bin ...lidate_culling.png => plot_validate_culling.png} | Bin ...lipping.png => plot_validate_depth_clipping.png} | Bin ...date_helpers1.png => plot_validate_helpers1.png} | Bin ...date_helpers2.png => plot_validate_helpers2.png} | Bin ...validate_image1.png => plot_validate_image1.png} | Bin ...validate_image2.png => plot_validate_image2.png} | Bin ...olormap.png => plot_validate_image_colormap.png} | Bin ...ht_shadow.png => plot_validate_light_shadow.png} | Bin ...colormap.png => plot_validate_mesh_colormap.png} | Bin .../{validate_ndc.png => plot_validate_ndc.png} | Bin ...validate_volume.png => plot_validate_volume.png} | Bin 13 files changed, 0 insertions(+), 0 deletions(-) rename examples/screenshots/{validate_box.png => plot_validate_box.png} (100%) rename examples/screenshots/{validate_color.png => plot_validate_color.png} (100%) rename examples/screenshots/{validate_culling.png => plot_validate_culling.png} (100%) rename examples/screenshots/{validate_depth_clipping.png => plot_validate_depth_clipping.png} (100%) rename examples/screenshots/{validate_helpers1.png => plot_validate_helpers1.png} (100%) rename examples/screenshots/{validate_helpers2.png => plot_validate_helpers2.png} (100%) rename examples/screenshots/{validate_image1.png => plot_validate_image1.png} (100%) rename examples/screenshots/{validate_image2.png => plot_validate_image2.png} (100%) rename examples/screenshots/{validate_image_colormap.png => plot_validate_image_colormap.png} (100%) rename examples/screenshots/{validate_light_shadow.png => plot_validate_light_shadow.png} (100%) rename examples/screenshots/{validate_mesh_colormap.png => plot_validate_mesh_colormap.png} (100%) rename examples/screenshots/{validate_ndc.png => plot_validate_ndc.png} (100%) rename examples/screenshots/{validate_volume.png => plot_validate_volume.png} (100%) diff --git a/examples/screenshots/validate_box.png b/examples/screenshots/plot_validate_box.png similarity index 100% rename from examples/screenshots/validate_box.png rename to examples/screenshots/plot_validate_box.png diff --git a/examples/screenshots/validate_color.png b/examples/screenshots/plot_validate_color.png similarity index 100% rename from examples/screenshots/validate_color.png rename to examples/screenshots/plot_validate_color.png diff --git a/examples/screenshots/validate_culling.png b/examples/screenshots/plot_validate_culling.png similarity index 100% rename from examples/screenshots/validate_culling.png rename to examples/screenshots/plot_validate_culling.png diff --git a/examples/screenshots/validate_depth_clipping.png b/examples/screenshots/plot_validate_depth_clipping.png similarity index 100% rename from examples/screenshots/validate_depth_clipping.png rename to examples/screenshots/plot_validate_depth_clipping.png diff --git a/examples/screenshots/validate_helpers1.png b/examples/screenshots/plot_validate_helpers1.png similarity index 100% rename from examples/screenshots/validate_helpers1.png rename to examples/screenshots/plot_validate_helpers1.png diff --git a/examples/screenshots/validate_helpers2.png b/examples/screenshots/plot_validate_helpers2.png similarity index 100% rename from examples/screenshots/validate_helpers2.png rename to examples/screenshots/plot_validate_helpers2.png diff --git a/examples/screenshots/validate_image1.png b/examples/screenshots/plot_validate_image1.png similarity index 100% rename from examples/screenshots/validate_image1.png rename to examples/screenshots/plot_validate_image1.png diff --git a/examples/screenshots/validate_image2.png b/examples/screenshots/plot_validate_image2.png similarity index 100% rename from examples/screenshots/validate_image2.png rename to examples/screenshots/plot_validate_image2.png diff --git a/examples/screenshots/validate_image_colormap.png b/examples/screenshots/plot_validate_image_colormap.png similarity index 100% rename from examples/screenshots/validate_image_colormap.png rename to examples/screenshots/plot_validate_image_colormap.png diff --git a/examples/screenshots/validate_light_shadow.png b/examples/screenshots/plot_validate_light_shadow.png similarity index 100% rename from examples/screenshots/validate_light_shadow.png rename to examples/screenshots/plot_validate_light_shadow.png diff --git a/examples/screenshots/validate_mesh_colormap.png b/examples/screenshots/plot_validate_mesh_colormap.png similarity index 100% rename from examples/screenshots/validate_mesh_colormap.png rename to examples/screenshots/plot_validate_mesh_colormap.png diff --git a/examples/screenshots/validate_ndc.png b/examples/screenshots/plot_validate_ndc.png similarity index 100% rename from examples/screenshots/validate_ndc.png rename to examples/screenshots/plot_validate_ndc.png diff --git a/examples/screenshots/validate_volume.png b/examples/screenshots/plot_validate_volume.png similarity index 100% rename from examples/screenshots/validate_volume.png rename to examples/screenshots/plot_validate_volume.png From 5e040c9476c7ee55d3e3a0419b959c648066768d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 29 Nov 2022 05:50:32 +0100 Subject: [PATCH 24/54] animate cube example --- examples/introductory/plot_cube.py | 2 +- pygfx/utils/gallery_scraper.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index e1870c3e2..674e9cf49 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -5,7 +5,7 @@ In this example shows how to do the rendering world's hello world: Show a 3D Cube on screen. """ -# sphinx_gallery_pygfx_render = True +# sphinx_gallery_pygfx_animate = True # sphinx_gallery_pygfx_target_name = "disp" import pygfx as gfx diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index c6f841cea..d508bde9b 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -1,4 +1,5 @@ import imageio.v3 as iio +from pathlib import Path from .show import Display from ..renderers import Renderer @@ -80,7 +81,15 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): images.append(img_path) if scraper_config["animate"]: - pass # TODO: code to generate an ainmated GIF + frames = [] + n_frames = scraper_config["duration"] * 30 + for _ in range(n_frames): + frames.append(canvas.draw()) + + path_generator = block_vars["image_path_iterator"] + img_path = Path(next(path_generator)).with_suffix(".gif") + iio.imwrite(img_path, frames, duration=40, loop=scraper_config["loop"]) # write at 25Hz + images.append(img_path) return figure_rst(images, gallery_conf["src_dir"]) From 2466a039f1f998e623a3c1fc3ebfe9b5c1480686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 09:41:00 +0100 Subject: [PATCH 25/54] mokeypatch run when building the gallery --- docs/conf.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 618497fec..be43889b3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,14 +3,23 @@ import os import sys from sphinx_gallery.sorting import ExplicitOrder +import wgpu.gui.offscreen ROOT_DIR = os.path.abspath(os.path.join(__file__, "..", "..")) sys.path.insert(0, ROOT_DIR) -# Avoid freezing examples +# -- Sphix Gallery Hackz ----------------------------------------------------- +# When building the gallery, render offscreen and don't process +# the event loop while parsing the example + +def _ignore_offscreen_run(): + wgpu.gui.offscreen.run = lambda: None + os.environ["WGPU_FORCE_OFFSCREEN"] = "true" +_ignore_offscreen_run() +# ---------------------------------------------------------------------------- import pygfx # noqa: E402 From 247c9771a6e0c9ce343cfcb58fcc31a2ce3386c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:22:15 +0100 Subject: [PATCH 26/54] blackify --- docs/conf.py | 2 ++ pygfx/utils/gallery_scraper.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index be43889b3..b0c760255 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,9 +13,11 @@ # When building the gallery, render offscreen and don't process # the event loop while parsing the example + def _ignore_offscreen_run(): wgpu.gui.offscreen.run = lambda: None + os.environ["WGPU_FORCE_OFFSCREEN"] = "true" _ignore_offscreen_run() diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index d508bde9b..d3e4d59b6 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -88,7 +88,9 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): path_generator = block_vars["image_path_iterator"] img_path = Path(next(path_generator)).with_suffix(".gif") - iio.imwrite(img_path, frames, duration=40, loop=scraper_config["loop"]) # write at 25Hz + iio.imwrite( + img_path, frames, duration=40, loop=scraper_config["loop"] + ) # write at 25Hz images.append(img_path) return figure_rst(images, gallery_conf["src_dir"]) From 51e797ac7a5638edf97b331573334611c0afc5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:33:32 +0100 Subject: [PATCH 27/54] prefer apt-get over apt in CI --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f18f4b338..b42f3717a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: sudo apt-get update -y -qq sudo add-apt-repository ppa:oibaf/graphics-drivers -y sudo apt-get update -y -qq - sudo apt install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + sudo apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers - name: Install dev dependencies run: | python -m pip install --upgrade pip @@ -102,7 +102,7 @@ jobs: sudo apt-get update -y -qq sudo add-apt-repository ppa:oibaf/graphics-drivers -y sudo apt-get update -y -qq - sudo apt install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + sudo apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers - name: Install dev dependencies run: | python -m pip install --upgrade pip From 8f446f1212cc15aa02f97adaa0bf212998cde6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:35:35 +0100 Subject: [PATCH 28/54] move doc requirements into setup.py --- .github/workflows/ci.yml | 2 +- docs/docs_requirements.txt | 10 ---------- setup.py | 9 +++++++++ 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 docs/docs_requirements.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b42f3717a..cc71539e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Install dev dependencies run: | python -m pip install --upgrade pip - pip install -U -r docs/docs_requirements.txt + pip install -U -e .[examples,docs] - name: Build docs run: | cd docs diff --git a/docs/docs_requirements.txt b/docs/docs_requirements.txt deleted file mode 100644 index cf694c78f..000000000 --- a/docs/docs_requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -sphinx -numpy -wgpu -jinja2 -sphinx-gallery -imageio -matplotlib -imageio-ffmpeg>=0.4.7 -scikit-image -trimesh diff --git a/setup.py b/setup.py index 65db91c05..166922412 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,15 @@ "scikit-image", "trimesh", ], + "docs": [ + "sphinx", + "numpy", + "wgpu", + "jinja2", + "sphinx-gallery", + "imageio", + "matplotlib", + ] } From c1cd52255b46f0b087ccd224b10df4c9618b60ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:38:02 +0100 Subject: [PATCH 29/54] add read-the-docs config --- .readthedocs.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 000000000..10380f28b --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,30 @@ +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +version: 2 + +build: + os: ubuntu-20.04 + tools: + python: "3.9" + jobs: + pre_build: + # install a software/CPU renderer + apt-get update -y -qq + add-apt-repository ppa:oibaf/graphics-drivers -y + apt-get update -y -qq + apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + +sphinx: + configuration: docs/conf.py + fail_on_warning: true + +# Optionally declare the Python requirements required to build your docs +python: + install: + - method: pip + path: . + extra_requirements: + - docs + - examples + - requirements: docs/doc_requirements.txt From f60b06204a8ae564c7df2af0c9cad93a1394799a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:38:23 +0100 Subject: [PATCH 30/54] blackify --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 166922412..f56d339aa 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ "sphinx-gallery", "imageio", "matplotlib", - ] + ], } From 50c0172639802f0f4cdb622567d7c3ef1c7bbf3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:47:43 +0100 Subject: [PATCH 31/54] add a whitespace to not break RTD :) --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 10380f28b..4956c7037 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -27,4 +27,4 @@ python: extra_requirements: - docs - examples - - requirements: docs/doc_requirements.txt + - requirements: docs/doc_requirements.txt From cd6bfffbdb99d59c1dff02a98d9dbb9049d7b727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:48:42 +0100 Subject: [PATCH 32/54] make pre-build steps a list --- .readthedocs.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 4956c7037..1c58abbbc 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,10 +10,10 @@ build: jobs: pre_build: # install a software/CPU renderer - apt-get update -y -qq - add-apt-repository ppa:oibaf/graphics-drivers -y - apt-get update -y -qq - apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + - apt-get update -y -qq + - add-apt-repository ppa:oibaf/graphics-drivers -y + - apt-get update -y -qq + - apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers sphinx: configuration: docs/conf.py From c57478f796c996cd958566b8590fa0ac92fa0625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 11:52:04 +0100 Subject: [PATCH 33/54] no longer need ref to requirements.txt --- .readthedocs.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1c58abbbc..e9b03fa8a 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -27,4 +27,3 @@ python: extra_requirements: - docs - examples - - requirements: docs/doc_requirements.txt From a3de57ac5201a5e400ce9439c58911639310a201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Fri, 2 Dec 2022 12:03:25 +0100 Subject: [PATCH 34/54] test using sudo to counter permission error --- .readthedocs.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e9b03fa8a..683372dbf 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,10 +10,10 @@ build: jobs: pre_build: # install a software/CPU renderer - - apt-get update -y -qq - - add-apt-repository ppa:oibaf/graphics-drivers -y - - apt-get update -y -qq - - apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + - sudo apt-get update -y -qq + - sudo add-apt-repository ppa:oibaf/graphics-drivers -y + - sudo apt-get update -y -qq + - sudo apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers sphinx: configuration: docs/conf.py From b0511cdc441cc5f528650bd60cdebfa6f0354fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 5 Dec 2022 19:57:30 +0100 Subject: [PATCH 35/54] add apt packages directly (long shot) --- .readthedocs.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 683372dbf..6c969a146 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,12 +8,11 @@ build: tools: python: "3.9" jobs: - pre_build: - # install a software/CPU renderer - - sudo apt-get update -y -qq - - sudo add-apt-repository ppa:oibaf/graphics-drivers -y - - sudo apt-get update -y -qq - - sudo apt-get install --no-install-recommends -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + apt-packages: + - libegl1-mesa + - libgl1-mesa-dri + - libxcb-xfixes0-dev + - mesa-vulkan-drivers sphinx: configuration: docs/conf.py From 30590dc0580b341fb2b56ac0ea428f88d41cf2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 5 Dec 2022 19:58:38 +0100 Subject: [PATCH 36/54] fix RTD config --- .readthedocs.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 6c969a146..d8db27fb2 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -7,12 +7,11 @@ build: os: ubuntu-20.04 tools: python: "3.9" - jobs: - apt-packages: - - libegl1-mesa - - libgl1-mesa-dri - - libxcb-xfixes0-dev - - mesa-vulkan-drivers + apt-packages: + - libegl1-mesa + - libgl1-mesa-dri + - libxcb-xfixes0-dev + - mesa-vulkan-drivers sphinx: configuration: docs/conf.py From d67a8135a7517ee3795b232cb1875185a324ee60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 5 Dec 2022 19:59:44 +0100 Subject: [PATCH 37/54] fix typo --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index d8db27fb2..1f0225d81 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -7,7 +7,7 @@ build: os: ubuntu-20.04 tools: python: "3.9" - apt-packages: + apt_packages: - libegl1-mesa - libgl1-mesa-dri - libxcb-xfixes0-dev From 9a5cdfaa40e72688b3b281a0d683fbaa2f27b037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 6 Dec 2022 10:48:41 +0100 Subject: [PATCH 38/54] build on ubuntu 22.04 --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1f0225d81..c742035f4 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -4,7 +4,7 @@ version: 2 build: - os: ubuntu-20.04 + os: ubuntu-22.04 tools: python: "3.9" apt_packages: From 6ae607bb4558c2a36aab5fcf4856cf17f7624342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 6 Dec 2022 10:54:56 +0100 Subject: [PATCH 39/54] try add PPA as pre-sys-dependency step --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index c742035f4..bc0c7a515 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,6 +12,9 @@ build: - libgl1-mesa-dri - libxcb-xfixes0-dev - mesa-vulkan-drivers + jobs: + pre_system_dependencies: + add-apt-repository ppa:oibaf/graphics-drivers -y sphinx: configuration: docs/conf.py From 05cc3182d5ace82c9cb8512c43bcdb66566cbe88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 6 Dec 2022 10:55:47 +0100 Subject: [PATCH 40/54] make it a list --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bc0c7a515..7af8e54f4 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -14,7 +14,7 @@ build: - mesa-vulkan-drivers jobs: pre_system_dependencies: - add-apt-repository ppa:oibaf/graphics-drivers -y + - add-apt-repository ppa:oibaf/graphics-drivers -y sphinx: configuration: docs/conf.py From 60e7b3e242f2be4dfc31c0b6c84dadb85c60665e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 6 Dec 2022 11:03:35 +0100 Subject: [PATCH 41/54] try the deb approach instead --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7af8e54f4..9f3082b80 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -14,7 +14,7 @@ build: - mesa-vulkan-drivers jobs: pre_system_dependencies: - - add-apt-repository ppa:oibaf/graphics-drivers -y + - deb https://ppa.launchpadcontent.net/oibaf/graphics-drivers/ubuntu jammy main sphinx: configuration: docs/conf.py From 5337c7f02ec1adecd33caac584b1d76f3034895b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 6 Dec 2022 13:13:31 +0100 Subject: [PATCH 42/54] don't build heavy example (maybe OOM segfault?) --- .../plot_collection_line.py => other/collection_line.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{feature_demo/plot_collection_line.py => other/collection_line.py} (100%) diff --git a/examples/feature_demo/plot_collection_line.py b/examples/other/collection_line.py similarity index 100% rename from examples/feature_demo/plot_collection_line.py rename to examples/other/collection_line.py From 56be2b077af9ef35fd630b3d0f2aa1755488bd7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Tue, 6 Dec 2022 13:14:26 +0100 Subject: [PATCH 43/54] undo changes to config file --- .readthedocs.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9f3082b80..c742035f4 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,9 +12,6 @@ build: - libgl1-mesa-dri - libxcb-xfixes0-dev - mesa-vulkan-drivers - jobs: - pre_system_dependencies: - - deb https://ppa.launchpadcontent.net/oibaf/graphics-drivers/ubuntu jammy main sphinx: configuration: docs/conf.py From c9d64725e05f95822e595c1b7de8fa5273a96c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 07:34:30 +0100 Subject: [PATCH 44/54] check if target is a canvas --- pygfx/utils/gallery_scraper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index d3e4d59b6..4d49b64ca 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -1,5 +1,6 @@ import imageio.v3 as iio from pathlib import Path +from wgpu.gui import WgpuCanvasBase from .show import Display from ..renderers import Renderer @@ -68,9 +69,10 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): canvas = target.canvas elif isinstance(target, Renderer): canvas = target.target - else: - # @almarklein: Where can I find the base class of Canvas? + elif isinstance(target, WgpuCanvasBase): canvas = target + else: + raise ValueError("`target` must be a Display, Renderer, or Canvas.") images = [] From c9018cea8d18e0995048fa33db0ba0120cfc5434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 07:35:18 +0100 Subject: [PATCH 45/54] conditionally import imageio --- pygfx/utils/gallery_scraper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index 4d49b64ca..49c38366e 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -1,4 +1,3 @@ -import imageio.v3 as iio from pathlib import Path from wgpu.gui import WgpuCanvasBase @@ -48,8 +47,10 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): the images. This is often produced by :func:`figure_rst`. """ - # import locally, to keep sphinx an optional dependency + # import locally, to keep sphinx and imageio an optional dependency from sphinx_gallery.scrapers import figure_rst + import imageio.v3 as iio + # parse block-level config scraper_config = default_config.copy() From 763120cb01f48ca86bb4d4a37548ef1e03e0a4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 09:52:13 +0100 Subject: [PATCH 46/54] add webp support in animations --- examples/introductory/plot_cube.py | 1 + pygfx/utils/gallery_scraper.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/introductory/plot_cube.py b/examples/introductory/plot_cube.py index 674e9cf49..4826caa3e 100644 --- a/examples/introductory/plot_cube.py +++ b/examples/introductory/plot_cube.py @@ -4,6 +4,7 @@ In this example shows how to do the rendering world's hello world: Show a 3D Cube on screen. + """ # sphinx_gallery_pygfx_animate = True # sphinx_gallery_pygfx_target_name = "disp" diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index 49c38366e..992756046 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -85,19 +85,23 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): if scraper_config["animate"]: frames = [] + + # by default videos are rendered at ~ 30 FPS n_frames = scraper_config["duration"] * 30 for _ in range(n_frames): frames.append(canvas.draw()) path_generator = block_vars["image_path_iterator"] - img_path = Path(next(path_generator)).with_suffix(".gif") - iio.imwrite( - img_path, frames, duration=40, loop=scraper_config["loop"] - ) # write at 25Hz + img_path = Path(next(path_generator)).with_suffix(".webp") + iio.imwrite(img_path, frames, duration=int(round(1/30 * 1000)), loop=scraper_config["loop"]) images.append(img_path) return figure_rst(images, gallery_conf["src_dir"]) def _get_sg_image_scraper(): + # add webp as supported extension + import sphinx_gallery.scrapers + sphinx_gallery.scrapers._KNOWN_IMG_EXTS += ("webp",) + return pygfx_scraper From c6943bd7fc20e044393b4998a9329ce2352386f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 09:52:33 +0100 Subject: [PATCH 47/54] blackify --- pygfx/utils/gallery_scraper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index 992756046..619355cac 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -51,7 +51,6 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): from sphinx_gallery.scrapers import figure_rst import imageio.v3 as iio - # parse block-level config scraper_config = default_config.copy() config_prefix = "# sphinx_gallery_pygfx_" @@ -93,7 +92,12 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): path_generator = block_vars["image_path_iterator"] img_path = Path(next(path_generator)).with_suffix(".webp") - iio.imwrite(img_path, frames, duration=int(round(1/30 * 1000)), loop=scraper_config["loop"]) + iio.imwrite( + img_path, + frames, + duration=int(round(1 / 30 * 1000)), + loop=scraper_config["loop"], + ) images.append(img_path) return figure_rst(images, gallery_conf["src_dir"]) @@ -102,6 +106,7 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): def _get_sg_image_scraper(): # add webp as supported extension import sphinx_gallery.scrapers + sphinx_gallery.scrapers._KNOWN_IMG_EXTS += ("webp",) return pygfx_scraper From fb47958e589ca46ee69161e27e60b519fb8cd617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 10:09:20 +0100 Subject: [PATCH 48/54] less cryptic duration value --- pygfx/utils/gallery_scraper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index 619355cac..3baebb760 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -95,7 +95,7 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): iio.imwrite( img_path, frames, - duration=int(round(1 / 30 * 1000)), + duration=33, loop=scraper_config["loop"], ) images.append(img_path) From 8e0bf319612863bc06f7e453638b6bc091b16132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 12:52:25 +0100 Subject: [PATCH 49/54] lossless compression for WEBP --- pygfx/utils/gallery_scraper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index 3baebb760..1bc66fe1f 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -97,6 +97,7 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): frames, duration=33, loop=scraper_config["loop"], + lossless=True, ) images.append(img_path) From 2e3345c065ec12dab1682a7c1b4608c82be958d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 12:57:59 +0100 Subject: [PATCH 50/54] move _get_sg_image_scraper into __init__ --- pygfx/__init__.py | 12 ++++++++++-- pygfx/utils/gallery_scraper.py | 9 --------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pygfx/__init__.py b/pygfx/__init__.py index 7d2fe3e81..9eafd76fa 100644 --- a/pygfx/__init__.py +++ b/pygfx/__init__.py @@ -18,13 +18,21 @@ from .utils.viewport import Viewport from .utils import cm, logger -from .utils.gallery_scraper import _get_sg_image_scraper - __version__ = "0.1.9" version_info = tuple(map(int, __version__.split("."))) +def _get_sg_image_scraper(): + import sphinx_gallery.scrapers + from .utils.gallery_scraper import pygfx_scraper + + # add webp as supported extension + sphinx_gallery.scrapers._KNOWN_IMG_EXTS += ("webp",) + + return pygfx_scraper + + # Elements of this library are derived from three.js, original license # at time of writing copied here: # --- diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index 1bc66fe1f..afbbc1827 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -102,12 +102,3 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): images.append(img_path) return figure_rst(images, gallery_conf["src_dir"]) - - -def _get_sg_image_scraper(): - # add webp as supported extension - import sphinx_gallery.scrapers - - sphinx_gallery.scrapers._KNOWN_IMG_EXTS += ("webp",) - - return pygfx_scraper From 60e43f7166b813dee201b78df26aa4df5b38e132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Wed, 7 Dec 2022 12:58:47 +0100 Subject: [PATCH 51/54] reorganize scraper imports --- pygfx/utils/gallery_scraper.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pygfx/utils/gallery_scraper.py b/pygfx/utils/gallery_scraper.py index afbbc1827..0e2a318ac 100644 --- a/pygfx/utils/gallery_scraper.py +++ b/pygfx/utils/gallery_scraper.py @@ -1,9 +1,11 @@ from pathlib import Path + +import imageio.v3 as iio +from sphinx_gallery.scrapers import figure_rst from wgpu.gui import WgpuCanvasBase -from .show import Display from ..renderers import Renderer - +from .show import Display # The scraper's default configuration. An example code-block # may overwrite these values by setting comments of the form @@ -47,10 +49,6 @@ def pygfx_scraper(block, block_vars, gallery_conf, **kwargs): the images. This is often produced by :func:`figure_rst`. """ - # import locally, to keep sphinx and imageio an optional dependency - from sphinx_gallery.scrapers import figure_rst - import imageio.v3 as iio - # parse block-level config scraper_config = default_config.copy() config_prefix = "# sphinx_gallery_pygfx_" From 99ba4cb40f0d26ae42829278af6a6442154dfc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 12 Dec 2022 13:55:15 +0100 Subject: [PATCH 52/54] use parameterize's ids --- examples/tests/test_examples.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index 29a1f02b6..d5be4b853 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -24,19 +24,13 @@ # run all tests unless they opt-out -examples_to_run_dict = { - path.stem: path for path in find_examples(negative_query="# run_example = false") -} -examples_to_run = [x for x in examples_to_run_dict.keys()] +examples_to_run = find_examples(negative_query="# run_example = false") # only test output of examples that opt-in -examples_to_test_dict = { - path.stem: path for path in find_examples(query="# test_example = true") -} -examples_to_test = [x for x in examples_to_test_dict.keys()] +examples_to_test = find_examples(query="# test_example = true") -@pytest.mark.parametrize("module", examples_to_run) +@pytest.mark.parametrize("module", examples_to_run, ids=lambda x: x.stem) def test_examples_run(module, force_offscreen, disable_call_later_after_run): """Run every example marked to see if they can run without error.""" # use runpy so the module is not actually imported (and can be gc'd) @@ -44,7 +38,7 @@ def test_examples_run(module, force_offscreen, disable_call_later_after_run): # (relative) module name from project root module_name = ( - examples_to_run_dict[module] + module .relative_to(ROOT) .with_suffix("") .as_posix() @@ -109,7 +103,7 @@ def mock_time(): yield -@pytest.mark.parametrize("module", examples_to_test) +@pytest.mark.parametrize("module", examples_to_test, ids=lambda x: x.stem) def test_examples_screenshots( module, pytestconfig, force_offscreen, mock_time, request ): @@ -117,7 +111,7 @@ def test_examples_screenshots( # (relative) module name from project root module_name = ( - examples_to_test_dict[module] + module .relative_to(ROOT) .with_suffix("") .as_posix() From db34c307a70664f17149d2e7e7fabf6bc9367a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 12 Dec 2022 13:58:12 +0100 Subject: [PATCH 53/54] blackify --- examples/tests/test_examples.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index d5be4b853..d7bf2fee5 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -37,13 +37,7 @@ def test_examples_run(module, force_offscreen, disable_call_later_after_run): # but also to be able to run the code in the __main__ block # (relative) module name from project root - module_name = ( - module - .relative_to(ROOT) - .with_suffix("") - .as_posix() - .replace("/", ".") - ) + module_name = module.relative_to(ROOT).with_suffix("").as_posix().replace("/", ".") runpy.run_module(module_name, run_name="__main__") @@ -110,13 +104,7 @@ def test_examples_screenshots( """Run every example marked for testing.""" # (relative) module name from project root - module_name = ( - module - .relative_to(ROOT) - .with_suffix("") - .as_posix() - .replace("/", ".") - ) + module_name = module.relative_to(ROOT).with_suffix("").as_posix().replace("/", ".") # import the example module example = importlib.import_module(module_name) From 16d243944a3720880a11001b52c27fcb292011db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wallk=C3=B6tter?= Date: Mon, 12 Dec 2022 15:21:01 +0100 Subject: [PATCH 54/54] update validation paths --- examples/tests/test_examples.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tests/test_examples.py b/examples/tests/test_examples.py index d7bf2fee5..19e06001c 100644 --- a/examples/tests/test_examples.py +++ b/examples/tests/test_examples.py @@ -131,7 +131,7 @@ def unload_module(): pytest.skip("screenshot comparisons are only done when using lavapipe") # regenerate screenshot if requested - screenshot_path = screenshots_dir / f"{module}.png" + screenshot_path = screenshots_dir / f"{module.stem}.png" if pytestconfig.getoption("regenerate_screenshots"): iio.imwrite(screenshot_path, img) @@ -142,9 +142,9 @@ def unload_module(): stored_img = iio.imread(screenshot_path) # assert similarity is_similar = np.allclose(img, stored_img, atol=1) - update_diffs(module, is_similar, img, stored_img) + update_diffs(module.stem, is_similar, img, stored_img) assert is_similar, ( - f"rendered image for example {module} changed, see " + f"rendered image for example {module.stem} changed, see " f"the {diffs_dir.relative_to(ROOT).as_posix()} folder" " for visual diffs (you can download this folder from" " CI build artifacts as well)"