Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
transp.C File Reference

Detailed Description

This demo shows how to use transparency.

On MacOS X you can see the transparency in a canvas, you can save canvas contents as pdf/png (and thus you'll have an image with transparency on every platform).

//Includes for ACLiC (cling does not need them).
#include "TCanvas.h"
#include "TColor.h"
#include "TError.h"
#include "TStyle.h"
#include "TH1F.h"
void transp(bool gl = true)
{
auto redIndex = TColor::GetColor((Float_t) 1., 0., 0., 0.85);
auto greeIndex = TColor::GetColor((Float_t) 0., 1., 0., 0.5);
auto cnv = new TCanvas("trasnparency", "transparency demo", 600, 400);
auto hist = new TH1F("a5", "b5", 10, -2., 3.);
auto hist2 = new TH1F("c6", "d6", 10, -3., 3.);
hist->FillRandom("landau", 100000);
hist2->FillRandom("gaus", 100000);
hist->SetFillColor(redIndex);
hist2->SetFillColor(greeIndex);
cnv->cd();
hist2->Draw();
hist->Draw("SAME");
}
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
The Canvas class.
Definition TCanvas.h:23
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1839
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition TStyle.h:339
Author
Timur Pocheptsov

Definition in file transp.C.