Skip to content

Commit a8fcd4b

Browse files
committed
Example showing how to use RBox
1 parent 673551b commit a8fcd4b

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

tutorials/v7/box.cxx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/// \file
2+
/// \ingroup tutorial_v7
3+
///
4+
/// This ROOT 7 example demonstrates how to create a ROOT 7 canvas (RCanvas) and
5+
/// draw ROOT 7 boxes in it (RBox). It generates a set of boxes using the
6+
/// "normal" coordinates' system.
7+
///
8+
/// \macro_image
9+
/// \macro_code
10+
///
11+
/// \date 2018-10-10
12+
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
13+
/// is welcome!
14+
/// \author Olivier couet
15+
16+
#include "ROOT/RCanvas.hxx"
17+
#include "ROOT/RColor.hxx"
18+
#include "ROOT/RBox.hxx"
19+
#include <ROOT/RPadPos.hxx>
20+
#include "TMath.h"
21+
22+
void box()
23+
{
24+
using namespace ROOT::Experimental;
25+
26+
// Create a canvas to be displayed.
27+
auto canvas = RCanvas::Create("Canvas Title");
28+
29+
auto OptsBox1 = canvas->Draw(RBox({0.1_normal, 0.3_normal}, {0.3_normal,0.6_normal}));
30+
RColor Color1(1., 0., 0.);
31+
RColor Color2(0., 0., 1.);
32+
33+
OptsBox1->SetLineColor(Color1);
34+
OptsBox1->SetLineWidth(5);
35+
OptsBox1->SetLineColorAlpha(.5);
36+
OptsBox1->SetFillColor(Color2);
37+
OptsBox1->SetFillColorAlpha(.3);
38+
39+
auto OptsBox2 = canvas->Draw(RBox({0.4_normal, 0.2_normal}, {0.6_normal,0.7_normal}));
40+
OptsBox2->SetLineColor(Color2);
41+
OptsBox2->SetFillStyle(0);
42+
OptsBox2->SetLineStyle(2);
43+
OptsBox2->SetLineWidth(3);
44+
45+
auto OptsBox3 = canvas->Draw(RBox({0.7_normal, 0.4_normal}, {0.9_normal,0.6_normal}));
46+
OptsBox3->SetFillStyle(0);
47+
OptsBox3->SetRoundWidth(50);
48+
OptsBox3->SetRoundHeight(50);
49+
OptsBox3->SetLineWidth(3);
50+
51+
auto OptsBox4 = canvas->Draw(RBox({0.7_normal, 0.7_normal}, {0.9_normal,0.9_normal}));
52+
OptsBox4->SetFillStyle(0);
53+
OptsBox4->SetRoundWidth(50);
54+
OptsBox4->SetRoundHeight(25);
55+
OptsBox4->SetLineWidth(3);
56+
57+
auto OptsBox5 = canvas->Draw(RBox({0.7_normal, 0.1_normal}, {0.9_normal,0.3_normal}));
58+
OptsBox5->SetFillStyle(0);
59+
OptsBox5->SetRoundWidth(25);
60+
OptsBox5->SetRoundHeight(50);
61+
OptsBox5->SetLineWidth(3);
62+
63+
canvas->Show();
64+
}

0 commit comments

Comments
 (0)