ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
greyscale.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// Create grey scale of `200 x 200` boxes.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Olivier Couet
9 
10 {
11  TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
12  c->SetBorderMode(0);
13 
14  Int_t n = 200; // tunable parameter
15  Float_t n1 = 1./n;
16  for (int i = 0; i < n; i++) {
17  for (int j = 0; j < n; j++) {
18  TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
19  Float_t grey = Float_t(i*n+j)/(n*n);
20  b->SetFillColor(TColor::GetColor(grey, grey, grey));
21  b->Draw();
22  }
23  }
24  TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
25  const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
26  p->SetFillColor(TColor::GetColor(guibackground));
27  p->Draw();
28  p->cd();
29  TText *t = new TText(0.5, 0.5, "GUI Background Color");
30  t->SetTextAlign(22);
31  t->SetTextSize(.09);
32  t->Draw();
33 
34  c->SetEditable(kFALSE);
35 }
float Float_t
Definition: RtypesCore.h:53
Create a Box.
Definition: TBox.h:44
virtual void SetBorderMode(Short_t bordermode)
Definition: TPad.h:316
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
Base class for several text objects.
Definition: TText.h:42
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1192
virtual void SetEditable(Bool_t mode=kTRUE)
Set pad editable yes/no If a pad is not editable:
Definition: TPad.cxx:5270
virtual void SetTextAlign(Short_t align=11)
Definition: TAttText.h:55
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
The most important graphics class in the ROOT system.
Definition: TPad.h:46
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:1023
The Canvas class.
Definition: TCanvas.h:48
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
virtual void Draw(Option_t *option="")
Draw this box with its current attributes.
Definition: TBox.cxx:176
virtual void SetTextSize(Float_t tsize=1)
Definition: TAttText.h:60
const Int_t n
Definition: legend1.C:16