This ROOT 7 example demonstrates how to create a ROOT 7 canvas (RCanvas) and draw ROOT 7 lines in it (RLine).
It generates a set of lines using the "normal" coordinates' system and changing the line color linearly from black to red.
#include <ROOT/RLine.hxx>
void rline()
{
auto canvas = RCanvas::Create("RLine example");
for (double i = 0; i < 360; i+=1) {
RColor col( 50 + (
int) i/360*200, 0, 0);
auto draw = canvas->Draw<RLine>();
draw->SetP1({0.5_normal, 0.5_normal});
draw->SetP2({0.5_normal + 0.3_normal*
TMath::Cos(angle), 0.5_normal + 0.3_normal*
TMath::Sin(angle)});
draw->line.color = col;
}
canvas->Draw<RLine>()->SetP1({0.0_normal, 0.0_normal}).SetP2({1.0_normal,1.0_normal});
canvas->Draw<RLine>()->SetP1({0.1_normal, 0.1_normal}).SetP2({0.9_normal,0.1_normal});
canvas->Draw<RLine>()->SetP1({0.9_normal, 0.1_normal}).SetP2({0.9_normal,0.9_normal});
canvas->Draw<RLine>()->SetP1({0.9_normal, 0.9_normal}).SetP2({0.1_normal,0.9_normal});
canvas->Draw<RLine>()->SetP1({0.1_normal, 0.1_normal}).SetP2({0.1_normal,0.9_normal});
canvas->Draw<RLine>()->SetP1({0.0_normal, 1.0_normal}).SetP2({1.0_normal,0.0_normal});
canvas->SetSize(900, 700);
canvas->SaveAs("line.png");
canvas->Show();
}
- Date
- 2018-03-18
- Warning
- This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
- Authors
- Olivier Couet, Iliana Betsou
Definition in file rline.cxx.