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

« back to all changes in this revision

Viewing changes to components/aggpas/lion_outline.dpr

  • 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
 
// AggPas 2.4 RM3 Demo application
3
 
// Note: Press F1 key on run to see more info about this demo
4
 
//
5
 
// Paths: src;src\ctrl;src\svg;src\util;src\platform\win;expat-wrap
6
 
//
7
 
program
8
 
 lion_outline ;
9
 
 
10
 
{DEFINE AGG_GRAY8 }
11
 
{$DEFINE AGG_BGR24 }
12
 
{DEFINE AGG_RGB24 }
13
 
{DEFINE AGG_BGRA32 }
14
 
{DEFINE AGG_RGBA32 }
15
 
{DEFINE AGG_ARGB32 }
16
 
{DEFINE AGG_ABGR32 }
17
 
{DEFINE AGG_RGB565 }
18
 
{DEFINE AGG_RGB555 }
19
 
 
20
 
uses
21
 
 Math ,
22
 
 
23
 
 agg_basics ,
24
 
 agg_platform_support ,
25
 
 
26
 
 agg_ctrl ,
27
 
 agg_slider_ctrl ,
28
 
 agg_cbox_ctrl ,
29
 
 
30
 
 agg_rasterizer_scanline_aa ,
31
 
 agg_rasterizer_outline_aa ,
32
 
 agg_scanline ,
33
 
 agg_scanline_p ,
34
 
 
35
 
 agg_renderer_base ,
36
 
 agg_renderer_scanline ,
37
 
 agg_renderer_outline_aa ,
38
 
 agg_render_scanlines ,
39
 
 
40
 
 agg_path_storage ,
41
 
 agg_bounding_rect ,
42
 
 agg_trans_affine ,
43
 
 agg_conv_stroke ,
44
 
 agg_conv_transform ,
45
 
 agg_vertex_source ,
46
 
 parse_lion_
47
 
 
48
 
{$I pixel_formats.inc }
49
 
{$I agg_mode.inc }
50
 
 
51
 
const
52
 
 flip_y = true;
53
 
 
54
 
var
55
 
 g_rasterizer : rasterizer_scanline_aa;
56
 
 g_scanline   : scanline_p8;
57
 
 
58
 
 g_path     : path_storage;
59
 
 g_colors   : array[0..99 ] of aggclr;
60
 
 g_path_idx : array[0..99 ] of unsigned;
61
 
 
62
 
 g_npaths : unsigned;
63
 
 
64
 
 g_x1 ,g_y1 ,g_x2 ,g_y2 ,
65
 
 g_base_dx  ,g_base_dy  ,
66
 
 g_angle    ,g_scale    ,
67
 
 g_skew_x   ,g_skew_y   : double;
68
 
 
69
 
 g_nclick : int;
70
 
 
71
 
type
72
 
 the_application = object(platform_support )
73
 
   m_width_slider : slider_ctrl;
74
 
   m_scanline     : cbox_ctrl;
75
 
 
76
 
   constructor Construct(format_ : pix_format_e; flip_y_ : boolean );
77
 
   destructor  Destruct;
78
 
 
79
 
   procedure on_draw; virtual;
80
 
 
81
 
   procedure transform(width_ ,height_ ,x ,y : double );
82
 
 
83
 
   procedure on_mouse_move       (x ,y : int; flags : unsigned ); virtual;
84
 
   procedure on_mouse_button_down(x ,y : int; flags : unsigned ); virtual;
85
 
 
86
 
   procedure on_key(x ,y : int; key ,flags : unsigned ); virtual;
87
 
 
88
 
  end;
89
 
 
90
 
{ _PARSE_LION_ }
91
 
procedure _parse_lion_;
92
 
begin
93
 
 g_npaths:=parse_lion(@g_path ,@g_colors ,@g_path_idx );
94
 
 
95
 
 bounding_rect(@g_path ,@g_path_idx ,0 ,g_npaths ,@g_x1 ,@g_y1 ,@g_x2 ,@g_y2 );
96
 
 
97
 
 g_base_dx:=(g_x2 - g_x1 ) / 2.0;
98
 
 g_base_dy:=(g_y2 - g_y1 ) / 2.0;
99
 
 
100
 
end;
101
 
 
102
 
{ CONSTRUCT }
103
 
constructor the_application.Construct;
104
 
begin
105
 
 inherited Construct(format_ ,flip_y_ );
106
 
 
107
 
 m_width_slider.Construct(5   ,5 ,150 ,12 ,not flip_y_ );
108
 
 m_scanline.Construct    (160 ,5 ,'Use Scanline Rasterizer' ,not flip_y_ );
109
 
 
110
 
 _parse_lion_;
111
 
 
112
 
 add_ctrl(@m_width_slider );
113
 
 
114
 
 m_width_slider.no_transform;
115
 
 m_width_slider.range_(0.0 ,4.0 );
116
 
 m_width_slider.value_(1.0 );
117
 
 m_width_slider.label_('Width %3.2f' );
118
 
 
119
 
 add_ctrl(@m_scanline );
120
 
 
121
 
 m_scanline.no_transform;
122
 
 
123
 
end;
124
 
 
125
 
{ DESTRUCT }
126
 
destructor the_application.Destruct;
127
 
begin
128
 
 inherited Destruct;
129
 
 
130
 
 m_width_slider.Destruct;
131
 
 m_scanline.Destruct;
132
 
 
133
 
end;
134
 
 
135
 
{ ON_DRAW }
136
 
procedure the_application.on_draw;
137
 
var
138
 
 width_ ,height_ : int;
139
 
 
140
 
 w : double;
141
 
 
142
 
 pixf : pixel_formats;
143
 
 
144
 
 rb : renderer_base;
145
 
 r  : renderer_scanline_aa_solid;
146
 
 
147
 
 rgba : aggclr;
148
 
 
149
 
 mtx : trans_affine;
150
 
 tat : trans_affine_translation;
151
 
 tas : trans_affine_scaling;
152
 
 tar : trans_affine_rotation;
153
 
 taw : trans_affine_skewing;
154
 
 
155
 
 stroke : conv_stroke;
156
 
 trans  : conv_transform;
157
 
 
158
 
 gm_no   : vertex_source;
159
 
 profile : line_profile_aa;
160
 
 
161
 
 ren : renderer_outline_aa;
162
 
 ras : rasterizer_outline_aa;
163
 
 
164
 
begin
165
 
 width_ :=rbuf_window._width;
166
 
 height_:=rbuf_window._height;
167
 
 
168
 
// Initialize structures
169
 
 pixfmt(pixf ,rbuf_window );
170
 
 
171
 
 rb.Construct(@pixf );
172
 
 r.Construct (@rb );
173
 
 
174
 
 rgba.ConstrDbl(1 ,1 ,1 );
175
 
 rb.clear      (@rgba );
176
 
 
177
 
// Transform lion
178
 
 mtx.Construct;
179
 
 
180
 
 tat.Construct(-g_base_dx ,-g_base_dy );
181
 
 mtx.multiply (@tat );
182
 
 
183
 
 tas.Construct(g_scale ,g_scale );
184
 
 mtx.multiply (@tas );
185
 
 
186
 
 tar.Construct(g_angle + pi );
187
 
 mtx.multiply (@tar );
188
 
 
189
 
 taw.Construct(g_skew_x / 1000.0 ,g_skew_y / 1000.0 );
190
 
 mtx.multiply (@taw );
191
 
 
192
 
 tat.Construct(width_ / 2 ,height_ / 2 );
193
 
 mtx.multiply (@tat );
194
 
 
195
 
// Render lion
196
 
 if m_scanline._status then
197
 
  begin
198
 
   stroke.Construct(@g_path );
199
 
   stroke.width_   (m_width_slider._value );
200
 
   trans.Construct (@stroke ,@mtx );
201
 
 
202
 
   render_all_paths(@g_rasterizer ,@g_scanline ,@r ,@trans ,@g_colors ,@g_path_idx ,g_npaths );
203
 
 
204
 
   stroke.Destruct;
205
 
 
206
 
  end
207
 
 else
208
 
  begin
209
 
   w:=m_width_slider._value * mtx.scale;
210
 
 
211
 
   gm_no.Construct;
212
 
   profile.Construct(w ,@gm_no );
213
 
 
214
 
   ren.Construct  (@rb ,@profile );
215
 
   ras.Construct  (@ren );
216
 
   trans.Construct(@g_path ,@mtx );
217
 
 
218
 
   ras.render_all_paths(@trans ,@g_colors ,@g_path_idx ,g_npaths );
219
 
 
220
 
   profile.Destruct;
221
 
   ras.Destruct;
222
 
 
223
 
  end;
224
 
 
225
 
// Render the control
226
 
 render_ctrl(@g_rasterizer ,@g_scanline ,@r ,@m_width_slider );
227
 
 render_ctrl(@g_rasterizer ,@g_scanline ,@r ,@m_scanline );
228
 
 
229
 
end;
230
 
 
231
 
{ TRANSFORM }
232
 
procedure the_application.transform;
233
 
begin
234
 
 x:=x - (width_ / 2 );
235
 
 y:=y - (height_ / 2 );
236
 
 
237
 
 g_angle:=ArcTan2(y ,x );
238
 
 g_scale:=Sqrt   (y * y + x * x ) / 100.0;
239
 
 
240
 
end;
241
 
 
242
 
{ ON_MOUSE_MOVE }
243
 
procedure the_application.on_mouse_move;
244
 
begin
245
 
 on_mouse_button_down(x ,y ,flags );
246
 
 
247
 
end;
248
 
 
249
 
{ ON_MOUSE_BUTTON_DOWN }
250
 
procedure the_application.on_mouse_button_down;
251
 
var
252
 
 width_ ,height_ : int;
253
 
 
254
 
begin
255
 
 if flags and mouse_left <> 0 then
256
 
  begin
257
 
   width_ :=rbuf_window._width;
258
 
   height_:=rbuf_window._height;
259
 
 
260
 
   transform(width_ ,height_ ,x ,y );
261
 
   force_redraw;
262
 
 
263
 
  end;
264
 
 
265
 
 if flags and mouse_right <> 0 then
266
 
  begin
267
 
   g_skew_x:=x;
268
 
   g_skew_y:=y;
269
 
 
270
 
   force_redraw;
271
 
 
272
 
  end;
273
 
 
274
 
end;
275
 
 
276
 
{ ON_KEY }
277
 
procedure the_application.on_key;
278
 
begin
279
 
 if key = key_f1 then
280
 
  message_(
281
 
   'The example demonstrates my new algorithm of drawing Anti-Aliased lines. '#13 +
282
 
   'The algorithm works about 2.5 times faster than the scanline rasterizer '#13 +
283
 
   'but has some restrictions, particularly, line joins can be only of the '#13 +
284
 
   '"miter" type, and when so called miter limit is exceded, they are not as '#13 +
285
 
   'accurate as generated by the stroke converter (conv_stroke).'#13#13 +
286
 
   'How to play with:'#13#13 +
287
 
   'To see the difference, maximize the window and try to rotate and scale '#13 +
288
 
   'the "lion" with and without using the scanline rasterizer (a checkbox '#13 +
289
 
   'at the bottom). The difference in performance is obvious.' +
290
 
   #13#13'Note: F2 key saves current "screenshot" file in this demo''s directory.  ' );
291
 
 
292
 
end;
293
 
 
294
 
VAR
295
 
 app : the_application;
296
 
 
297
 
BEGIN
298
 
// Rendering
299
 
 g_rasterizer.Construct;
300
 
 g_scanline.Construct;
301
 
 g_path.Construct;
302
 
 
303
 
 g_npaths:=0;
304
 
 
305
 
 g_x1:=0;
306
 
 g_y1:=0;
307
 
 g_x2:=0;
308
 
 g_y2:=0;
309
 
 
310
 
 g_base_dx:=0;
311
 
 g_base_dy:=0;
312
 
 
313
 
 g_angle:=0;
314
 
 g_scale:=1.0;
315
 
 
316
 
 g_skew_x:=0;
317
 
 g_skew_y:=0;
318
 
 g_nclick:=0;
319
 
 
320
 
// App
321
 
 app.Construct(pix_format ,flip_y );
322
 
 app.caption_ ('AGG Example. Lion (F1-Help)' );
323
 
 
324
 
 if app.init(512 ,512 ,window_resize ) then
325
 
  app.run;
326
 
 
327
 
 app.Destruct;
328
 
 
329
 
// Free
330
 
 g_rasterizer.Destruct;
331
 
 g_scanline.Destruct;
332
 
 g_path.Destruct;
333
 
 
334
 
END.
 
 
b'\\ No newline at end of file'