histo->SetFillColorAlpha(kBlue, 0.35);
The transparency is available on all platforms when the flagOpenGL.CanvasPreferGL is set to 1 in $ROOTSYS/etc/system.rootrc, or on Mac with the Cocoa backend. On the file output it is visible with PDF, PNG, Gif, JPEG, SVG ... but not PostScript.
Using this color set for your text, background or graphics will give your application a consistent appearance across different platforms and browsers.
Colors are grouped by hue, the aspect most important in human perception Touching color chips have the same hue, but with different brightness and vividness.
Colors of slightly different hues clash. If you intend to display colors of the same hue together, you should pick them from the same group.
Each color chip is identified by a mnemonic (eg kYellow) and a number. The keywords, kRed, kBlue, kYellow, kPink, etc are defined in the header file Rtypes.h that is included in all ROOT other header files. We strongly recommend to use these keywords in your code instead of hardcoded color numbers, eg:
myObject.SetFillColor(kRed); myObject.SetFillColor(kYellow-10); myLine.SetLineColor(kMagenta+2);
{ TColorWheel *w = new TColorWheel(); w->Draw(); return w->GetCanvas(); }
pattern_number = ijk (FillStyle = 3ijk) i (1-9) : specify the space between each hatch 1 = 1/2mm 9 = 6mm j (0-9) : specify angle between 0 and 90 degrees 0 = 0 1 = 10 2 = 20 3 = 30 4 = 45 5 = Not drawn 6 = 60 7 = 70 8 = 80 9 = 90 k (0-9) : specify angle between 90 and 180 degrees 0 = 180 1 = 170 2 = 160 3 = 150 4 = 135 5 = Not drawn 6 = 120 7 = 110 8 = 100 9 = 90The following table shows the list of pattern styles. The first table displays the 25 fixed patterns. They cannot be customized unlike the hatches displayed in the second table which be customized using:
TCanvas * fillpatterns() { // Fill patterns example. This macro shows the available fill patterns. // The first table displays the 25 fixed patterns. They cannot be // customized unlike the hatches displayed in the second table which be // cutomized using: // - gStyle->SetHatchesSpacing() to define the spacing between hatches. SetHatchesLineWidth() to define the hatches line width. TCanvas *Pat = new TCanvas("Fill Patterns", "",0,0,500,700); Pat->Range(0,0,1,1); Pat->SetBorderSize(2); Pat->SetFrameFillColor(0); Double_t bh = 0.059; Double_t db = 0.01; Double_t y = 0.995; Int_t i,j=3001; for (i=1; i<=5; i++) { box(j++, 0.01, y-bh, 0.19, y); box(j++, 0.21, y-bh, 0.39, y); box(j++, 0.41, y-bh, 0.59, y); box(j++, 0.61, y-bh, 0.79, y); box(j++, 0.81, y-bh, 0.99, y); y = y-bh-db; } y = y-3*db; gStyle->SetHatchesSpacing(2.0); gStyle->SetHatchesLineWidth(1); Int_t j1 = 3144; Int_t j2 = 3305; Int_t j3 = 3350; Int_t j4 = 3490; Int_t j5 = 3609; for (i=1; i<=9; i++) { if (i==6) {j2 += 10; j3 += 1; j4 += 1; j5 += 10;} if (i==5) {j4 -= 10; j5 -= 1;} box(j1, 0.01, y-bh, 0.19, y); box(j2, 0.21, y-bh, 0.39, y); box(j3, 0.41, y-bh, 0.59, y); box(j4, 0.61, y-bh, 0.79, y); box(j5, 0.81, y-bh, 0.99, y); j1 += 100; j2 += 10; j3 += 1; j4 -= 9; j5 += 9; y = y-bh-db; } return Pat; } box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2) { "pat" with the "pat" value TBox b; b.SetFillColor(1); b.SetFillStyle(pat); b.DrawBox(x1,y1,x2,y2); b.SetFillStyle(0) ; b.DrawBox(x1,y1,x2,y2); b.SetFillColor(0) ; b.SetFillStyle(1000) ; Double_t dx = (x2-x1)/3; Double_t dy = (y2-y1)/3; Double_t h = (y2-y1)/2.5; b.DrawBox(x1+dx, y1+dy, x2-dx, y2-dy); b.SetFillStyle(0); b.DrawBox(x1+dx, y1+dy, x2-dx, y2-dy); TLatex l; l.SetTextAlign(22); l.SetTextSize(h); l.DrawLatex((x1+x2)/2, (y1+y2)/2, Form("%d",pat)); }
TAttFill() | |
TAttFill(const TAttFill&) | |
TAttFill(Color_t fcolor, Style_t fstyle) | |
virtual | ~TAttFill() |
static TClass* | Class() |
void | Copy(TAttFill& attfill) const |
virtual Color_t | GetFillColor() const |
virtual Style_t | GetFillStyle() const |
virtual TClass* | IsA() const |
virtual Bool_t | IsTransparent() const |
virtual void | Modify() |
TAttFill& | operator=(const TAttFill&) |
virtual void | ResetAttFill(Option_t* option = "") |
virtual void | SaveFillAttributes(ostream& out, const char* name, Int_t coldef = 1, Int_t stydef = 1001) |
virtual void | SetFillAttributes()MENU |
virtual void | SetFillColor(Color_t fcolor) |
virtual void | SetFillColorAlpha(Color_t fcolor, Float_t falpha) |
virtual void | SetFillStyle(Style_t fstyle) |
virtual void | ShowMembers(TMemberInspector&) |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
AttFill normal constructor. color Fill Color style Fill Style
Save fill attributes as C++ statement(s) on output stream out
Set a transparent fill color. falpha defines the percentage of the color opacity from 0. (fully transparent) to 1. (fully opaque).