File: fpvwritetest.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (185 lines) | stat: -rw-r--r-- 5,986 bytes parent folder | download | duplicates (7)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{
FPVectorial example application for writing vectorial images
generated in code to disk. This program will generate the following
vectorial images:

single_line_1    One line from (0, 20) to (30, 30)
single_line_2    One line from (20, 30) to (30, 20)
polyline_1       One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
polyline_2       One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
bezier_1         One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
bezier_2         One curve from (10, 10) to (20, 20)
text_ascii       One text written at (10, 10)
text_europen     One text testing european languages at (20, 20)
text_asian       One text testing asian languages at (30, 30)

Author: Felipe Monteiro de Carvalho

License: Public Domain
}
program fpvwritetest;

{$mode objfpc}{$H+}

uses
  fpvectorial, svgvectorialwriter, fpvutils, fpvectorialpkg;

const
  cFormat = vfSVG;
  cExtension = '.svg';
var
  Vec: TvVectorialDocument;
  Page: TvVectorialPage;
begin
  Vec := TvVectorialDocument.Create;
  try
    // All documents are 10cm x 10cm
    Vec.Width := 100;
    Vec.Height := 100;
    Page := Vec.AddPage();

    // single_line_1    One line from (0, 20) to (30, 30)
    Page.StartPath(0, 20);
    Page.AddLineToPath(30, 30);
    Page.EndPath();
    Vec.WriteToFile('single_line_1' + cExtension, cFormat);

    // single_line_2    One line from (20, 30) to (30, 20)
    Page.Clear;
    Page.StartPath(20, 30);
    Page.AddLineToPath(30, 20);
    Page.EndPath();
    Vec.WriteToFile('single_line_2' + cExtension, cFormat);

    // single_line_3    One line from (0, 20) to (30, 30) + frame
    Page.Clear;
    Page.StartPath(0, 20);
    Page.AddLineToPath(30, 30);
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(100, 0);
    Page.AddLineToPath(100, 100);
    Page.AddLineToPath(0, 100);
    Page.AddLineToPath(0, 0);
    Page.EndPath();
    Vec.WriteToFile('single_line_3' + cExtension, cFormat);

    // polyline_1       One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
    Page.Clear;
    Page.StartPath(0, 0);
    Page.AddLineToPath(10, 10);
    Page.AddLineToPath(20, 30);
    Page.AddLineToPath(30, 20);
    Page.EndPath();
    Vec.WriteToFile('polyline_1' + cExtension, cFormat);

    //    polyline_2       One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
    Page.Clear;
    Page.StartPath(10, 10);
    Page.AddLineToPath(20, 30);
    Page.AddLineToPath(30, 20);
    Page.AddLineToPath(40, 40);
    Page.EndPath();
    Vec.WriteToFile('polyline_2' + cExtension, cFormat);

    // bezier_1         One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
    Page.Clear;
    Page.StartPath(0, 0);
    Page.AddLineToPath(10, 10);
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
    Page.AddLineToPath(30, 0);
    Page.EndPath();
    Vec.WriteToFile('bezier_1' + cExtension, cFormat);

    // bezier_2         One curve from (10, 10) to (20, 20)
    Page.Clear;
    Page.StartPath(10, 10);
    Page.AddBezierToPath(10, 15, 15, 20, 20, 10);
    Page.EndPath();
    Vec.WriteToFile('bezier_2' + cExtension, cFormat);

    // text_ascii       One text written at (10, 10)
    Page.Clear;
    Page.AddText(10, 10, 0, '10,10 Some text in english.');
    Vec.WriteToFile('text_ascii' + cExtension, cFormat);

    // text_europen     One text testing european languages at (20, 20)
    Page.Clear;
    Page.AddText(20, 20, 0, '20, 20 Mówić, cześć, Włosku, Parabéns, Assunção, Correções.');
    Vec.WriteToFile('text_europen' + cExtension, cFormat);

    // text_asian       One text testing asian languages at (30, 30)
    Page.Clear;
    Page.AddText(30, 30, 0, '30, 30 森林,是一个高密度树木的区域');
    Vec.WriteToFile('text_asian' + cExtension, cFormat);

    // multi_test_1     Combines various elements
    Page.Clear;
    Page.StartPath(0, 20);
    Page.AddLineToPath(30, 30);
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(100, 0);
    Page.AddLineToPath(100, 100);
    Page.AddLineToPath(0, 100);
    Page.AddLineToPath(0, 0);
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(10, 10);
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
    Page.AddLineToPath(30, 0);
    Page.EndPath();
    Page.AddText(10, 10, 0, '10,10 Some text in english.');
    Page.AddText(20, 20, 0, '20, 20 Mówić, cześć, Włosku, Parabéns.');
    Page.AddText(30, 30, 0, '30, 30 森林,是一个高密');
    Vec.WriteToFile('multi_test_1' + cExtension, cFormat);

    // pen_test_1     Tests the properties of the Pen
    Page.Clear;
    Page.StartPath(0, 20);
    Page.AddLineToPath(30, 30);
    Page.SetPenWidth(10);
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(100, 0);
    Page.AddLineToPath(100, 100);
    Page.AddLineToPath(0, 100);
    Page.AddLineToPath(0, 0);
    Page.SetPenWidth(10);
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(10, 10);
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
    Page.AddLineToPath(30, 0);
    Page.SetPenWidth(10);
    Page.EndPath();
    Vec.WriteToFile('pen_test_1' + cExtension, cFormat);

    // pen_test_2     Tests the properties of the Pen
    Page.Clear;
    Page.StartPath(0, 20);
    Page.AddLineToPath(30, 30);
    Page.SetPenWidth(10);
    Page.SetPenColor(RGBToFPColor(255, 0, 0));
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(100, 0);
    Page.AddLineToPath(100, 100);
    Page.AddLineToPath(0, 100);
    Page.AddLineToPath(0, 0);
    Page.SetPenWidth(10);
    Page.SetPenColor(RGBToFPColor(0, 255, 0));
    Page.EndPath();
    Page.StartPath(0, 0);
    Page.AddLineToPath(10, 10);
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
    Page.AddLineToPath(30, 0);
    Page.SetPenWidth(10);
    Page.SetPenColor(RGBToFPColor(0, 0, 255));
    Page.EndPath();
    Vec.WriteToFile('pen_test_2' + cExtension, cFormat);
  finally
    Vec.Free;
  end;
end.