ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
transp.C
Go to the documentation of this file.
1 //This demo shows how to use transparency.
2 
3 //Includes for ACLiC (cling does not need them).
4 #include "TCanvas.h"
5 #include "TColor.h"
6 #include "TError.h"
7 #include "TStyle.h"
8 #include "TH1F.h"
9 
10 //Aux. functions for tutorials/gl.
11 #include "customcolorgl.h"
12 
13 void transp()
14 {
15  //1. Try to find free indices for our custom colors.
16  //We can use hard-coded indices like 1001, 1002, 1003, ... but
17  //I prefer to find free indices in a ROOT's color table
18  //to avoid possible conflicts with other tutorials.
19  Int_t indices[2] = {};
21  ::Error("transp", "failed to create new custom colors");
22  return;
23  }
24 
25  //2. Now that we have indices, create our custom colors.
26  const Int_t redIndex = indices[0], greeIndex = indices[1];
27 
28  new TColor(redIndex, 1., 0., 0., "red", 0.85);
29  new TColor(greeIndex, 0., 1., 0., "green", 0.5);
30 
32  TCanvas * const cnv = new TCanvas("trasnparency", "transparency demo", 600, 400);
33 
34  TH1F * const hist = new TH1F("a5", "b5", 10, -2., 3.);
35  TH1F * const hist2 = new TH1F("c6", "d6", 10, -3., 3.);
36  hist->FillRandom("landau", 100000);
37  hist2->FillRandom("gaus", 100000);
38 
39  hist->SetFillColor(redIndex);
40  hist2->SetFillColor(greeIndex);
41 
42  cnv->cd();
43  hist2->Draw();
44  hist->Draw("SAME");
45 }
unsigned FindFreeCustomColorIndices(T(&indices)[N])
Definition: customcolorgl.h:44
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
int Int_t
Definition: RtypesCore.h:41
void Error(const char *location, const char *msgfmt,...)
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:337
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH1.cxx:3330
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
The Canvas class.
Definition: TCanvas.h:48
The color creation and management class.
Definition: TColor.h:47
const Bool_t kTRUE
Definition: Rtypes.h:91
void transp()
Definition: transp.C:17