pyvista.Texture.wrap

Contents

pyvista.Texture.wrap#

property Texture.wrap: WrapType[source]#

Return or set the Wrap mode for the texture coordinates.

Wrap mode for the texture coordinates valid values are:

  • 0 - CLAMP_TO_EDGE

  • 1 - REPEAT

  • 2 - MIRRORED_REPEAT

  • 3 - CLAMP_TO_BORDER

Notes

CLAMP_TO_BORDER is not supported with OpenGL ES <= 3.2. Wrap will default to CLAMP_TO_EDGE if it is set to CLAMP_TO_BORDER in this case.

Requires vtk v9.1.0 or newer.

Examples

Load the masonry texture and create a simple pyvista.PolyData with texture coordinates using pyvista.Plane(). By default the texture coordinates are between 0 and 1. Let’s raise these values over 1 by multiplying them in place. This will allow us to wrap the texture.

>>> import pyvista as pv
>>> from pyvista import examples
>>> texture = examples.download_masonry_texture()
>>> plane = pv.Plane()
>>> plane.active_texture_coordinates *= 2

Let’s now set the texture wrap to clamp to edge and visualize it.

>>> texture.wrap = pv.Texture.WrapType.CLAMP_TO_EDGE
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(plane, texture=texture)
>>> pl.camera.zoom('tight')
>>> pl.show()
../../../_images/pyvista-Texture-wrap-1_00_00.png

Here is the default repeat:

>>> texture.wrap = pv.Texture.WrapType.REPEAT
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(plane, texture=texture)
>>> pl.camera.zoom('tight')
>>> pl.show()
../../../_images/pyvista-Texture-wrap-1_01_00.png

And here is mirrored repeat:

>>> texture.wrap = pv.Texture.WrapType.MIRRORED_REPEAT
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(plane, texture=texture)
>>> pl.camera.zoom('tight')
>>> pl.show()
../../../_images/pyvista-Texture-wrap-1_02_00.png

Finally, this is clamp to border:

>>> texture.wrap = pv.Texture.WrapType.CLAMP_TO_BORDER
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(plane, texture=texture)
>>> pl.camera.zoom('tight')
>>> pl.show()
../../../_images/pyvista-Texture-wrap-1_03_00.png