-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
57 lines (41 loc) · 1.48 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace example;
// example-0013
// text multilines
class Program
{
static void Main(string[] args)
{
const float TEXT_HEIGHT = 1f;
InitAvalonia();
var w = GLWindow.Create();
w.GLModel.BuildModel = (glCtl, isInitial) =>
{
if (!isInitial) return;
var glModel = glCtl.GLModel;
glModel.Clear();
glModel.AddFigure(MakeWCSFigure());
void addText(Vector3 insPt, string text, GLTextVHAlignment alignment)
{
glModel.AddFigure(new GLPointFigure(new GLPoint(new GLVertex(insPt, Color.Cyan))) { PointSize = 10 });
var figs = glModel.MakeTextFigure(new GLText(WCS.Move(insPt), text)
{
Height = TEXT_HEIGHT,
Alignment = alignment,
SpacingBetweenLines = 1
});
glModel.AddFigure(figs);
var figBBox = new BBox(figs.Select(fig => fig.OBBox))
.MakeFigure(Color.Yellow);
glModel.AddFigure(figBBox);
}
// multiline text can have newlines
addText(
insPt: new Vector3(10, 4, 0),
text: "Sample text\nOn newline\n\nAbove is empty line\nend line",
alignment: GLTextVHAlignment.TopCenter);
glCtl.Perspective = false;
glCtl.CameraView(CameraViewType.Top);
};
w.ShowSync();
}
}