Alpha Channel in TColor Objects

Hello,

I’ve been trying to read through the class references in the hopes that I could find a way to use (partially) transparent colors in my plots. Looking at this constructor:

in ‘TColor.cxx’ I found the lines:

// fill color structure SetRGB(r, g, b); fAlpha = a;

which made me assume that ‘a’ was a floating point value representing an alpha channel going from 0 to 1. I did a little test as follows:

[code]TH1F * h_tall_gaus = new TH1F(“h_tall_gaus”, “”, 20, -2, 2)
TH1F * h_shortl_gaus = new TH1F(“h_short_gaus”, “”, 20, -2, 2)

h_tall_gaus->FillRandom(“gaus”, 1000)
h_short_gaus->FillRandom(“gaus”, 500)

TColor * tc_blue = new TColor(1001, 0, 0, 1, “”, .25)
TColor * tc_red = new TColor(1002, 1, 0, 0, “”, .25)

h_tall_gaus->SetFillColor(1001)
h_short_gaus->SetFillColor(1002)

h_tall_gaus->Draw()
h_short_gaus->Draw(“same”)[/code]

which resulted in what I would have expected if I had set the alpha channels to 1 instead of .25 (this also happens if I set them to 0).

Am I missing something here? I tried gStyle->SetCanvasPreferGL(1) hoping that that might make a difference, but unfortunately not.

Olivier will process this mail once he will be back next week.

Rene

The transparency is not available for color in that context. As explained here : root.cern.ch/root/html/TAttFill.html#F2 the transparency is for TPad only.
In the case of simple colors like in your example, alpha is not used.

Is this something that would be very difficult to implement? I think that it would be a great improvement as far as making “pretty” figures and I would be more than willing to contribute code.

You are very welcome ! :slight_smile: