Confusing documentation on TColor

Hi everybody

I found the TColor documentation (root.cern.ch/root/html/TColor.html) to be rather confusing, at least the part about bright and dark colors.

For one thing, the lines

TColor *dark = TColor::GetColorDark(color_index); TColor *bright = TColor::GetColorBright(color_index);
won’t compile for, say, color_index = kRed. Then, the text suggests that I could use something like myBox->SetFillColor(kRed+100); to obtain the dark version of “kRed”. But that’s not the case. What really works for me is myBox->SetFillColor(TColor::GetColorDark(kRed));

I would update the documentation accordingly to spare other users the confusion.

Thanks,

Thomas

Thomas,

Why do you interpret a doc in a complex way when things are simple ? ::slight_smile:
Instead of

myBox->SetFillColor(TColor::GetColorDark(kRed)); simply do (as illustrated on the color wheel):

myBox->SetFillColor(kRed); or

myBox->SetFillColor(kRed+2); myBox->SetFillColor(kRed-3);
Rene

Hi Rene,

I believe you misunderstood. Let’s say I want a lighter shade of gray (kGray).

SetFillColor(TColor::GetColorBright(kGray)); does the job, but SetFillColor(kGray-1); does not. I can’t see a brighter gray anywhere on the color wheel!

See below for a full macro illustrating this.

Thanks, again,

Thomas

[code]{
gStyle->SetFrameBorderMode(0);
gStyle->SetCanvasBorderMode(0);
gStyle->SetPadBorderMode(0);
gStyle->SetPadColor(0);
gStyle->SetCanvasColor(0);

TCanvas* canv = new TCanvas(“canv”,“canv”,800, 600);
canv->DrawFrame(0.,0.,1.4,1.4);

TBox* boxDark = new TBox(0.2,0.2,0.6,0.4);
TBox* box = new TBox(0.2,0.6,0.6,0.8);
TBox* boxBright = new TBox(0.2,1.0,0.6,1.2);

box->SetFillColor(kGray);
boxBright->SetFillColor(TColor::GetColorBright(kGray));
boxDark->SetFillColor(TColor::GetColorDark(kGray));

box->Draw();
boxBright->Draw();
boxDark->Draw();

TBox* boxDark2 = new TBox(0.8,0.2,1.2,0.4);
TBox* box2 = new TBox(0.8,0.6,1.2,0.8);
TBox* boxBright2 = new TBox(0.8,1.0,1.2,1.2);

box2->SetFillColor(kGray);
boxBright2->SetFillColor(kGray-1); // gives a white box!
boxDark2->SetFillColor(kGray+1);

box2->Draw();
boxBright2->Draw();
boxDark2->Draw();

}[/code]