Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 1.19 KB

factory.texture.rst

File metadata and controls

60 lines (40 loc) · 1.19 KB

texture

.. autofunction:: k3d.factory.texture

Examples

Basic

:download:`arcade_carpet_512.png <./assets/factory/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()
.. k3d_plot ::
  :filename: plots/factory/texture_basic_plot.py

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()
.. k3d_plot ::
  :filename: plots/factory/texture_colormap_plot.py