#include "ROOT/RCanvas.hxx" #include "ROOT/RText.hxx" #include "ROOT/RLine.hxx" #include using namespace ROOT::Experimental; void rstyle() { auto canvas = RCanvas::Create("Use RStyle for line styling"); double num = 0.3; for (int i = 10; i > 0; i--) { num = num + 0.05; auto text = canvas->Add(RPadPos{.3_normal, 1_normal * num}, std::to_string(i)); text->text.size = 0.04; text->text.align = RAttrText::kRightCenter; text->text.font = RAttrFont::kArialOblique; auto line = canvas->Add(RPadPos(.32_normal, 1_normal * num), RPadPos(.8_normal, 1_normal * num)); line->SetId(std::string("obj") + std::to_string(i)); line->SetCssClass(std::string("user_class_") + std::to_string(i % 3)); } auto style = std::make_shared(); style->AddBlock(".user_class_1").AddInt("line_style", 4); // all lines with user_class_1 should get style 1 style->AddBlock(".user_class_2").AddDouble("line_width", 5.); // all lines with user_class_2 should get line width 5 style->AddBlock("#obj7").AddString("line_color", "#0000FF"); // line with id obj7 should be blue style->AddBlock("line").AddString("line_color", "red"); // all lines should get red color canvas->UseStyle(style); canvas->Show(); // after leaving function scope style will be destroyed, one has to preserve it canvas->ClearOnClose(style); }