texture#

k3d.factory.texture(binary: bytes | None = None, file_format: str | None = None, color_map: List[List[float]] | Dict[str, Any] | ndarray | None = None, color_range: List[float] = None, attribute: List | ndarray | Tuple = None, puv: List | ndarray | Tuple = None, opacity_function: List[float] = None, interpolation: bool = True, name: str | None = None, group: str | None = None, custom_data: Dict[str, Any] | None = None, compression_level: int = 0, **kwargs: Any) Texture[source]#

Examples#

Basic#

arcade_carpet_512.png

# Texture from https://opengameart.org/content/arcade-carpet-textures-arcadecarpet512png

import k3d

with open('arcade_carpet_512.png', 'rb') as texture:
    data = texture.read()

plt_texture = k3d.texture(data,
                          file_format='png')

plot = k3d.plot()
plot += plt_texture
plot.display()

Colormap#

Attention

color_map must be used along with attribute and color_range in order to work correctly.

import k3d
import numpy as np
from k3d.colormaps import matplotlib_color_maps

t = np.linspace(0, 1, 100)

plt_texture = k3d.texture(color_map=matplotlib_color_maps.Jet,
                          attribute=t,
                          color_range=[0.15, 0.85])

plot = k3d.plot()
plot += plt_texture
plot.display()