Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
greyscale.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// \notebook
4 /// Create grey scale of `200 x 200` boxes.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Olivier Couet
10 
11 void greyscale()
12 {
13  TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
14  c->SetBorderMode(0);
15 
16  Int_t n = 200; // tunable parameter
17  Float_t n1 = 1./n;
18  for (int i = 0; i < n; i++) {
19  for (int j = 0; j < n; j++) {
20  TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
21  Float_t grey = Float_t(i*n+j)/(n*n);
22  b->SetFillColor(TColor::GetColor(grey, grey, grey));
23  b->Draw();
24  }
25  }
26  TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
27  const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
28  p->SetFillColor(TColor::GetColor(guibackground));
29  p->Draw();
30  p->cd();
31  TText *t = new TText(0.5, 0.5, "GUI Background Color");
32  t->SetTextAlign(22);
33  t->SetTextSize(.09);
34  t->Draw();
35 
36  c->SetEditable(kFALSE);
37 }