ROOT
master
Reference Guide
Loading...
Searching...
No Matches
greyscale.C File Reference
Tutorials
»
Visualisation tutorials
»
Graphics tutorials
Detailed Description
Create grey scale of 200x200 boxes.
void
greyscale
()
{
TCanvas
*
c
=
new
TCanvas
(
"grey"
,
"Grey Scale"
, 500, 500);
c
->SetBorderMode(0);
Int_t
n
= 200;
// tunable parameter
Float_t
n1
= 1. /
n
;
for
(
int
i = 0; i <
n
; i++) {
for
(
int
j
= 0;
j
<
n
;
j
++) {
TBox
*
b
=
new
TBox
(
n1
*
j
,
n1
* (
n
- 1 - i),
n1
* (
j
+ 1),
n1
* (
n
- i));
Float_t
grey
=
Float_t
(i *
n
+
j
) / (
n
*
n
);
b
->SetFillColor(
TColor::GetColor
(
grey
,
grey
,
grey
));
b
->Draw();
}
}
TPad
*
p
=
new
TPad
(
"p"
,
"p"
, 0.3, 0.3, 0.7, 0.7);
const
char
*
guibackground
=
gEnv
->
GetValue
(
"Gui.BackgroundColor"
,
""
);
p
->SetFillColor(
TColor::GetColor
(
guibackground
));
p
->Draw();
p
->cd();
TText
*t =
new
TText
(0.5, 0.5,
"GUI Background Color"
);
t->
SetTextAlign
(22);
t->
SetTextSize
(.09);
t->
Draw
();
c
->SetEditable(
kFALSE
);
}
b
#define b(i)
Definition
RSha256.hxx:100
c
#define c(i)
Definition
RSha256.hxx:101
Int_t
int Int_t
Definition
RtypesCore.h:45
Float_t
float Float_t
Definition
RtypesCore.h:57
kFALSE
constexpr Bool_t kFALSE
Definition
RtypesCore.h:94
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
gEnv
R__EXTERN TEnv * gEnv
Definition
TEnv.h:170
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TAttText::SetTextAlign
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition
TAttText.h:44
TAttText::SetTextSize
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition
TAttText.h:49
TBox
Create a Box.
Definition
TBox.h:22
TCanvas
The Canvas class.
Definition
TCanvas.h:23
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:1927
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition
TEnv.cxx:491
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition
TObject.cxx:293
TPad
The most important graphics class in the ROOT system.
Definition
TPad.h:28
TText
Base class for several text objects.
Definition
TText.h:22
n
const Int_t n
Definition
legend1.C:16
Author
Olivier Couet
Definition in file
greyscale.C
.
tutorials
visualisation
graphics
greyscale.C
ROOT master - Reference Guide Generated on Sat Apr 26 2025 15:41:17 (GVA Time) using Doxygen 1.10.0