Skip to content

Color Quantities

Visualize color rgb-valued data at the elements of a surface mesh.

Example: visualizing random colors at faces

#include "polyscope/surface_mesh.h"

// Make some random colors
std::vector<std::array<double, 3>> fColor(nFaces);
for (size_t iF = 0; iF < nFaces; iF++) {
  std::vector<size_t>& face = faceIndices[iF];
  fColor[iF] = {{polyscope::randomUnit(), polyscope::randomUnit(), polyscope::randomUnit()}};
}

// Visualize
polyscope::getSurfaceMesh("name")->addFaceColorQuantity("fColor", fColor);

Add colors to elements

SurfaceMesh::addVertexColorQuantity(std::string name, const T& values)

Add a color quantity defined at the vertices of the mesh.

  • values is the array of colors at vertices. The type should be adaptable to a 3-vector array of floats. The length should be the number of vertices in the mesh.

RGB values are interpreted in the range [0,1].

SurfaceMesh::addFaceColorQuantity(std::string name, const T& values)

Add a color quantity defined at the faces of the mesh.

  • values is the array of colors at faces. The type should be adaptable to a 3-vector array of floats. The length should be the number of faces in the mesh.

RGB values are interpreted in the range [0,1].

Options

Parameter Meaning Getter Setter Persistent?
enabled is the quantity enabled? bool isEnabled() setEnabled(bool newVal) yes

(all setters return this to support chaining. setEnabled() returns generic quantity, so chain it last)