pyvista.Texture#
- class Texture(*args, **kwargs)[source]#
Wrap vtkTexture.
Textures can be used to apply images to surfaces, as in the case of Applying Textures.
They can also be used for environment textures to affect the lighting of the scene, or even as a environment cubemap as in the case of Physically Based Rendering and 3D Earth and Celestial Bodies.
- Parameters:
- uinput
str
,vtkImageData
,vtkTexture
, sequence[pyvista.ImageData
],optional
Filename,
vtkImageData
,vtkTexture
,numpy.ndarray
or a sequence of images to create a cubemap. If a sequence of images, must be of the same size and in the following order:+X
-X
+Y
-Y
+Z
-Z
- **kwargs
dict
,optional
Optional arguments when reading from a file. Generally unused.
- uinput
Examples
Load a texture from file. File should be a “image” or “image-like” file.
>>> from pathlib import Path >>> import pyvista as pv >>> from pyvista import examples >>> path = examples.download_masonry_texture(load=False) >>> Path(path).name 'masonry.bmp' >>> texture = pv.Texture(path) >>> texture Texture (...) Components: 3 Cube Map: False Dimensions: 256, 256
Create a texture from an RGB array. Note how this is colored per “point” rather than per “pixel”.
>>> import numpy as np >>> arr = np.array( ... [ ... [255, 255, 255], ... [255, 0, 0], ... [0, 255, 0], ... [0, 0, 255], ... ], ... dtype=np.uint8, ... ) >>> arr = arr.reshape((2, 2, 3)) >>> texture = pv.Texture(arr) >>> texture.plot()
Create a cubemap from 6 images.
>>> px = examples.download_sky(direction='posx') >>> nx = examples.download_sky(direction='negx') >>> py = examples.download_sky(direction='posy') >>> ny = examples.download_sky(direction='negy') >>> pz = examples.download_sky(direction='posz') >>> nz = examples.download_sky(direction='negz') >>> texture = pv.Texture([px, nx, py, ny, pz, nz]) >>> texture.cube_map True
Methods
Make a copy of this texture.
Flip the texture in the x direction.
Flip the texture in the y direction.
Texture.plot
(**kwargs)Plot the texture as an image.
Rotate this texture 90 degrees counter-clockwise.
Rotate this texture 90 degrees clockwise.
Return the texture as an array.
Convert this texture as a single component (grayscale) texture.
Return the texture as an image.
Return the texture as a
vtkSkybox
if cube mapping is enabled.Attributes
Return
True
if cube mapping is enabled andFalse
otherwise.Dimensions of the texture.
Return if interpolate is enabled or disabled.
Return if mipmap is enabled or disabled.
Return the number of components in the image.
Repeat the texture.
Return or set the Wrap mode for the texture coordinates.