Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rbox.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 boxes in it (RBox). It generates a set of boxes using the
6/// "normal" coordinates' system.
7///
8/// \macro_image (rcanvas_js)
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
21void rbox()
22{
23 using namespace ROOT::Experimental;
24
25 // Create a canvas to be displayed.
26 auto canvas = RCanvas::Create("RBox drawing");
27
28 auto box1 = canvas->Draw<RBox>(RPadPos(0.1_normal, 0.3_normal), RPadPos(0.3_normal,0.6_normal));
29 box1->border.color = RColor::kBlue;
30 box1->border.width = 5;
31 box1->fill.color = RColor(0, 255, 0, 127); // 50% opaque
32 box1->fill.style = RAttrFill::kSolid;
33
34 auto box2 = canvas->Draw<RBox>(RPadPos(0.4_normal, 0.2_normal), RPadPos(0.6_normal,0.7_normal));
35 box2->border.color = RColor::kRed;
36 box2->border.width = 10.f;
37 box2->border.style = RAttrLine::kDashed;
38 box2->fill.color = RColor(0, 0, 255, 179); // 70% opaque
39 box2->fill.style = RAttrFill::kSolid;
40
41 auto box3 = canvas->Draw<RBox>(RPadPos(0.7_normal, 0.4_normal), RPadPos(0.9_normal,0.6_normal));
42 box3->border.width = 3;
43 box3->fill.color = RColor::kBlue;
44 box3->fill.style = RAttrFill::kSolid;
45
46 auto box4 = canvas->Draw<RBox>(RPadPos(0.7_normal, 0.7_normal), RPadPos(0.9_normal,0.9_normal));
47 box4->border.width = 4;
48
49 auto box5 = canvas->Draw<RBox>(RPadPos(0.7_normal, 0.1_normal), RPadPos(0.9_normal,0.3_normal));
50 box5->border.rx = 10;
51 box5->border.ry = 10;
52 box5->border.width = 2;
53
54 canvas->Show();
55}
The color class.
Definition RColor.hxx:33
A position (horizontal and vertical) in a RPad.
Definition RPadPos.hxx:28
Definition rbox.py:1