[vtk-developers] Manual conversion of some Tcl to Python tests.

David Thompson david.thompson at kitware.com
Fri Aug 31 10:31:16 EDT 2012


Hi Andrew,

> ...  it would be nice to have in VTK 6 a class of colors and
> their names.
> What do people think of creating a class called say vtkNamedColors
> where the underlying structure would be a std::map<std::string,
> std::vector> with this map prefilled with the colours defined in
> colors.py or colors.tcl?

I like it but would like to add a twist.

> There would be only two functions e.g GetColor(std::string) returning
> a std::vector and SetColor(std::string, std::vector) - this function
> would allow the user to add new colours.

How about

  GetColor( std::string palette, int swatch = 0 )

so that a name could refer to a single color name (ignoring the swatch argument) or to an entire palette?

The storage could be the same... a std::map<std::string,std::vector<double> > could have any length that was a multiple of 4 (RGBA) and the ( swatch % (length/4) ) would be used to get the offset into the vector of the first color.

That would let us include the Brewer color palettes and others as well.

	David




More information about the vtk-developers mailing list