How to populate vtkColorSeries with specific RGB values?

How to populate a vtkColorSeries with specific RGB values? I see method vtkColorSeries::SetColor(index, vtkColor3ub &) and examples that populate the series with vtkNamedColors, e.g. to set the 0th color in the series:

colorSeries->SetColor(0, colors->GetColor3ub("turquoise_blue"))

But how would I set the 0th color to R=0.00, G=1.00, B=0.94? How can I create a vtkColor3ub from just RGB values rather than named colors? Google search of “vtkColor3ub rgb” yields mostly references to vtkNamedColors…

Thanks
Tom

Hi,

This is an old topic, and I’m pretty sure you have already found the answer. But for other people with the same question, here is the solution:

vtkNew<vtkNamedColors> nc;
nc->SetColor("customColor", 1, 0.992, 0.815); // Just a random RGB color, I named it customColor

vtkNew<vtkColorSeries> colorsSeries;
colorsSeries->AddColor(nc->GetColor3ub("customColor"));
colorsSeries->AddColor(nc->GetColor3ub("turquoise_blue"));

Best,

Kaveh

1 Like