Correct usage of colors and fillings

ROOT Version: 6.26/06
Platform: Rocky Linux release 8.4
Compiler: gcc (GCC) 8.4.1

Hi,

in my code I’m using a TPolyLine which is filled with a color.

TPolyLine *line = new TPolyLine (5, x, y);

auto color = TColor::GetColor (kRGB[i].red, kRGB[i].green, kRGB[i].blue);
auto color_transparent = TColor::GetColorTransparent (color, kRGB[i].alpha);

line->SetFillColor (color_transparent);

Using this code I’m wondering, since both TColor::GetColor and TColor::GetColorTransparent returning a Int_t alias int and SetFillColor takes a Color_t alias short.

If the color index received by GetColor or GetColorTransparent passes the 16 Bit the short can take the index swaps into negative range and then again into positive range and so on.

Using a negative color index leads to problems with the fill color.

Can you confirm this or am I doing it wrong?

Bests,
Michael

Negative color indices are illegal.

Have you an example having such a problems ?
Usually color indices are “small numbers”. I never saw a such problem.
But in principle you are right.

If you have a reproducer showing it I am interested to try it.

Currently I don’t have an example but I will file one after the weekend.

The problem occurs in connection with “bug-getting-transparent-color” (my other issue) where many many objects are drawn with a transparent color. Because every transparent color gets a new color index this leads to high color indexes and therefore to an overflow at the short parameter.

Thank you for your support. Have a nice weekend.

As mentioned in the other thread, I was not able to reproduce this effect with the maco you sent me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.