color_mesh_cells1.py 688 B

12345678910111213141516171819202122
  1. """Colorize faces of a Mesh by passing
  2. a 1-to-1 list of colors and transparencies"""
  3. from vedo import *
  4. # Enable depth peeling for better rendering of transparent objects
  5. settings.use_depth_peeling = True
  6. # Generate a torus and assign a linewidth of 1
  7. tor = Torus(res=9).linewidth(1)
  8. # Generate an array of random RGBA color values for each cell of the mesh
  9. rgba = np.random.rand(tor.ncells, 4)*255
  10. tor.cellcolors = rgba
  11. # Print information about the cell arrays of the mesh and their shape
  12. printc(
  13. 'Mesh cell arrays:', tor.celldata.keys(),
  14. 'shape:', tor.celldata['CellsRGBA'].shape,
  15. )
  16. # Display the mesh with the assigned colors and the docstring
  17. show(tor, __doc__).close()