ultimatepp/benchmarks/PainterBenchmark/TextOnPath.cpp
cxl c4d0d63aab .benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@14485 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-05-20 14:39:17 +00:00

22 lines
555 B
C++

#include "LionBenchmark.h"
void TextOnPath(Painter& sw)
{
Font fnt = Roman(100);
FontInfo fi = fnt.Info();
double pos = 0;
const char *s = "Hello world, this is text on path!";
int l = GetTextSize(s, fnt).cx;
double r = l / (2 * M_PI);
sw.Circle(300, 300, r).Stroke(1, Red());
while(*s) {
double w = fi[*s];
sw.BeginOnPath(pos + w / 2, true);
sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt)
.Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue())
.Stroke(1, Black());
sw.End();
pos += w;
}
}