TColor -> Color_t

I have a TColor initialized with its RGB components. I want to draw a TBox with this color, but TBox::SetFillColor need a Color_t

You can use:

col->GetNumber()

it returns the color index of the TColor “col”.

[quote=“couet”]You can use:

col->GetNumber()

it returns the color index of the TColor “col”.[/quote]

TColor Color;
Color.SetRGB(1.,0,0)  //it's red
b = new TBox(0.2,0.2,0.8,0.3)
b->SetFillColor(Color.GetNumber()) //Color.GetNumber() is -1 !!!
b->Draw()

and the box is gray

try:

root [2] TColor *c=gROOT->GetColor(20);
root [3] c->SetRGB(1.,0,0);
root [4] b = new TBox(0.2,0.2,0.8,0.3);
root [5] b->SetFillColor(20)
root [6] b->Draw()