ROOT
6.08/02
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
hist
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
}
Float_t
float Float_t
Definition:
RtypesCore.h:53
c
return c
Definition:
entrylist_figure1.C:47
TBox
Create a Box.
Definition:
TBox.h:36
TPad::SetBorderMode
virtual void SetBorderMode(Short_t bordermode)
Definition:
TPad.h:308
Int_t
int Int_t
Definition:
RtypesCore.h:41
kFALSE
const Bool_t kFALSE
Definition:
Rtypes.h:92
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition:
TObject.cxx:255
TPad::cd
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition:
TPad.cxx:526
TText
Base class for several text objects.
Definition:
TText.h:33
TPad::Draw
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition:
TPad.cxx:1208
TPad::SetEditable
virtual void SetEditable(Bool_t mode=kTRUE)
Set pad editable yes/no If a pad is not editable:
Definition:
TPad.cxx:5302
TAttText::SetTextAlign
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition:
TAttText.h:47
TAttFill::SetFillColor
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition:
TAttFill.h:42
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition:
TEnv.cxx:482
TPad
The most important graphics class in the ROOT system.
Definition:
TPad.h:37
TColor::GetColor
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:1706
TCanvas
The Canvas class.
Definition:
TCanvas.h:41
gEnv
R__EXTERN TEnv * gEnv
Definition:
TEnv.h:174
TBox::Draw
virtual void Draw(Option_t *option="")
Draw this box with its current attributes.
Definition:
TBox.cxx:180
b
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition:
TRolke.cxx:630
TAttText::SetTextSize
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition:
TAttText.h:52
n
const Int_t n
Definition:
legend1.C:16