1 #include "Examples.h"
2
OnPath(Painter & sw)3 void OnPath(Painter& sw)
4 {
5 sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue());
6 for(int i = -1; i <= 16; i++) {
7 sw.BeginOnPath(i / 15.0);
8 sw.Move(0, -6).Line(6, 0).Line(0, 6).Close().Stroke(1, Black());
9 sw.End();
10 }
11 }
12
OnTextPath(Painter & sw)13 void OnTextPath(Painter& sw)
14 {
15 sw.Text(50, 50, "Hello!", Roman(350)).Stroke(1, Black());
16 for(int i = 0; i <= 100; i++) {
17 sw.BeginOnPath(i / 100.0);
18 sw.Move(0, -6).Line(6, 0).Line(0, 6).Fill(Red());
19 sw.End();
20 }
21 }
22
OnPathBee(Painter & sw)23 void OnPathBee(Painter& sw)
24 {
25 sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue());
26 for(int i = -1; i <= 16; i++) {
27 sw.BeginOnPath(i / 15.0);
28 sw.DrawImage(0, -TestImg::Bee().GetHeight() / 2, TestImg::Bee());
29 sw.End();
30 }
31 }
32
TextOnPath(Painter & sw)33 void TextOnPath(Painter& sw)
34 {
35 Font fnt = Roman(100);
36 FontInfo fi = fnt.Info();
37 double pos = 0;
38 const char *s = "Hello world, this is text on path!";
39 int l = GetTextSize(s, fnt).cx;
40 double r = l / (2 * M_PI);
41 sw.Circle(300, 300, r).Stroke(1, Red());
42 while(*s) {
43 double w = fi[*s];
44 sw.BeginOnPath(pos + w / 2, true);
45 sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt)
46 .Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue())
47 .Stroke(1, Black());
48 sw.End();
49 pos += w;
50 }
51 }
52
53 INITBLOCK {
54 RegisterExample("OnPath", OnPath);
55 RegisterExample("OnTextPath", OnTextPath);
56 RegisterExample("OnPathBee", OnPathBee);
57 RegisterExample("TextOnPath", TextOnPath);
58 }
59