ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
rline.cxx
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_rcanvas
3
///
4
/// This ROOT 7 example demonstrates how to create a ROOT 7 canvas (RCanvas) and
5
/// draw ROOT 7 lines in it (RLine). It generates a set of lines using the
6
/// "normal" coordinates' system and changing the line color linearly from black
7
/// to red.
8
///
9
/// \macro_code
10
///
11
/// \date 2018-03-18
12
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
13
/// is welcome!
14
/// \authors Olivier Couet, Iliana Betsou
15
16
#include <
ROOT/RCanvas.hxx
>
17
#include <
ROOT/RColor.hxx
>
18
#include <ROOT/RLine.hxx>
19
#include <
ROOT/RPadPos.hxx
>
20
#include "
TMath.h
"
21
22
void
rline
()
23
{
24
using namespace
ROOT::Experimental
;
25
26
// Create a canvas to be displayed.
27
auto
canvas = RCanvas::Create(
"RLine example"
);
28
29
for
(
double
i = 0; i < 360; i+=1) {
30
double
angle
= i *
TMath::Pi
() / 180;
31
RColor
col( 50 + (
int
) i/360*200, 0, 0);
32
auto
draw
= canvas->Draw<
RLine
>();
33
draw
->SetP1({0.5
_normal
, 0.5
_normal
});
34
draw
->SetP2({0.5
_normal
+ 0.3
_normal
*
TMath::Cos
(
angle
), 0.5
_normal
+ 0.3
_normal
*
TMath::Sin
(
angle
)});
35
draw
->line.color = col;
36
}
37
38
canvas->Draw<
RLine
>()->
SetP1
({0.0
_normal
, 0.0
_normal
}).
SetP2
({1.0
_normal
,1.0
_normal
});
39
canvas->Draw<
RLine
>()->
SetP1
({0.1
_normal
, 0.1
_normal
}).
SetP2
({0.9
_normal
,0.1
_normal
});
40
canvas->Draw<
RLine
>()->
SetP1
({0.9
_normal
, 0.1
_normal
}).
SetP2
({0.9
_normal
,0.9
_normal
});
41
canvas->Draw<
RLine
>()->
SetP1
({0.9
_normal
, 0.9
_normal
}).
SetP2
({0.1
_normal
,0.9
_normal
});
42
canvas->Draw<
RLine
>()->
SetP1
({0.1
_normal
, 0.1
_normal
}).
SetP2
({0.1
_normal
,0.9
_normal
});
43
canvas->Draw<
RLine
>()->
SetP1
({0.0
_normal
, 1.0
_normal
}).
SetP2
({1.0
_normal
,0.0
_normal
});
44
45
canvas->SetSize(900, 700);
46
47
if
(canvas->SaveAs(
"line.png"
))
48
printf
(
"Store RCanvas in line.png\n"
);
49
50
canvas->Show();
51
}
RCanvas.hxx
RColor.hxx
RPadPos.hxx
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
angle
Option_t Option_t TPoint TPoint angle
Definition
TGWin32VirtualXProxy.cxx:68
TMath.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
ROOT::Experimental::RColor
The color class.
Definition
RColor.hxx:33
ROOT::Experimental
Definition
RDirectory.hxx:30
TMath::Cos
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition
TMath.h:594
TMath::Pi
constexpr Double_t Pi()
Definition
TMath.h:37
TMath::Sin
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition
TMath.h:588
tutorials
rcanvas
rline.cxx
ROOT v6-32 - Reference Guide Generated on Sat Jan 25 2025 14:33:51 (GVA Time) using Doxygen 1.10.0