Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rbox.py
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## Run macro with python3 -i box.py command to get interactive canvas
8##
9## \macro_image (rcanvas_js)
10## \macro_code
11##
12## \date 2021-06-15
13## \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
14## is welcome!
15## \author Sergey Linev
16
17import ROOT
18from ROOT.Experimental import RCanvas, RBox, RPadPos, RColor, RAttrFill, RAttrLine
19
20# Create a canvas to be displayed.
21canvas = RCanvas.Create("RBox drawing")
22
23box1 = canvas.Draw[RBox](RPadPos(0.1, 0.1), RPadPos(0.3, 0.6))
24box1.border.color = RColor.kBlue
25box1.border.width = 5
26box1.fill.color = RColor(0, 255, 0, 127) # 50% opaque
27box1.fill.style = RAttrFill.kSolid
28
29box2 = canvas.Draw[RBox](RPadPos(0.4, 0.2), RPadPos(0.6, 0.7))
30box2.border.color = RColor.kRed
31box2.border.width = 10
32box2.border.style = RAttrLine.kDashed
33box2.fill.color = RColor(0, 0, 255, 179) # 70% opaque
34box2.fill.style = RAttrFill.kSolid
35
36box3 = canvas.Draw[RBox](RPadPos(0.7, 0.4), RPadPos(0.9, 0.6))
37box3.border.width = 3
38box3.fill.color = RColor.kBlue
39box3.fill.style = RAttrFill.kSolid
40
41box4 = canvas.Draw[RBox](RPadPos(0.7, 0.7), RPadPos(0.9, 0.9))
42box4.border.width = 4
43
44box5 = canvas.Draw[RBox](RPadPos(0.7, 0.1), RPadPos(0.9, 0.3))
45box5.border.rx = 10
46box5.border.ry = 10
47box5.border.width = 2
48
49canvas.Show()