# Examples from pyvista.Texture
# =============================

# 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
texture = pv.Texture(path)
texture

# 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

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

