Drawing primitives inside and outside of the frame.
In normal ROOT graphics all objects drawn on the pad and therefore requires special treatment to be able drawn only inside frame borders. In web-based graphics objects automatically clipped by frame border - if drawn inside frame. Macro demonstrates usage of "frame" draw option for TLine, TBox, TMarker and TLatex classes. If user interactively change zooming range "in-frame" objects automatically clipped.
Functionality available only in web-based graphics
void inframe()
{
auto c1 =
new TCanvas(
"c1",
"Drawing inside frame", 1200, 800);
if (!
gROOT->IsBatch() && !
c1->IsWeb())
::Warning(
"inframe.cxx",
"macro may not work without enabling web-based canvas");
c1->DrawFrame(0., 0., 10., 10.,
"Usage of \"frame\" draw options");
auto latex =
new TLatex(3., 8.,
"Text in the frame");
latex->SetTextColor(
kCyan);
latex->SetTextSize(0.08);
latex->SetTextAlign(22);
auto l1 =
new TLine(-0.5, 5, 10.5, 5);
auto tl1 =
new TLatex(0.5, 5,
"line outside");
tl1->SetTextColor(
kBlue);
tl1->SetTextAlign(13);
auto l2 =
new TLine(-0.5, 5.2, 10.5, 5.2);
auto tl2 =
new TLatex(0.5, 5.3,
"line inside");
tl2->SetTextAlign(11);
auto b1 =
new TBox(-0.5, 1, 4, 3);
auto tb1 =
new TLatex(0.5, 3.1,
"box outside");
tb1->SetTextColor(
kBlue);
tb1->SetTextAlign(11);
auto b2 =
new TBox(6, 1, 10.5, 3);
auto b2_dash =
new TBox(6, 1, 10.5, 3);
b2_dash->SetFillStyle(0);
b2_dash->SetLineColor(
kRed);
b2_dash->SetLineStyle(3);
b2_dash->SetLineWidth(3);
auto tb2 =
new TLatex(6.5, 3.1,
"box inside");
tb2->SetTextAlign(11);
auto m1 =
new TMarker(9.5, 7., 29);
m1->SetMarkerColor(
kBlue);
m1->SetMarkerSize(3);
auto tm1 =
new TLatex(9.3, 7.,
"outside");
tm1->SetTextColor(
kBlue);
tm1->SetTextAlign(32);
auto m2 =
new TMarker(9.5, 8., 34);
m2->SetMarkerSize(3);
auto tm2 =
new TLatex(9.3, 8.,
"inside");
tm2->SetTextAlign(32);
}
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
To draw Mathematical Formula.
Use the TLine constructor to create a simple line.
- Author
- Sergey Linev
Definition in file inframe.cxx.