This macro demonstrate the text align attribute for RText.
#include "ROOT/RText.hxx"
#include "ROOT/RBox.hxx"
void rtext_align()
{
auto canvas = RCanvas::Create("RText align example");
auto box = canvas->Add<RBox>(
RPadPos(0.1_normal, 0.1_normal),
RPadPos(0.9_normal, 0.9_normal));
box->border.style = RAttrLine::kStyle6;
auto drawText = [&canvas](
double x,
double y,
RAttrText::EAlign align,
const std::string &lbl) {
dbox->fill.color = RColor::kRed;
dbox->fill.style = RAttrFill::kSolid;
text->text.align = align;
};
drawText(0.1, 0.9, RAttrText::kLeftTop, "kLeftTop");
drawText(0.1, 0.5, RAttrText::kLeftCenter, "kLeftCenter");
drawText(0.1, 0.1, RAttrText::kLeftBottom, "kLeftBottom");
drawText(0.9, 0.9, RAttrText::kRightTop, "kRightTop");
drawText(0.9, 0.5, RAttrText::kRightCenter, "kRightCenter");
drawText(0.9, 0.1, RAttrText::kRightBottom, "kRightBottom");
drawText(0.5, 0.5, RAttrText::kCenter, "kCenter");
drawText(0.5, 0.9, RAttrText::kCenterTop, "kCenterTop");
drawText(0.5, 0.1, RAttrText::kCenterBottom, "kCenterBottom");
canvas->Show();
}
Option_t Option_t TPoint TPoint const char text
A position (horizontal and vertical) in a RPad.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)