vispy 0.15.0__cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vispy might be problematic. Click here for more details.
- vispy/__init__.py +33 -0
- vispy/app/__init__.py +15 -0
- vispy/app/_default_app.py +76 -0
- vispy/app/_detect_eventloop.py +148 -0
- vispy/app/application.py +263 -0
- vispy/app/backends/__init__.py +52 -0
- vispy/app/backends/_egl.py +264 -0
- vispy/app/backends/_glfw.py +513 -0
- vispy/app/backends/_jupyter_rfb.py +278 -0
- vispy/app/backends/_offscreen_util.py +121 -0
- vispy/app/backends/_osmesa.py +235 -0
- vispy/app/backends/_pyglet.py +451 -0
- vispy/app/backends/_pyqt4.py +36 -0
- vispy/app/backends/_pyqt5.py +36 -0
- vispy/app/backends/_pyqt6.py +40 -0
- vispy/app/backends/_pyside.py +37 -0
- vispy/app/backends/_pyside2.py +52 -0
- vispy/app/backends/_pyside6.py +53 -0
- vispy/app/backends/_qt.py +1003 -0
- vispy/app/backends/_sdl2.py +444 -0
- vispy/app/backends/_template.py +244 -0
- vispy/app/backends/_test.py +8 -0
- vispy/app/backends/_tk.py +800 -0
- vispy/app/backends/_wx.py +476 -0
- vispy/app/backends/tests/__init__.py +0 -0
- vispy/app/backends/tests/test_offscreen_util.py +52 -0
- vispy/app/backends/tests/test_rfb.py +77 -0
- vispy/app/base.py +294 -0
- vispy/app/canvas.py +828 -0
- vispy/app/qt.py +92 -0
- vispy/app/tests/__init__.py +0 -0
- vispy/app/tests/qt-designer.ui +58 -0
- vispy/app/tests/test_app.py +442 -0
- vispy/app/tests/test_backends.py +164 -0
- vispy/app/tests/test_canvas.py +122 -0
- vispy/app/tests/test_context.py +92 -0
- vispy/app/tests/test_qt.py +47 -0
- vispy/app/tests/test_simultaneous.py +134 -0
- vispy/app/timer.py +174 -0
- vispy/color/__init__.py +17 -0
- vispy/color/_color_dict.py +193 -0
- vispy/color/color_array.py +447 -0
- vispy/color/color_space.py +181 -0
- vispy/color/colormap.py +1213 -0
- vispy/color/tests/__init__.py +0 -0
- vispy/color/tests/test_color.py +378 -0
- vispy/conftest.py +12 -0
- vispy/ext/__init__.py +0 -0
- vispy/ext/cocoapy.py +1522 -0
- vispy/ext/cubehelix.py +138 -0
- vispy/ext/egl.py +375 -0
- vispy/ext/fontconfig.py +118 -0
- vispy/ext/gdi32plus.py +206 -0
- vispy/ext/osmesa.py +105 -0
- vispy/geometry/__init__.py +23 -0
- vispy/geometry/_triangulation_debugger.py +171 -0
- vispy/geometry/calculations.py +162 -0
- vispy/geometry/curves.py +399 -0
- vispy/geometry/generation.py +643 -0
- vispy/geometry/isocurve.py +175 -0
- vispy/geometry/isosurface.py +465 -0
- vispy/geometry/meshdata.py +700 -0
- vispy/geometry/normals.py +78 -0
- vispy/geometry/parametric.py +56 -0
- vispy/geometry/polygon.py +137 -0
- vispy/geometry/rect.py +210 -0
- vispy/geometry/tests/__init__.py +0 -0
- vispy/geometry/tests/test_calculations.py +23 -0
- vispy/geometry/tests/test_generation.py +56 -0
- vispy/geometry/tests/test_meshdata.py +106 -0
- vispy/geometry/tests/test_triangulation.py +594 -0
- vispy/geometry/torusknot.py +142 -0
- vispy/geometry/triangulation.py +876 -0
- vispy/gloo/__init__.py +56 -0
- vispy/gloo/buffer.py +505 -0
- vispy/gloo/context.py +272 -0
- vispy/gloo/framebuffer.py +257 -0
- vispy/gloo/gl/__init__.py +234 -0
- vispy/gloo/gl/_constants.py +332 -0
- vispy/gloo/gl/_es2.py +986 -0
- vispy/gloo/gl/_gl2.py +1365 -0
- vispy/gloo/gl/_proxy.py +499 -0
- vispy/gloo/gl/_pyopengl2.py +362 -0
- vispy/gloo/gl/dummy.py +24 -0
- vispy/gloo/gl/es2.py +62 -0
- vispy/gloo/gl/gl2.py +98 -0
- vispy/gloo/gl/glplus.py +168 -0
- vispy/gloo/gl/pyopengl2.py +97 -0
- vispy/gloo/gl/tests/__init__.py +0 -0
- vispy/gloo/gl/tests/test_basics.py +282 -0
- vispy/gloo/gl/tests/test_functionality.py +568 -0
- vispy/gloo/gl/tests/test_names.py +246 -0
- vispy/gloo/gl/tests/test_use.py +71 -0
- vispy/gloo/glir.py +1824 -0
- vispy/gloo/globject.py +101 -0
- vispy/gloo/preprocessor.py +67 -0
- vispy/gloo/program.py +543 -0
- vispy/gloo/tests/__init__.py +0 -0
- vispy/gloo/tests/test_buffer.py +558 -0
- vispy/gloo/tests/test_context.py +119 -0
- vispy/gloo/tests/test_framebuffer.py +195 -0
- vispy/gloo/tests/test_glir.py +307 -0
- vispy/gloo/tests/test_globject.py +35 -0
- vispy/gloo/tests/test_program.py +302 -0
- vispy/gloo/tests/test_texture.py +732 -0
- vispy/gloo/tests/test_use_gloo.py +187 -0
- vispy/gloo/tests/test_util.py +60 -0
- vispy/gloo/tests/test_wrappers.py +261 -0
- vispy/gloo/texture.py +1046 -0
- vispy/gloo/util.py +129 -0
- vispy/gloo/wrappers.py +762 -0
- vispy/glsl/__init__.py +42 -0
- vispy/glsl/antialias/antialias.glsl +7 -0
- vispy/glsl/antialias/cap-butt.glsl +31 -0
- vispy/glsl/antialias/cap-round.glsl +29 -0
- vispy/glsl/antialias/cap-square.glsl +30 -0
- vispy/glsl/antialias/cap-triangle-in.glsl +30 -0
- vispy/glsl/antialias/cap-triangle-out.glsl +30 -0
- vispy/glsl/antialias/cap.glsl +67 -0
- vispy/glsl/antialias/caps.glsl +67 -0
- vispy/glsl/antialias/filled.glsl +50 -0
- vispy/glsl/antialias/outline.glsl +40 -0
- vispy/glsl/antialias/stroke.glsl +43 -0
- vispy/glsl/arrowheads/angle.glsl +99 -0
- vispy/glsl/arrowheads/arrowheads.frag +60 -0
- vispy/glsl/arrowheads/arrowheads.glsl +12 -0
- vispy/glsl/arrowheads/arrowheads.vert +83 -0
- vispy/glsl/arrowheads/curved.glsl +48 -0
- vispy/glsl/arrowheads/inhibitor.glsl +26 -0
- vispy/glsl/arrowheads/stealth.glsl +46 -0
- vispy/glsl/arrowheads/triangle.glsl +97 -0
- vispy/glsl/arrowheads/util.glsl +13 -0
- vispy/glsl/arrows/angle-30.glsl +12 -0
- vispy/glsl/arrows/angle-60.glsl +12 -0
- vispy/glsl/arrows/angle-90.glsl +12 -0
- vispy/glsl/arrows/arrow.frag +39 -0
- vispy/glsl/arrows/arrow.vert +49 -0
- vispy/glsl/arrows/arrows.glsl +17 -0
- vispy/glsl/arrows/common.glsl +187 -0
- vispy/glsl/arrows/curved.glsl +63 -0
- vispy/glsl/arrows/stealth.glsl +50 -0
- vispy/glsl/arrows/triangle-30.glsl +12 -0
- vispy/glsl/arrows/triangle-60.glsl +12 -0
- vispy/glsl/arrows/triangle-90.glsl +12 -0
- vispy/glsl/arrows/util.glsl +98 -0
- vispy/glsl/build_spatial_filters.py +660 -0
- vispy/glsl/collections/agg-fast-path.frag +20 -0
- vispy/glsl/collections/agg-fast-path.vert +78 -0
- vispy/glsl/collections/agg-glyph.frag +60 -0
- vispy/glsl/collections/agg-glyph.vert +33 -0
- vispy/glsl/collections/agg-marker.frag +35 -0
- vispy/glsl/collections/agg-marker.vert +48 -0
- vispy/glsl/collections/agg-path.frag +55 -0
- vispy/glsl/collections/agg-path.vert +166 -0
- vispy/glsl/collections/agg-point.frag +21 -0
- vispy/glsl/collections/agg-point.vert +35 -0
- vispy/glsl/collections/agg-segment.frag +32 -0
- vispy/glsl/collections/agg-segment.vert +75 -0
- vispy/glsl/collections/marker.frag +38 -0
- vispy/glsl/collections/marker.vert +48 -0
- vispy/glsl/collections/raw-path.frag +15 -0
- vispy/glsl/collections/raw-path.vert +24 -0
- vispy/glsl/collections/raw-point.frag +14 -0
- vispy/glsl/collections/raw-point.vert +31 -0
- vispy/glsl/collections/raw-segment.frag +18 -0
- vispy/glsl/collections/raw-segment.vert +26 -0
- vispy/glsl/collections/raw-triangle.frag +13 -0
- vispy/glsl/collections/raw-triangle.vert +26 -0
- vispy/glsl/collections/sdf-glyph-ticks.vert +69 -0
- vispy/glsl/collections/sdf-glyph.frag +80 -0
- vispy/glsl/collections/sdf-glyph.vert +59 -0
- vispy/glsl/collections/tick-labels.vert +71 -0
- vispy/glsl/colormaps/autumn.glsl +20 -0
- vispy/glsl/colormaps/blues.glsl +20 -0
- vispy/glsl/colormaps/color-space.glsl +17 -0
- vispy/glsl/colormaps/colormaps.glsl +24 -0
- vispy/glsl/colormaps/cool.glsl +20 -0
- vispy/glsl/colormaps/fire.glsl +21 -0
- vispy/glsl/colormaps/gray.glsl +20 -0
- vispy/glsl/colormaps/greens.glsl +20 -0
- vispy/glsl/colormaps/hot.glsl +22 -0
- vispy/glsl/colormaps/ice.glsl +20 -0
- vispy/glsl/colormaps/icefire.glsl +23 -0
- vispy/glsl/colormaps/parse.py +40 -0
- vispy/glsl/colormaps/reds.glsl +20 -0
- vispy/glsl/colormaps/spring.glsl +20 -0
- vispy/glsl/colormaps/summer.glsl +20 -0
- vispy/glsl/colormaps/user.glsl +22 -0
- vispy/glsl/colormaps/util.glsl +41 -0
- vispy/glsl/colormaps/wheel.glsl +21 -0
- vispy/glsl/colormaps/winter.glsl +20 -0
- vispy/glsl/lines/agg.frag +320 -0
- vispy/glsl/lines/agg.vert +241 -0
- vispy/glsl/markers/arrow.glsl +12 -0
- vispy/glsl/markers/asterisk.glsl +16 -0
- vispy/glsl/markers/chevron.glsl +14 -0
- vispy/glsl/markers/clover.glsl +20 -0
- vispy/glsl/markers/club.glsl +31 -0
- vispy/glsl/markers/cross.glsl +17 -0
- vispy/glsl/markers/diamond.glsl +12 -0
- vispy/glsl/markers/disc.glsl +9 -0
- vispy/glsl/markers/ellipse.glsl +67 -0
- vispy/glsl/markers/hbar.glsl +9 -0
- vispy/glsl/markers/heart.glsl +15 -0
- vispy/glsl/markers/infinity.glsl +15 -0
- vispy/glsl/markers/marker-sdf.frag +74 -0
- vispy/glsl/markers/marker-sdf.vert +41 -0
- vispy/glsl/markers/marker.frag +36 -0
- vispy/glsl/markers/marker.vert +46 -0
- vispy/glsl/markers/markers.glsl +24 -0
- vispy/glsl/markers/pin.glsl +18 -0
- vispy/glsl/markers/ring.glsl +11 -0
- vispy/glsl/markers/spade.glsl +28 -0
- vispy/glsl/markers/square.glsl +10 -0
- vispy/glsl/markers/tag.glsl +11 -0
- vispy/glsl/markers/triangle.glsl +14 -0
- vispy/glsl/markers/vbar.glsl +9 -0
- vispy/glsl/math/circle-through-2-points.glsl +30 -0
- vispy/glsl/math/constants.glsl +48 -0
- vispy/glsl/math/double.glsl +114 -0
- vispy/glsl/math/functions.glsl +20 -0
- vispy/glsl/math/point-to-line-distance.glsl +31 -0
- vispy/glsl/math/point-to-line-projection.glsl +29 -0
- vispy/glsl/math/signed-line-distance.glsl +27 -0
- vispy/glsl/math/signed-segment-distance.glsl +30 -0
- vispy/glsl/misc/regular-grid.frag +244 -0
- vispy/glsl/misc/spatial-filters.frag +1407 -0
- vispy/glsl/misc/viewport-NDC.glsl +20 -0
- vispy/glsl/transforms/azimuthal-equal-area.glsl +32 -0
- vispy/glsl/transforms/azimuthal-equidistant.glsl +38 -0
- vispy/glsl/transforms/hammer.glsl +44 -0
- vispy/glsl/transforms/identity.glsl +6 -0
- vispy/glsl/transforms/identity_forward.glsl +23 -0
- vispy/glsl/transforms/identity_inverse.glsl +23 -0
- vispy/glsl/transforms/linear-scale.glsl +127 -0
- vispy/glsl/transforms/log-scale.glsl +126 -0
- vispy/glsl/transforms/mercator-transverse-forward.glsl +40 -0
- vispy/glsl/transforms/mercator-transverse-inverse.glsl +40 -0
- vispy/glsl/transforms/panzoom.glsl +10 -0
- vispy/glsl/transforms/polar.glsl +41 -0
- vispy/glsl/transforms/position.glsl +44 -0
- vispy/glsl/transforms/power-scale.glsl +139 -0
- vispy/glsl/transforms/projection.glsl +7 -0
- vispy/glsl/transforms/pvm.glsl +13 -0
- vispy/glsl/transforms/rotate.glsl +45 -0
- vispy/glsl/transforms/trackball.glsl +15 -0
- vispy/glsl/transforms/translate.glsl +35 -0
- vispy/glsl/transforms/transverse_mercator.glsl +38 -0
- vispy/glsl/transforms/viewport-clipping.glsl +14 -0
- vispy/glsl/transforms/viewport-transform.glsl +16 -0
- vispy/glsl/transforms/viewport.glsl +50 -0
- vispy/glsl/transforms/x.glsl +24 -0
- vispy/glsl/transforms/y.glsl +19 -0
- vispy/glsl/transforms/z.glsl +14 -0
- vispy/io/__init__.py +20 -0
- vispy/io/_data/spatial-filters.npy +0 -0
- vispy/io/datasets.py +94 -0
- vispy/io/image.py +231 -0
- vispy/io/mesh.py +122 -0
- vispy/io/stl.py +167 -0
- vispy/io/tests/__init__.py +0 -0
- vispy/io/tests/test_image.py +47 -0
- vispy/io/tests/test_io.py +121 -0
- vispy/io/wavefront.py +350 -0
- vispy/plot/__init__.py +36 -0
- vispy/plot/fig.py +58 -0
- vispy/plot/plotwidget.py +522 -0
- vispy/plot/tests/__init__.py +0 -0
- vispy/plot/tests/test_plot.py +46 -0
- vispy/scene/__init__.py +43 -0
- vispy/scene/cameras/__init__.py +27 -0
- vispy/scene/cameras/_base.py +38 -0
- vispy/scene/cameras/arcball.py +105 -0
- vispy/scene/cameras/base_camera.py +551 -0
- vispy/scene/cameras/fly.py +474 -0
- vispy/scene/cameras/magnify.py +163 -0
- vispy/scene/cameras/panzoom.py +311 -0
- vispy/scene/cameras/perspective.py +338 -0
- vispy/scene/cameras/tests/__init__.py +0 -0
- vispy/scene/cameras/tests/test_cameras.py +27 -0
- vispy/scene/cameras/tests/test_link.py +53 -0
- vispy/scene/cameras/tests/test_perspective.py +122 -0
- vispy/scene/cameras/turntable.py +183 -0
- vispy/scene/canvas.py +639 -0
- vispy/scene/events.py +85 -0
- vispy/scene/node.py +644 -0
- vispy/scene/subscene.py +20 -0
- vispy/scene/tests/__init__.py +0 -0
- vispy/scene/tests/test_canvas.py +119 -0
- vispy/scene/tests/test_node.py +142 -0
- vispy/scene/tests/test_visuals.py +141 -0
- vispy/scene/visuals.py +276 -0
- vispy/scene/widgets/__init__.py +18 -0
- vispy/scene/widgets/anchor.py +25 -0
- vispy/scene/widgets/axis.py +88 -0
- vispy/scene/widgets/colorbar.py +176 -0
- vispy/scene/widgets/console.py +351 -0
- vispy/scene/widgets/grid.py +509 -0
- vispy/scene/widgets/label.py +50 -0
- vispy/scene/widgets/tests/__init__.py +0 -0
- vispy/scene/widgets/tests/test_colorbar.py +47 -0
- vispy/scene/widgets/viewbox.py +199 -0
- vispy/scene/widgets/widget.py +478 -0
- vispy/testing/__init__.py +51 -0
- vispy/testing/_runners.py +448 -0
- vispy/testing/_testing.py +416 -0
- vispy/testing/image_tester.py +494 -0
- vispy/testing/rendered_array_tester.py +85 -0
- vispy/testing/tests/__init__.py +0 -0
- vispy/testing/tests/test_testing.py +20 -0
- vispy/util/__init__.py +32 -0
- vispy/util/bunch.py +15 -0
- vispy/util/check_environment.py +57 -0
- vispy/util/config.py +490 -0
- vispy/util/dpi/__init__.py +19 -0
- vispy/util/dpi/_linux.py +69 -0
- vispy/util/dpi/_quartz.py +26 -0
- vispy/util/dpi/_win32.py +34 -0
- vispy/util/dpi/tests/__init__.py +0 -0
- vispy/util/dpi/tests/test_dpi.py +16 -0
- vispy/util/eq.py +41 -0
- vispy/util/event.py +774 -0
- vispy/util/fetching.py +276 -0
- vispy/util/filter.py +44 -0
- vispy/util/fonts/__init__.py +14 -0
- vispy/util/fonts/_freetype.py +73 -0
- vispy/util/fonts/_quartz.py +192 -0
- vispy/util/fonts/_triage.py +36 -0
- vispy/util/fonts/_vispy_fonts.py +20 -0
- vispy/util/fonts/_win32.py +105 -0
- vispy/util/fonts/data/OpenSans-Bold.ttf +0 -0
- vispy/util/fonts/data/OpenSans-BoldItalic.ttf +0 -0
- vispy/util/fonts/data/OpenSans-Italic.ttf +0 -0
- vispy/util/fonts/data/OpenSans-Regular.ttf +0 -0
- vispy/util/fonts/tests/__init__.py +0 -0
- vispy/util/fonts/tests/test_font.py +45 -0
- vispy/util/fourier.py +69 -0
- vispy/util/frozen.py +25 -0
- vispy/util/gallery_scraper.py +268 -0
- vispy/util/keys.py +91 -0
- vispy/util/logs.py +358 -0
- vispy/util/osmesa_gl.py +17 -0
- vispy/util/profiler.py +135 -0
- vispy/util/ptime.py +16 -0
- vispy/util/quaternion.py +229 -0
- vispy/util/svg/__init__.py +18 -0
- vispy/util/svg/base.py +20 -0
- vispy/util/svg/color.py +219 -0
- vispy/util/svg/element.py +51 -0
- vispy/util/svg/geometry.py +478 -0
- vispy/util/svg/group.py +66 -0
- vispy/util/svg/length.py +81 -0
- vispy/util/svg/number.py +25 -0
- vispy/util/svg/path.py +332 -0
- vispy/util/svg/shapes.py +57 -0
- vispy/util/svg/style.py +59 -0
- vispy/util/svg/svg.py +40 -0
- vispy/util/svg/transform.py +223 -0
- vispy/util/svg/transformable.py +28 -0
- vispy/util/svg/viewport.py +73 -0
- vispy/util/tests/__init__.py +0 -0
- vispy/util/tests/test_config.py +58 -0
- vispy/util/tests/test_docstring_parameters.py +123 -0
- vispy/util/tests/test_emitter_group.py +262 -0
- vispy/util/tests/test_event_emitter.py +743 -0
- vispy/util/tests/test_fourier.py +35 -0
- vispy/util/tests/test_gallery_scraper.py +112 -0
- vispy/util/tests/test_import.py +127 -0
- vispy/util/tests/test_key.py +22 -0
- vispy/util/tests/test_logging.py +45 -0
- vispy/util/tests/test_run.py +14 -0
- vispy/util/tests/test_transforms.py +42 -0
- vispy/util/tests/test_vispy.py +48 -0
- vispy/util/transforms.py +201 -0
- vispy/util/wrappers.py +155 -0
- vispy/version.py +21 -0
- vispy/visuals/__init__.py +50 -0
- vispy/visuals/_scalable_textures.py +487 -0
- vispy/visuals/axis.py +678 -0
- vispy/visuals/border.py +208 -0
- vispy/visuals/box.py +79 -0
- vispy/visuals/collections/__init__.py +30 -0
- vispy/visuals/collections/agg_fast_path_collection.py +219 -0
- vispy/visuals/collections/agg_path_collection.py +197 -0
- vispy/visuals/collections/agg_point_collection.py +52 -0
- vispy/visuals/collections/agg_segment_collection.py +142 -0
- vispy/visuals/collections/array_list.py +401 -0
- vispy/visuals/collections/base_collection.py +482 -0
- vispy/visuals/collections/collection.py +253 -0
- vispy/visuals/collections/path_collection.py +23 -0
- vispy/visuals/collections/point_collection.py +19 -0
- vispy/visuals/collections/polygon_collection.py +25 -0
- vispy/visuals/collections/raw_path_collection.py +119 -0
- vispy/visuals/collections/raw_point_collection.py +113 -0
- vispy/visuals/collections/raw_polygon_collection.py +77 -0
- vispy/visuals/collections/raw_segment_collection.py +112 -0
- vispy/visuals/collections/raw_triangle_collection.py +78 -0
- vispy/visuals/collections/segment_collection.py +19 -0
- vispy/visuals/collections/triangle_collection.py +16 -0
- vispy/visuals/collections/util.py +168 -0
- vispy/visuals/colorbar.py +699 -0
- vispy/visuals/cube.py +41 -0
- vispy/visuals/ellipse.py +162 -0
- vispy/visuals/filters/__init__.py +10 -0
- vispy/visuals/filters/base_filter.py +242 -0
- vispy/visuals/filters/clipper.py +60 -0
- vispy/visuals/filters/clipping_planes.py +122 -0
- vispy/visuals/filters/color.py +181 -0
- vispy/visuals/filters/markers.py +28 -0
- vispy/visuals/filters/mesh.py +801 -0
- vispy/visuals/filters/picking.py +60 -0
- vispy/visuals/filters/tests/__init__.py +3 -0
- vispy/visuals/filters/tests/test_primitive_picking_filters.py +70 -0
- vispy/visuals/filters/tests/test_wireframe_filter.py +16 -0
- vispy/visuals/glsl/__init__.py +1 -0
- vispy/visuals/glsl/antialiasing.py +133 -0
- vispy/visuals/glsl/color.py +63 -0
- vispy/visuals/graphs/__init__.py +1 -0
- vispy/visuals/graphs/graph.py +240 -0
- vispy/visuals/graphs/layouts/__init__.py +55 -0
- vispy/visuals/graphs/layouts/circular.py +49 -0
- vispy/visuals/graphs/layouts/force_directed.py +211 -0
- vispy/visuals/graphs/layouts/networkx_layout.py +87 -0
- vispy/visuals/graphs/layouts/random.py +52 -0
- vispy/visuals/graphs/tests/__init__.py +1 -0
- vispy/visuals/graphs/tests/test_layouts.py +139 -0
- vispy/visuals/graphs/tests/test_networkx_layout.py +47 -0
- vispy/visuals/graphs/util.py +120 -0
- vispy/visuals/gridlines.py +161 -0
- vispy/visuals/gridmesh.py +98 -0
- vispy/visuals/histogram.py +58 -0
- vispy/visuals/image.py +701 -0
- vispy/visuals/image_complex.py +130 -0
- vispy/visuals/infinite_line.py +199 -0
- vispy/visuals/instanced_mesh.py +152 -0
- vispy/visuals/isocurve.py +213 -0
- vispy/visuals/isoline.py +241 -0
- vispy/visuals/isosurface.py +113 -0
- vispy/visuals/line/__init__.py +6 -0
- vispy/visuals/line/arrow.py +289 -0
- vispy/visuals/line/dash_atlas.py +90 -0
- vispy/visuals/line/line.py +545 -0
- vispy/visuals/line_plot.py +135 -0
- vispy/visuals/linear_region.py +199 -0
- vispy/visuals/markers.py +819 -0
- vispy/visuals/mesh.py +373 -0
- vispy/visuals/mesh_normals.py +159 -0
- vispy/visuals/plane.py +54 -0
- vispy/visuals/polygon.py +145 -0
- vispy/visuals/rectangle.py +196 -0
- vispy/visuals/regular_polygon.py +56 -0
- vispy/visuals/scrolling_lines.py +197 -0
- vispy/visuals/shaders/__init__.py +17 -0
- vispy/visuals/shaders/compiler.py +206 -0
- vispy/visuals/shaders/expression.py +99 -0
- vispy/visuals/shaders/function.py +788 -0
- vispy/visuals/shaders/multiprogram.py +145 -0
- vispy/visuals/shaders/parsing.py +140 -0
- vispy/visuals/shaders/program.py +161 -0
- vispy/visuals/shaders/shader_object.py +162 -0
- vispy/visuals/shaders/tests/__init__.py +0 -0
- vispy/visuals/shaders/tests/test_function.py +486 -0
- vispy/visuals/shaders/tests/test_multiprogram.py +78 -0
- vispy/visuals/shaders/tests/test_parsing.py +57 -0
- vispy/visuals/shaders/variable.py +272 -0
- vispy/visuals/spectrogram.py +169 -0
- vispy/visuals/sphere.py +80 -0
- vispy/visuals/surface_plot.py +192 -0
- vispy/visuals/tests/__init__.py +0 -0
- vispy/visuals/tests/test_arrows.py +109 -0
- vispy/visuals/tests/test_axis.py +120 -0
- vispy/visuals/tests/test_collections.py +15 -0
- vispy/visuals/tests/test_colorbar.py +179 -0
- vispy/visuals/tests/test_colormap.py +97 -0
- vispy/visuals/tests/test_ellipse.py +122 -0
- vispy/visuals/tests/test_gridlines.py +30 -0
- vispy/visuals/tests/test_histogram.py +24 -0
- vispy/visuals/tests/test_image.py +392 -0
- vispy/visuals/tests/test_image_complex.py +36 -0
- vispy/visuals/tests/test_infinite_line.py +53 -0
- vispy/visuals/tests/test_instanced_mesh.py +50 -0
- vispy/visuals/tests/test_isosurface.py +22 -0
- vispy/visuals/tests/test_linear_region.py +152 -0
- vispy/visuals/tests/test_markers.py +54 -0
- vispy/visuals/tests/test_mesh.py +261 -0
- vispy/visuals/tests/test_mesh_normals.py +218 -0
- vispy/visuals/tests/test_polygon.py +112 -0
- vispy/visuals/tests/test_rectangle.py +163 -0
- vispy/visuals/tests/test_regular_polygon.py +111 -0
- vispy/visuals/tests/test_scalable_textures.py +196 -0
- vispy/visuals/tests/test_sdf.py +73 -0
- vispy/visuals/tests/test_spectrogram.py +42 -0
- vispy/visuals/tests/test_surface_plot.py +57 -0
- vispy/visuals/tests/test_text.py +95 -0
- vispy/visuals/tests/test_volume.py +542 -0
- vispy/visuals/tests/test_windbarb.py +33 -0
- vispy/visuals/text/__init__.py +7 -0
- vispy/visuals/text/_sdf_cpu.cpython-313-aarch64-linux-gnu.so +0 -0
- vispy/visuals/text/_sdf_cpu.pyx +112 -0
- vispy/visuals/text/_sdf_gpu.py +316 -0
- vispy/visuals/text/text.py +675 -0
- vispy/visuals/transforms/__init__.py +34 -0
- vispy/visuals/transforms/_util.py +191 -0
- vispy/visuals/transforms/base_transform.py +233 -0
- vispy/visuals/transforms/chain.py +300 -0
- vispy/visuals/transforms/interactive.py +98 -0
- vispy/visuals/transforms/linear.py +564 -0
- vispy/visuals/transforms/nonlinear.py +398 -0
- vispy/visuals/transforms/tests/__init__.py +0 -0
- vispy/visuals/transforms/tests/test_transforms.py +243 -0
- vispy/visuals/transforms/transform_system.py +339 -0
- vispy/visuals/tube.py +173 -0
- vispy/visuals/visual.py +923 -0
- vispy/visuals/volume.py +1366 -0
- vispy/visuals/windbarb.py +291 -0
- vispy/visuals/xyz_axis.py +34 -0
- vispy-0.15.0.dist-info/METADATA +243 -0
- vispy-0.15.0.dist-info/RECORD +521 -0
- vispy-0.15.0.dist-info/WHEEL +6 -0
- vispy-0.15.0.dist-info/licenses/LICENSE.txt +36 -0
- vispy-0.15.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (c) Vispy Development Team. All Rights Reserved.
|
|
3
|
+
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
|
|
4
|
+
import numbers
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
from vispy.gloo import Texture2D, VertexBuffer
|
|
9
|
+
from vispy.visuals.shaders import Function, Varying
|
|
10
|
+
from vispy.visuals.filters import Filter, PrimitivePickingFilter
|
|
11
|
+
from ...color import Color
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TextureFilter(Filter):
|
|
15
|
+
"""Filter to apply a texture to a mesh.
|
|
16
|
+
|
|
17
|
+
Note the texture is applied by multiplying the texture color by the
|
|
18
|
+
Visual's produced color. By specifying `color="white"` when creating
|
|
19
|
+
a `MeshVisual` the result will be the unaltered texture value. Any
|
|
20
|
+
other color, including the default, will result in a blending of that
|
|
21
|
+
color and the color of the texture.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
texture : (M, N) or (M, N, C) array
|
|
26
|
+
The 2D texture image.
|
|
27
|
+
texcoords : (N, 2) array
|
|
28
|
+
The texture coordinates.
|
|
29
|
+
enabled : bool
|
|
30
|
+
Whether the display of the texture is enabled.
|
|
31
|
+
|
|
32
|
+
Examples
|
|
33
|
+
--------
|
|
34
|
+
See
|
|
35
|
+
`examples/basics/scene/mesh_texture.py
|
|
36
|
+
<https://github.com/vispy/vispy/blob/main/examples/basics/scene/mesh_texture.py>`_
|
|
37
|
+
example script.
|
|
38
|
+
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(self, texture, texcoords, enabled=True):
|
|
42
|
+
"""Apply a texture on a mesh."""
|
|
43
|
+
vfunc = Function("""
|
|
44
|
+
void pass_coords() {
|
|
45
|
+
$v_texcoords = $texcoords;
|
|
46
|
+
}
|
|
47
|
+
""")
|
|
48
|
+
ffunc = Function("""
|
|
49
|
+
void apply_texture() {
|
|
50
|
+
if ($enabled == 1) {
|
|
51
|
+
gl_FragColor *= texture2D($u_texture, $texcoords);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
""")
|
|
55
|
+
self._texcoord_varying = Varying('v_texcoord', 'vec2')
|
|
56
|
+
vfunc['v_texcoords'] = self._texcoord_varying
|
|
57
|
+
ffunc['texcoords'] = self._texcoord_varying
|
|
58
|
+
self._texcoords_buffer = VertexBuffer(
|
|
59
|
+
np.zeros((0, 2), dtype=np.float32)
|
|
60
|
+
)
|
|
61
|
+
vfunc['texcoords'] = self._texcoords_buffer
|
|
62
|
+
super().__init__(vcode=vfunc, vhook='pre', fcode=ffunc)
|
|
63
|
+
|
|
64
|
+
self.enabled = enabled
|
|
65
|
+
self.texture = texture
|
|
66
|
+
self.texcoords = texcoords
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def enabled(self):
|
|
70
|
+
"""True to display the texture, False to disable."""
|
|
71
|
+
return self._enabled
|
|
72
|
+
|
|
73
|
+
@enabled.setter
|
|
74
|
+
def enabled(self, enabled):
|
|
75
|
+
self._enabled = enabled
|
|
76
|
+
self.fshader['enabled'] = 1 if enabled else 0
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def texture(self):
|
|
80
|
+
"""The texture image."""
|
|
81
|
+
return self._texture
|
|
82
|
+
|
|
83
|
+
@texture.setter
|
|
84
|
+
def texture(self, texture):
|
|
85
|
+
self._texture = texture
|
|
86
|
+
self.fshader['u_texture'] = Texture2D(texture)
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def texcoords(self):
|
|
90
|
+
"""The texture coordinates as an (N, 2) array of floats."""
|
|
91
|
+
return self._texcoords
|
|
92
|
+
|
|
93
|
+
@texcoords.setter
|
|
94
|
+
def texcoords(self, texcoords):
|
|
95
|
+
self._texcoords = texcoords
|
|
96
|
+
self._update_texcoords_buffer(texcoords)
|
|
97
|
+
|
|
98
|
+
def _update_texcoords_buffer(self, texcoords):
|
|
99
|
+
if not self._attached or self._visual is None:
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
# FIXME: Indices for texture coordinates might be different than face
|
|
103
|
+
# indices, although in some cases they are the same. Currently,
|
|
104
|
+
# vispy.io.read_mesh assumes face indices and texture coordinates are
|
|
105
|
+
# the same.
|
|
106
|
+
# TODO:
|
|
107
|
+
# 1. Add reading and returning of texture coordinate indices in
|
|
108
|
+
# read_mesh.
|
|
109
|
+
# 2. Add texture coordinate indices in MeshData from
|
|
110
|
+
# vispy.geometry.meshdata
|
|
111
|
+
# 3. Use mesh_data.get_texcoords_indices() here below.
|
|
112
|
+
tc = texcoords[self._visual.mesh_data.get_faces()]
|
|
113
|
+
self._texcoords_buffer.set_data(tc, convert=True)
|
|
114
|
+
|
|
115
|
+
def _attach(self, visual):
|
|
116
|
+
super()._attach(visual)
|
|
117
|
+
self._update_texcoords_buffer(self._texcoords)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
shading_vertex_template = """
|
|
121
|
+
varying vec3 v_normal_vec;
|
|
122
|
+
varying vec3 v_light_vec;
|
|
123
|
+
varying vec3 v_eye_vec;
|
|
124
|
+
varying vec4 v_pos_scene;
|
|
125
|
+
|
|
126
|
+
void prepare_shading() {
|
|
127
|
+
vec4 pos_scene = $render2scene(gl_Position);
|
|
128
|
+
v_pos_scene = pos_scene;
|
|
129
|
+
|
|
130
|
+
// Calculate normal
|
|
131
|
+
vec4 normal_scene = $visual2scene(vec4($normal, 1.0));
|
|
132
|
+
vec4 origin_scene = $visual2scene(vec4(0.0, 0.0, 0.0, 1.0));
|
|
133
|
+
normal_scene /= normal_scene.w;
|
|
134
|
+
origin_scene /= origin_scene.w;
|
|
135
|
+
v_normal_vec = normalize(normal_scene.xyz - origin_scene.xyz);
|
|
136
|
+
|
|
137
|
+
// Calculate eye vector per-vertex (to account for perspective)
|
|
138
|
+
vec4 pos_doc = $scene2doc(pos_scene);
|
|
139
|
+
pos_doc /= pos_doc.w;
|
|
140
|
+
vec4 pos_front = pos_doc;
|
|
141
|
+
vec4 pos_back = pos_doc;
|
|
142
|
+
pos_front.z -= 1e-5;
|
|
143
|
+
pos_back.z += 1e-5;
|
|
144
|
+
pos_front = $doc2scene(pos_front);
|
|
145
|
+
pos_back = $doc2scene(pos_back);
|
|
146
|
+
// The eye vec eminates from the eye, pointing towards what is being viewed
|
|
147
|
+
v_eye_vec = normalize(pos_back.xyz / pos_back.w - pos_front.xyz / pos_front.w);
|
|
148
|
+
|
|
149
|
+
// Pass on light direction (the direction that the "photons" travel)
|
|
150
|
+
v_light_vec = normalize($light_dir.xyz);
|
|
151
|
+
}
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
shading_fragment_template = """
|
|
156
|
+
varying vec3 v_normal_vec;
|
|
157
|
+
varying vec3 v_light_vec;
|
|
158
|
+
varying vec3 v_eye_vec;
|
|
159
|
+
varying vec4 v_pos_scene;
|
|
160
|
+
|
|
161
|
+
void shade() {
|
|
162
|
+
if ($shading_enabled != 1) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
vec3 base_color = gl_FragColor.rgb;
|
|
167
|
+
vec4 ambient_coeff = $ambient_coefficient;
|
|
168
|
+
vec4 diffuse_coeff = $diffuse_coefficient;
|
|
169
|
+
vec4 specular_coeff = $specular_coefficient;
|
|
170
|
+
vec4 ambient_light = $ambient_light;
|
|
171
|
+
vec4 diffuse_light = $diffuse_light;
|
|
172
|
+
vec4 specular_light = $specular_light;
|
|
173
|
+
float shininess = $shininess;
|
|
174
|
+
|
|
175
|
+
vec3 normal = v_normal_vec;
|
|
176
|
+
if ($flat_shading == 1) {
|
|
177
|
+
vec3 u = dFdx(v_pos_scene.xyz);
|
|
178
|
+
vec3 v = dFdy(v_pos_scene.xyz);
|
|
179
|
+
normal = cross(u, v);
|
|
180
|
+
} else {
|
|
181
|
+
// Note(asnt): The normal calculated above always points in the
|
|
182
|
+
// direction of the camera. Reintroduce the original orientation of the
|
|
183
|
+
// face.
|
|
184
|
+
normal = gl_FrontFacing ? normal : -normal;
|
|
185
|
+
}
|
|
186
|
+
normal = normalize(normal);
|
|
187
|
+
|
|
188
|
+
vec3 light_vec = normalize(v_light_vec);
|
|
189
|
+
vec3 eye_vec = normalize(v_eye_vec);
|
|
190
|
+
|
|
191
|
+
// Ambient illumination.
|
|
192
|
+
vec3 ambient = ambient_coeff.rgb * ambient_coeff.a
|
|
193
|
+
* ambient_light.rgb * ambient_light.a;
|
|
194
|
+
|
|
195
|
+
// Diffuse illumination (light vec points towards the surface)
|
|
196
|
+
float diffuse_factor = dot(-light_vec, normal);
|
|
197
|
+
diffuse_factor = max(diffuse_factor, 0.0);
|
|
198
|
+
vec3 diffuse = diffuse_factor
|
|
199
|
+
* diffuse_coeff.rgb * diffuse_coeff.a
|
|
200
|
+
* diffuse_light.rgb * diffuse_light.a;
|
|
201
|
+
|
|
202
|
+
// Specular illumination. Both light_vec and eye_vec point towards the surface.
|
|
203
|
+
float specular_factor = 0.0;
|
|
204
|
+
bool is_illuminated = diffuse_factor > 0.0;
|
|
205
|
+
if (is_illuminated && shininess > 0.0) {
|
|
206
|
+
// Phong reflection
|
|
207
|
+
//vec3 reflection = reflect(-light_vec, normal);
|
|
208
|
+
//float reflection_factor = max(dot(reflection, eye_vec), 0.0);
|
|
209
|
+
// Blinn-Phong reflection
|
|
210
|
+
vec3 halfway = -normalize(light_vec + eye_vec);
|
|
211
|
+
float reflection_factor = clamp(dot(halfway, normal), 0.0, 1.0);
|
|
212
|
+
specular_factor = pow(reflection_factor, shininess);
|
|
213
|
+
}
|
|
214
|
+
vec3 specular = specular_factor
|
|
215
|
+
* specular_coeff.rgb * specular_coeff.a
|
|
216
|
+
* specular_light.rgb * specular_light.a;
|
|
217
|
+
|
|
218
|
+
// Blend the base color and combine the illuminations.
|
|
219
|
+
vec3 color = base_color * (ambient + diffuse) + specular;
|
|
220
|
+
gl_FragColor.rgb = color;
|
|
221
|
+
}
|
|
222
|
+
""" # noqa
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _as_rgba(intensity_or_color, default_rgb=(1.0, 1.0, 1.0)):
|
|
226
|
+
"""Create an RGBA color from a color or a scalar intensity.
|
|
227
|
+
|
|
228
|
+
Examples
|
|
229
|
+
--------
|
|
230
|
+
>>> # Specify the full RGBA color.
|
|
231
|
+
>>> _as_rgba((0.2, 0.3, 0.4, 0.25))
|
|
232
|
+
... <Color: (0.2, 0.3, 0.4, 0.25)>
|
|
233
|
+
>>> # Specify an RGB color. (Default intensity `1.0` is used.)
|
|
234
|
+
>>> _as_rgba((0.2, 0.3, 0.4))
|
|
235
|
+
... <Color: (0.2, 0.3, 0.4, 1.0)>
|
|
236
|
+
>>> # Specify an intensity only. (Default color `(1.0, 1.0, 1.0)` is used.)
|
|
237
|
+
>>> _as_rgba(0.25)
|
|
238
|
+
... <Color: (1.0, 1.0, 1.0, 0.25)>
|
|
239
|
+
"""
|
|
240
|
+
if isinstance(intensity_or_color, numbers.Number):
|
|
241
|
+
intensity = intensity_or_color
|
|
242
|
+
return Color(default_rgb, alpha=intensity)
|
|
243
|
+
color = intensity_or_color
|
|
244
|
+
return Color(color)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class ShadingFilter(Filter):
|
|
248
|
+
"""Apply shading to a :class:`~vispy.visuals.mesh.MeshVisual` using the Phong reflection model.
|
|
249
|
+
|
|
250
|
+
For convenience, a :class:`~vispy.visuals.mesh.MeshVisual` creates and
|
|
251
|
+
embeds a shading filter when constructed with an explicit `shading`
|
|
252
|
+
parameter, e.g. `mesh = MeshVisual(..., shading='smooth')`. The filter is
|
|
253
|
+
then accessible as `mesh.shading_filter`.
|
|
254
|
+
|
|
255
|
+
When attached manually to a :class:`~vispy.visuals.mesh.MeshVisual`, the
|
|
256
|
+
shading filter should come after any other filter that modifies the base
|
|
257
|
+
color to be shaded. See the examples below.
|
|
258
|
+
|
|
259
|
+
Parameters
|
|
260
|
+
----------
|
|
261
|
+
shading : str
|
|
262
|
+
Shading mode: None, 'flat' or 'smooth'. If None, the shading is
|
|
263
|
+
disabled.
|
|
264
|
+
ambient_coefficient : str or tuple or Color
|
|
265
|
+
Color and intensity of the ambient reflection coefficient (Ka).
|
|
266
|
+
diffuse_coefficient : str or tuple or Color
|
|
267
|
+
Color and intensity of the diffuse reflection coefficient (Kd).
|
|
268
|
+
specular_coefficient : str or tuple or Color
|
|
269
|
+
Color and intensity of the specular reflection coefficient (Ks).
|
|
270
|
+
shininess : float
|
|
271
|
+
The shininess controls the size of specular highlight. The higher, the
|
|
272
|
+
more localized. Must be greater than or equal to zero.
|
|
273
|
+
light_dir : array_like
|
|
274
|
+
Direction of the light. Assuming a directional light.
|
|
275
|
+
ambient_light : str or tuple or Color
|
|
276
|
+
Color and intensity of the ambient light.
|
|
277
|
+
diffuse_light : str or tuple or Color
|
|
278
|
+
Color and intensity of the diffuse light.
|
|
279
|
+
specular_light : str or tuple or Color
|
|
280
|
+
Color and intensity of the specular light.
|
|
281
|
+
enabled : bool, default=True
|
|
282
|
+
Whether the filter is enabled at creation time. This can be changed at
|
|
283
|
+
run time with :obj:`~enabled`.
|
|
284
|
+
|
|
285
|
+
Notes
|
|
286
|
+
-----
|
|
287
|
+
Under the Phong reflection model, the illumination `I` is computed as::
|
|
288
|
+
|
|
289
|
+
I = I_ambient + mesh_color * I_diffuse + I_specular
|
|
290
|
+
|
|
291
|
+
for each color channel independently.
|
|
292
|
+
`mesh_color` is the color of the :class:`~vispy.visuals.mesh.MeshVisual`,
|
|
293
|
+
possibly modified by the filters applied before this one.
|
|
294
|
+
The ambient, diffuse and specular terms are defined as::
|
|
295
|
+
|
|
296
|
+
I_ambient = Ka * Ia
|
|
297
|
+
I_diffuse = Kd * Id * dot(L, N)
|
|
298
|
+
I_specular = Ks * Is * dot(R, V) ** s
|
|
299
|
+
|
|
300
|
+
with
|
|
301
|
+
|
|
302
|
+
`L`
|
|
303
|
+
the light direction, assuming a directional light,
|
|
304
|
+
`N`
|
|
305
|
+
the normal to the surface at the reflection point,
|
|
306
|
+
`R`
|
|
307
|
+
the direction of the reflection,
|
|
308
|
+
`V`
|
|
309
|
+
the direction to the viewer,
|
|
310
|
+
`s`
|
|
311
|
+
the shininess factor.
|
|
312
|
+
|
|
313
|
+
The `Ka`, `Kd` and `Ks` coefficients are defined as an RGBA color. The RGB
|
|
314
|
+
components define the color that the surface reflects, and the alpha
|
|
315
|
+
component (A) defines the intensity/attenuation of the reflection. When
|
|
316
|
+
applied in the per-channel illumation formulas above, the color component
|
|
317
|
+
is multiplied by the intensity to obtain the final coefficient, e.g.
|
|
318
|
+
`Kd = R * A` for the red channel.
|
|
319
|
+
|
|
320
|
+
Similarly, the light intensities, `Ia`, `Id` and `Is`, are defined by RGBA
|
|
321
|
+
colors, corresponding to the color of the light and its intensity.
|
|
322
|
+
|
|
323
|
+
Examples
|
|
324
|
+
--------
|
|
325
|
+
Define the mesh data for a :class:`vispy.visuals.mesh.MeshVisual`:
|
|
326
|
+
|
|
327
|
+
>>> # A triangle.
|
|
328
|
+
>>> vertices = np.array([(0, 0, 0), (1, 1, 1), (0, 1, 0)], dtype=float)
|
|
329
|
+
>>> faces = np.array([(0, 1, 2)], dtype=int)
|
|
330
|
+
|
|
331
|
+
Let the :class:`vispy.visuals.mesh.MeshVisual` create and embed a shading
|
|
332
|
+
filter:
|
|
333
|
+
|
|
334
|
+
>>> mesh = MeshVisual(vertices, faces, shading='smooth')
|
|
335
|
+
>>> # Configure the filter afterwards.
|
|
336
|
+
>>> mesh.shading_filter.shininess = 64
|
|
337
|
+
>>> mesh.shading_filter.specular_coefficient = 0.3
|
|
338
|
+
|
|
339
|
+
Create the shading filter manually and attach it to a
|
|
340
|
+
:class:`vispy.visuals.mesh.MeshVisual`:
|
|
341
|
+
|
|
342
|
+
>>> # With the default shading parameters.
|
|
343
|
+
>>> shading_filter = ShadingFilter()
|
|
344
|
+
>>> mesh = MeshVisual(vertices, faces)
|
|
345
|
+
>>> mesh.attach(shading_filter)
|
|
346
|
+
|
|
347
|
+
The filter can be configured at creation time and at run time:
|
|
348
|
+
|
|
349
|
+
>>> # Configure at creation time.
|
|
350
|
+
>>> shading_filter = ShadingFilter(
|
|
351
|
+
... # A shiny surface (small specular highlight).
|
|
352
|
+
... shininess=250,
|
|
353
|
+
... # A blue higlight, at half intensity.
|
|
354
|
+
... specular_coefficient=(0, 0, 1, 0.5),
|
|
355
|
+
... # Equivalent to `(0.7, 0.7, 0.7, 1.0)`.
|
|
356
|
+
... diffuse_coefficient=0.7,
|
|
357
|
+
... # Same as `(0.2, 0.3, 0.3, 1.0)`.
|
|
358
|
+
... ambient_coefficient=(0.2, 0.3, 0.3),
|
|
359
|
+
... )
|
|
360
|
+
>>> # Change the configuration at run time.
|
|
361
|
+
>>> shading_filter.shininess = 64
|
|
362
|
+
>>> shading_filter.specular_coefficient = 0.3
|
|
363
|
+
|
|
364
|
+
Disable the filter temporarily:
|
|
365
|
+
|
|
366
|
+
>>> # Turn off the shading.
|
|
367
|
+
>>> shading_filter.enabled = False
|
|
368
|
+
... # Some time passes...
|
|
369
|
+
>>> # Turn on the shading again.
|
|
370
|
+
>>> shading_filter.enabled = True
|
|
371
|
+
|
|
372
|
+
When using the :class:`WireframeFilter`, the wireframe is shaded only if
|
|
373
|
+
the wireframe filter is attached before the shading filter:
|
|
374
|
+
|
|
375
|
+
>>> shading_filter = ShadingFilter()
|
|
376
|
+
>>> wireframe_filter = WireframeFilter()
|
|
377
|
+
>>> # Option 1: Shade the wireframe.
|
|
378
|
+
>>> mesh1 = MeshVisual(vertices, faces)
|
|
379
|
+
>>> mesh1.attached(wireframe_filter)
|
|
380
|
+
>>> mesh1.attached(shading_filter)
|
|
381
|
+
>>> # Option 2: Do not shade the wireframe.
|
|
382
|
+
>>> mesh2 = MeshVisual(vertices, faces)
|
|
383
|
+
>>> mesh2.attached(shading_filter)
|
|
384
|
+
>>> mesh2.attached(wireframe_filter)
|
|
385
|
+
|
|
386
|
+
See also
|
|
387
|
+
`examples/basics/scene/mesh_shading.py
|
|
388
|
+
<https://github.com/vispy/vispy/blob/main/examples/basics/scene/mesh_shading.py>`_
|
|
389
|
+
example script.
|
|
390
|
+
"""
|
|
391
|
+
_shaders = {
|
|
392
|
+
'vertex': shading_vertex_template,
|
|
393
|
+
'fragment': shading_fragment_template,
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
def __init__(self, shading='flat',
|
|
397
|
+
ambient_coefficient=(1, 1, 1, 1),
|
|
398
|
+
diffuse_coefficient=(1, 1, 1, 1),
|
|
399
|
+
specular_coefficient=(1, 1, 1, 1),
|
|
400
|
+
shininess=100,
|
|
401
|
+
light_dir=(10, 5, -5),
|
|
402
|
+
ambient_light=(1, 1, 1, .25),
|
|
403
|
+
diffuse_light=(1, 1, 1, 0.7),
|
|
404
|
+
specular_light=(1, 1, 1, .25),
|
|
405
|
+
enabled=True):
|
|
406
|
+
self._shading = shading
|
|
407
|
+
|
|
408
|
+
self._ambient_coefficient = _as_rgba(ambient_coefficient)
|
|
409
|
+
self._diffuse_coefficient = _as_rgba(diffuse_coefficient)
|
|
410
|
+
self._specular_coefficient = _as_rgba(specular_coefficient)
|
|
411
|
+
self._shininess = shininess
|
|
412
|
+
|
|
413
|
+
self._light_dir = light_dir
|
|
414
|
+
self._ambient_light = _as_rgba(ambient_light)
|
|
415
|
+
self._diffuse_light = _as_rgba(diffuse_light)
|
|
416
|
+
self._specular_light = _as_rgba(specular_light)
|
|
417
|
+
|
|
418
|
+
self._enabled = enabled
|
|
419
|
+
|
|
420
|
+
vfunc = Function(self._shaders['vertex'])
|
|
421
|
+
ffunc = Function(self._shaders['fragment'])
|
|
422
|
+
|
|
423
|
+
self._normals = VertexBuffer(np.zeros((0, 3), dtype=np.float32))
|
|
424
|
+
self._normals_cache = None
|
|
425
|
+
vfunc['normal'] = self._normals
|
|
426
|
+
|
|
427
|
+
super().__init__(vcode=vfunc, fcode=ffunc)
|
|
428
|
+
|
|
429
|
+
@property
|
|
430
|
+
def enabled(self):
|
|
431
|
+
"""True to enable the filter, False to disable."""
|
|
432
|
+
return self._enabled
|
|
433
|
+
|
|
434
|
+
@enabled.setter
|
|
435
|
+
def enabled(self, enabled):
|
|
436
|
+
self._enabled = enabled
|
|
437
|
+
self._update_data()
|
|
438
|
+
|
|
439
|
+
@property
|
|
440
|
+
def shading(self):
|
|
441
|
+
"""The shading method."""
|
|
442
|
+
return self._shading
|
|
443
|
+
|
|
444
|
+
@shading.setter
|
|
445
|
+
def shading(self, shading):
|
|
446
|
+
assert shading in (None, 'flat', 'smooth')
|
|
447
|
+
self._shading = shading
|
|
448
|
+
self._update_data()
|
|
449
|
+
|
|
450
|
+
@property
|
|
451
|
+
def light_dir(self):
|
|
452
|
+
"""The light direction."""
|
|
453
|
+
return self._light_dir
|
|
454
|
+
|
|
455
|
+
@light_dir.setter
|
|
456
|
+
def light_dir(self, direction):
|
|
457
|
+
direction = np.array(direction, float).ravel()
|
|
458
|
+
if direction.size != 3 or not np.isfinite(direction).all():
|
|
459
|
+
raise ValueError('Invalid direction %s' % direction)
|
|
460
|
+
self._light_dir = tuple(direction)
|
|
461
|
+
self._update_data()
|
|
462
|
+
|
|
463
|
+
@property
|
|
464
|
+
def ambient_light(self):
|
|
465
|
+
"""The color and intensity of the ambient light."""
|
|
466
|
+
return self._ambient_light
|
|
467
|
+
|
|
468
|
+
@ambient_light.setter
|
|
469
|
+
def ambient_light(self, light_color):
|
|
470
|
+
self._ambient_light = _as_rgba(light_color)
|
|
471
|
+
self._update_data()
|
|
472
|
+
|
|
473
|
+
@property
|
|
474
|
+
def diffuse_light(self):
|
|
475
|
+
"""The color and intensity of the diffuse light."""
|
|
476
|
+
return self._diffuse_light
|
|
477
|
+
|
|
478
|
+
@diffuse_light.setter
|
|
479
|
+
def diffuse_light(self, light_color):
|
|
480
|
+
self._diffuse_light = _as_rgba(light_color)
|
|
481
|
+
self._update_data()
|
|
482
|
+
|
|
483
|
+
@property
|
|
484
|
+
def specular_light(self):
|
|
485
|
+
"""The color and intensity of the specular light."""
|
|
486
|
+
return self._specular_light
|
|
487
|
+
|
|
488
|
+
@specular_light.setter
|
|
489
|
+
def specular_light(self, light_color):
|
|
490
|
+
self._specular_light = _as_rgba(light_color)
|
|
491
|
+
self._update_data()
|
|
492
|
+
|
|
493
|
+
@property
|
|
494
|
+
def ambient_coefficient(self):
|
|
495
|
+
"""The ambient reflection coefficient."""
|
|
496
|
+
return self._ambient_coefficient
|
|
497
|
+
|
|
498
|
+
@ambient_coefficient.setter
|
|
499
|
+
def ambient_coefficient(self, color):
|
|
500
|
+
self._ambient_coefficient = _as_rgba(color)
|
|
501
|
+
self._update_data()
|
|
502
|
+
|
|
503
|
+
@property
|
|
504
|
+
def diffuse_coefficient(self):
|
|
505
|
+
"""The diffuse reflection coefficient."""
|
|
506
|
+
return self._diffuse_coefficient
|
|
507
|
+
|
|
508
|
+
@diffuse_coefficient.setter
|
|
509
|
+
def diffuse_coefficient(self, diffuse_coefficient):
|
|
510
|
+
self._diffuse_coefficient = _as_rgba(diffuse_coefficient)
|
|
511
|
+
self._update_data()
|
|
512
|
+
|
|
513
|
+
@property
|
|
514
|
+
def specular_coefficient(self):
|
|
515
|
+
"""The specular reflection coefficient."""
|
|
516
|
+
return self._specular_coefficient
|
|
517
|
+
|
|
518
|
+
@specular_coefficient.setter
|
|
519
|
+
def specular_coefficient(self, specular_coefficient):
|
|
520
|
+
self._specular_coefficient = _as_rgba(specular_coefficient)
|
|
521
|
+
self._update_data()
|
|
522
|
+
|
|
523
|
+
@property
|
|
524
|
+
def shininess(self):
|
|
525
|
+
"""The shininess controlling the spread of the specular highlight."""
|
|
526
|
+
return self._shininess
|
|
527
|
+
|
|
528
|
+
@shininess.setter
|
|
529
|
+
def shininess(self, shininess):
|
|
530
|
+
self._shininess = float(shininess)
|
|
531
|
+
self._update_data()
|
|
532
|
+
|
|
533
|
+
def _update_data(self):
|
|
534
|
+
if not self._attached:
|
|
535
|
+
return
|
|
536
|
+
|
|
537
|
+
self.vshader['light_dir'] = self._light_dir
|
|
538
|
+
|
|
539
|
+
self.fshader['ambient_light'] = self._ambient_light.rgba
|
|
540
|
+
self.fshader['diffuse_light'] = self._diffuse_light.rgba
|
|
541
|
+
self.fshader['specular_light'] = self._specular_light.rgba
|
|
542
|
+
|
|
543
|
+
self.fshader['ambient_coefficient'] = self._ambient_coefficient.rgba
|
|
544
|
+
self.fshader['diffuse_coefficient'] = self._diffuse_coefficient.rgba
|
|
545
|
+
self.fshader['specular_coefficient'] = self._specular_coefficient.rgba
|
|
546
|
+
self.fshader['shininess'] = self._shininess
|
|
547
|
+
|
|
548
|
+
self.fshader['flat_shading'] = 1 if self._shading == 'flat' else 0
|
|
549
|
+
self.fshader['shading_enabled'] = (
|
|
550
|
+
1 if self._enabled and self._shading is not None else 0
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
normals = self._visual.mesh_data.get_vertex_normals(indexed='faces')
|
|
554
|
+
if normals is not self._normals_cache:
|
|
555
|
+
# limit how often we upload new normal arrays
|
|
556
|
+
# gotcha: if normals are changed in place then this won't invalidate this cache
|
|
557
|
+
self._normals_cache = normals
|
|
558
|
+
self._normals.set_data(self._normals_cache, convert=True)
|
|
559
|
+
|
|
560
|
+
def on_mesh_data_updated(self, event):
|
|
561
|
+
self._update_data()
|
|
562
|
+
|
|
563
|
+
def _attach(self, visual):
|
|
564
|
+
super()._attach(visual)
|
|
565
|
+
|
|
566
|
+
render2scene = visual.transforms.get_transform('render', 'scene')
|
|
567
|
+
visual2scene = visual.transforms.get_transform('visual', 'scene')
|
|
568
|
+
scene2doc = visual.transforms.get_transform('scene', 'document')
|
|
569
|
+
doc2scene = visual.transforms.get_transform('document', 'scene')
|
|
570
|
+
self.vshader['render2scene'] = render2scene
|
|
571
|
+
self.vshader['visual2scene'] = visual2scene
|
|
572
|
+
self.vshader['scene2doc'] = scene2doc
|
|
573
|
+
self.vshader['doc2scene'] = doc2scene
|
|
574
|
+
|
|
575
|
+
if self._visual.mesh_data is not None:
|
|
576
|
+
self._update_data()
|
|
577
|
+
|
|
578
|
+
visual.events.data_updated.connect(self.on_mesh_data_updated)
|
|
579
|
+
|
|
580
|
+
def _detach(self, visual):
|
|
581
|
+
visual.events.data_updated.disconnect(self.on_mesh_data_updated)
|
|
582
|
+
super()._detach(visual)
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
instanced_shading_vertex_template = shading_vertex_template.replace(
|
|
586
|
+
"$normal",
|
|
587
|
+
"mat3($instance_transform_x, $instance_transform_y, $instance_transform_z) * $normal"
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
class InstancedShadingFilter(ShadingFilter):
|
|
592
|
+
"""Shading filter modified for use with :class:`~vispy.visuals.InstancedMeshVisual`.
|
|
593
|
+
|
|
594
|
+
See :class:`ShadingFilter` for details and usage.
|
|
595
|
+
"""
|
|
596
|
+
_shaders = {
|
|
597
|
+
'vertex': instanced_shading_vertex_template,
|
|
598
|
+
'fragment': ShadingFilter._shaders['fragment'],
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
def _attach(self, visual):
|
|
602
|
+
super()._attach(visual)
|
|
603
|
+
self.vshader['instance_transform_x'] = visual._instance_transforms_vbos[0]
|
|
604
|
+
self.vshader['instance_transform_y'] = visual._instance_transforms_vbos[1]
|
|
605
|
+
self.vshader['instance_transform_z'] = visual._instance_transforms_vbos[2]
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
wireframe_vertex_template = """
|
|
609
|
+
varying vec3 v_bc;
|
|
610
|
+
|
|
611
|
+
void prepare_wireframe() {
|
|
612
|
+
v_bc = $bc;
|
|
613
|
+
}
|
|
614
|
+
""" # noqa
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
wireframe_fragment_template = """
|
|
618
|
+
varying vec3 v_bc;
|
|
619
|
+
|
|
620
|
+
void draw_wireframe() {
|
|
621
|
+
if ($enabled != 1) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
vec3 d = fwidth(v_bc); // relative distance to edge
|
|
626
|
+
vec3 fading3 = smoothstep(vec3(0.0), $width * d, v_bc);
|
|
627
|
+
float opacity = 1.0 - min(min(fading3.x, fading3.y), fading3.z);
|
|
628
|
+
|
|
629
|
+
if ($wireframe_only == 1) {
|
|
630
|
+
if (opacity == 0.0) {
|
|
631
|
+
// Inside a triangle.
|
|
632
|
+
discard;
|
|
633
|
+
}
|
|
634
|
+
// On the edge.
|
|
635
|
+
gl_FragColor = $color;
|
|
636
|
+
gl_FragColor.a = opacity;
|
|
637
|
+
} else if ($faces_only == 1) {
|
|
638
|
+
if (opacity == 1.0) {
|
|
639
|
+
// Inside an edge.
|
|
640
|
+
discard;
|
|
641
|
+
}
|
|
642
|
+
// Inside a triangle.
|
|
643
|
+
gl_FragColor.a = 1.0 - opacity;
|
|
644
|
+
} else {
|
|
645
|
+
gl_FragColor = mix(gl_FragColor, $color, opacity);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
}
|
|
649
|
+
""" # noqa
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
class WireframeFilter(Filter):
|
|
653
|
+
"""Add wireframe to a mesh.
|
|
654
|
+
|
|
655
|
+
The wireframe filter should be attached before the shading filter for the
|
|
656
|
+
wireframe to be shaded.
|
|
657
|
+
|
|
658
|
+
Parameters
|
|
659
|
+
----------
|
|
660
|
+
color : str or tuple or Color
|
|
661
|
+
Line color of the wireframe
|
|
662
|
+
width : float
|
|
663
|
+
Line width of the wireframe
|
|
664
|
+
enabled : bool
|
|
665
|
+
Whether the wireframe is drawn or not
|
|
666
|
+
|
|
667
|
+
Examples
|
|
668
|
+
--------
|
|
669
|
+
See
|
|
670
|
+
`examples/basics/scene/mesh_shading.py
|
|
671
|
+
<https://github.com/vispy/vispy/blob/main/examples/basics/scene/mesh_shading.py>`_
|
|
672
|
+
example script.
|
|
673
|
+
|
|
674
|
+
"""
|
|
675
|
+
|
|
676
|
+
def __init__(self, enabled=True, color='black', width=1.0,
|
|
677
|
+
wireframe_only=False, faces_only=False):
|
|
678
|
+
self._attached = False
|
|
679
|
+
self._color = Color(color)
|
|
680
|
+
self._width = width
|
|
681
|
+
self._enabled = enabled
|
|
682
|
+
self._wireframe_only = wireframe_only
|
|
683
|
+
self._faces_only = faces_only
|
|
684
|
+
|
|
685
|
+
vfunc = Function(wireframe_vertex_template)
|
|
686
|
+
ffunc = Function(wireframe_fragment_template)
|
|
687
|
+
|
|
688
|
+
self._bc = VertexBuffer(np.zeros((0, 3), dtype=np.float32))
|
|
689
|
+
vfunc['bc'] = self._bc
|
|
690
|
+
|
|
691
|
+
super().__init__(vcode=vfunc, fcode=ffunc)
|
|
692
|
+
self.enabled = enabled
|
|
693
|
+
|
|
694
|
+
@property
|
|
695
|
+
def enabled(self):
|
|
696
|
+
"""True to enable the display of the wireframe, False to disable."""
|
|
697
|
+
return self._enabled
|
|
698
|
+
|
|
699
|
+
@enabled.setter
|
|
700
|
+
def enabled(self, enabled):
|
|
701
|
+
self._enabled = enabled
|
|
702
|
+
self.fshader['enabled'] = 1 if enabled else 0
|
|
703
|
+
self._update_data()
|
|
704
|
+
|
|
705
|
+
@property
|
|
706
|
+
def color(self):
|
|
707
|
+
"""The wireframe color."""
|
|
708
|
+
return self._color
|
|
709
|
+
|
|
710
|
+
@color.setter
|
|
711
|
+
def color(self, color):
|
|
712
|
+
self._color = Color(color)
|
|
713
|
+
self._update_data()
|
|
714
|
+
|
|
715
|
+
@property
|
|
716
|
+
def width(self):
|
|
717
|
+
"""The wireframe width."""
|
|
718
|
+
return self._width
|
|
719
|
+
|
|
720
|
+
@width.setter
|
|
721
|
+
def width(self, width):
|
|
722
|
+
if width < 0:
|
|
723
|
+
raise ValueError("width must be greater than zero")
|
|
724
|
+
self._width = width
|
|
725
|
+
self._update_data()
|
|
726
|
+
|
|
727
|
+
@property
|
|
728
|
+
def wireframe_only(self):
|
|
729
|
+
"""Draw only the wireframe and discard the interior of the faces."""
|
|
730
|
+
return self._wireframe_only
|
|
731
|
+
|
|
732
|
+
@wireframe_only.setter
|
|
733
|
+
def wireframe_only(self, wireframe_only):
|
|
734
|
+
self._wireframe_only = wireframe_only
|
|
735
|
+
self._update_data()
|
|
736
|
+
|
|
737
|
+
@property
|
|
738
|
+
def faces_only(self):
|
|
739
|
+
"""Make the wireframe transparent.
|
|
740
|
+
|
|
741
|
+
Draw only the interior of the faces.
|
|
742
|
+
"""
|
|
743
|
+
return self._faces_only
|
|
744
|
+
|
|
745
|
+
@faces_only.setter
|
|
746
|
+
def faces_only(self, faces_only):
|
|
747
|
+
self._faces_only = faces_only
|
|
748
|
+
self._update_data()
|
|
749
|
+
|
|
750
|
+
def _update_data(self):
|
|
751
|
+
if not self.attached:
|
|
752
|
+
return
|
|
753
|
+
self.fshader['color'] = self._color.rgba
|
|
754
|
+
self.fshader['width'] = self._width
|
|
755
|
+
self.fshader['wireframe_only'] = 1 if self._wireframe_only else 0
|
|
756
|
+
self.fshader['faces_only'] = 1 if self._faces_only else 0
|
|
757
|
+
if self._visual.mesh_data.is_empty():
|
|
758
|
+
n_faces = 0
|
|
759
|
+
else:
|
|
760
|
+
n_faces = len(self._visual.mesh_data.get_faces())
|
|
761
|
+
bc = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype='float')
|
|
762
|
+
bc = np.tile(bc[None, ...], (n_faces, 1, 1))
|
|
763
|
+
self._bc.set_data(bc, convert=True)
|
|
764
|
+
|
|
765
|
+
def on_data_updated(self, event):
|
|
766
|
+
self._update_data()
|
|
767
|
+
|
|
768
|
+
def _attach(self, visual):
|
|
769
|
+
super()._attach(visual)
|
|
770
|
+
visual.events.data_updated.connect(self.on_data_updated)
|
|
771
|
+
|
|
772
|
+
def _detach(self, visual):
|
|
773
|
+
visual.events.data_updated.disconnect(self.on_data_updated)
|
|
774
|
+
super()._detach(visual)
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
class FacePickingFilter(PrimitivePickingFilter):
|
|
778
|
+
"""Filter used to color mesh faces by a picking ID.
|
|
779
|
+
|
|
780
|
+
Note that the ID color uses the alpha channel, so this may not be used
|
|
781
|
+
with blending enabled.
|
|
782
|
+
|
|
783
|
+
Examples
|
|
784
|
+
--------
|
|
785
|
+
:ref:`sphx_glr_gallery_scene_face_picking.py`
|
|
786
|
+
"""
|
|
787
|
+
|
|
788
|
+
def _get_picking_ids(self):
|
|
789
|
+
if self._visual.mesh_data.is_empty():
|
|
790
|
+
n_faces = 0
|
|
791
|
+
else:
|
|
792
|
+
n_faces = len(self._visual.mesh_data.get_faces())
|
|
793
|
+
|
|
794
|
+
# we only care about the number of faces changing
|
|
795
|
+
if self._n_primitives == n_faces:
|
|
796
|
+
return None
|
|
797
|
+
self._n_primitives = n_faces
|
|
798
|
+
|
|
799
|
+
ids = np.arange(1, n_faces + 1, dtype=np.uint32)
|
|
800
|
+
ids = np.repeat(ids, 3, axis=0) # repeat id for each vertex
|
|
801
|
+
return ids
|