~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/fpvectorial/examples/fpvwritetest.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
FPVectorial example application for writing vectorial images
 
3
generated in code to disk. This program will generate the following
 
4
vectorial images:
 
5
 
 
6
single_line_1    One line from (0, 20) to (30, 30)
 
7
single_line_2    One line from (20, 30) to (30, 20)
 
8
polyline_1       One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
 
9
polyline_2       One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
 
10
bezier_1         One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
 
11
bezier_2         One curve from (10, 10) to (20, 20)
 
12
text_ascii       One text written at (10, 10)
 
13
text_europen     One text testing european languages at (20, 20)
 
14
text_asian       One text testing asian languages at (30, 30)
 
15
 
 
16
Author: Felipe Monteiro de Carvalho
 
17
 
 
18
License: Public Domain
 
19
}
 
20
program fpvwritetest;
 
21
 
 
22
{$mode objfpc}{$H+}
 
23
 
 
24
uses
 
25
  fpvectorial, svgvectorialwriter, fpvutils, fpvectorialpkg;
 
26
 
 
27
const
 
28
  cFormat = vfSVG;
 
29
  cExtension = '.svg';
 
30
var
 
31
  Vec: TvVectorialDocument;
 
32
  Page: TvVectorialPage;
 
33
begin
 
34
  Vec := TvVectorialDocument.Create;
 
35
  try
 
36
    // All documents are 10cm x 10cm
 
37
    Vec.Width := 100;
 
38
    Vec.Height := 100;
 
39
    Page := Vec.AddPage();
 
40
 
 
41
    // single_line_1    One line from (0, 20) to (30, 30)
 
42
    Page.StartPath(0, 20);
 
43
    Page.AddLineToPath(30, 30);
 
44
    Page.EndPath();
 
45
    Vec.WriteToFile('single_line_1' + cExtension, cFormat);
 
46
 
 
47
    // single_line_2    One line from (20, 30) to (30, 20)
 
48
    Page.Clear;
 
49
    Page.StartPath(20, 30);
 
50
    Page.AddLineToPath(30, 20);
 
51
    Page.EndPath();
 
52
    Vec.WriteToFile('single_line_2' + cExtension, cFormat);
 
53
 
 
54
    // single_line_3    One line from (0, 20) to (30, 30) + frame
 
55
    Page.Clear;
 
56
    Page.StartPath(0, 20);
 
57
    Page.AddLineToPath(30, 30);
 
58
    Page.EndPath();
 
59
    Page.StartPath(0, 0);
 
60
    Page.AddLineToPath(100, 0);
 
61
    Page.AddLineToPath(100, 100);
 
62
    Page.AddLineToPath(0, 100);
 
63
    Page.AddLineToPath(0, 0);
 
64
    Page.EndPath();
 
65
    Vec.WriteToFile('single_line_3' + cExtension, cFormat);
 
66
 
 
67
    // polyline_1       One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
 
68
    Page.Clear;
 
69
    Page.StartPath(0, 0);
 
70
    Page.AddLineToPath(10, 10);
 
71
    Page.AddLineToPath(20, 30);
 
72
    Page.AddLineToPath(30, 20);
 
73
    Page.EndPath();
 
74
    Vec.WriteToFile('polyline_1' + cExtension, cFormat);
 
75
 
 
76
    //    polyline_2       One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
 
77
    Page.Clear;
 
78
    Page.StartPath(10, 10);
 
79
    Page.AddLineToPath(20, 30);
 
80
    Page.AddLineToPath(30, 20);
 
81
    Page.AddLineToPath(40, 40);
 
82
    Page.EndPath();
 
83
    Vec.WriteToFile('polyline_2' + cExtension, cFormat);
 
84
 
 
85
    // bezier_1         One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
 
86
    Page.Clear;
 
87
    Page.StartPath(0, 0);
 
88
    Page.AddLineToPath(10, 10);
 
89
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
 
90
    Page.AddLineToPath(30, 0);
 
91
    Page.EndPath();
 
92
    Vec.WriteToFile('bezier_1' + cExtension, cFormat);
 
93
 
 
94
    // bezier_2         One curve from (10, 10) to (20, 20)
 
95
    Page.Clear;
 
96
    Page.StartPath(10, 10);
 
97
    Page.AddBezierToPath(10, 15, 15, 20, 20, 10);
 
98
    Page.EndPath();
 
99
    Vec.WriteToFile('bezier_2' + cExtension, cFormat);
 
100
 
 
101
    // text_ascii       One text written at (10, 10)
 
102
    Page.Clear;
 
103
    Page.AddText(10, 10, 0, '10,10 Some text in english.');
 
104
    Vec.WriteToFile('text_ascii' + cExtension, cFormat);
 
105
 
 
106
    // text_europen     One text testing european languages at (20, 20)
 
107
    Page.Clear;
 
108
    Page.AddText(20, 20, 0, '20, 20 Mówić, cześć, Włosku, Parabéns, Assunção, Correções.');
 
109
    Vec.WriteToFile('text_europen' + cExtension, cFormat);
 
110
 
 
111
    // text_asian       One text testing asian languages at (30, 30)
 
112
    Page.Clear;
 
113
    Page.AddText(30, 30, 0, '30, 30 森林,是一个高密度树木的区域');
 
114
    Vec.WriteToFile('text_asian' + cExtension, cFormat);
 
115
 
 
116
    // multi_test_1     Combines various elements
 
117
    Page.Clear;
 
118
    Page.StartPath(0, 20);
 
119
    Page.AddLineToPath(30, 30);
 
120
    Page.EndPath();
 
121
    Page.StartPath(0, 0);
 
122
    Page.AddLineToPath(100, 0);
 
123
    Page.AddLineToPath(100, 100);
 
124
    Page.AddLineToPath(0, 100);
 
125
    Page.AddLineToPath(0, 0);
 
126
    Page.EndPath();
 
127
    Page.StartPath(0, 0);
 
128
    Page.AddLineToPath(10, 10);
 
129
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
 
130
    Page.AddLineToPath(30, 0);
 
131
    Page.EndPath();
 
132
    Page.AddText(10, 10, 0, '10,10 Some text in english.');
 
133
    Page.AddText(20, 20, 0, '20, 20 Mówić, cześć, Włosku, Parabéns.');
 
134
    Page.AddText(30, 30, 0, '30, 30 森林,是一个高密');
 
135
    Vec.WriteToFile('multi_test_1' + cExtension, cFormat);
 
136
 
 
137
    // pen_test_1     Tests the properties of the Pen
 
138
    Page.Clear;
 
139
    Page.StartPath(0, 20);
 
140
    Page.AddLineToPath(30, 30);
 
141
    Page.SetPenWidth(10);
 
142
    Page.EndPath();
 
143
    Page.StartPath(0, 0);
 
144
    Page.AddLineToPath(100, 0);
 
145
    Page.AddLineToPath(100, 100);
 
146
    Page.AddLineToPath(0, 100);
 
147
    Page.AddLineToPath(0, 0);
 
148
    Page.SetPenWidth(10);
 
149
    Page.EndPath();
 
150
    Page.StartPath(0, 0);
 
151
    Page.AddLineToPath(10, 10);
 
152
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
 
153
    Page.AddLineToPath(30, 0);
 
154
    Page.SetPenWidth(10);
 
155
    Page.EndPath();
 
156
    Vec.WriteToFile('pen_test_1' + cExtension, cFormat);
 
157
 
 
158
    // pen_test_2     Tests the properties of the Pen
 
159
    Page.Clear;
 
160
    Page.StartPath(0, 20);
 
161
    Page.AddLineToPath(30, 30);
 
162
    Page.SetPenWidth(10);
 
163
    Page.SetPenColor(RGBToFPColor(255, 0, 0));
 
164
    Page.EndPath();
 
165
    Page.StartPath(0, 0);
 
166
    Page.AddLineToPath(100, 0);
 
167
    Page.AddLineToPath(100, 100);
 
168
    Page.AddLineToPath(0, 100);
 
169
    Page.AddLineToPath(0, 0);
 
170
    Page.SetPenWidth(10);
 
171
    Page.SetPenColor(RGBToFPColor(0, 255, 0));
 
172
    Page.EndPath();
 
173
    Page.StartPath(0, 0);
 
174
    Page.AddLineToPath(10, 10);
 
175
    Page.AddBezierToPath(10, 20, 20, 20, 20, 10);
 
176
    Page.AddLineToPath(30, 0);
 
177
    Page.SetPenWidth(10);
 
178
    Page.SetPenColor(RGBToFPColor(0, 0, 255));
 
179
    Page.EndPath();
 
180
    Vec.WriteToFile('pen_test_2' + cExtension, cFormat);
 
181
  finally
 
182
    Vec.Free;
 
183
  end;
 
184
end.
 
185