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

« back to all changes in this revision

Viewing changes to components/aggpas/compositing.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
 
{mac_copy:compositing.bmp}
2
 
//
3
 
// AggPas 2.4 RM3 Demo application
4
 
// Note: Press F1 key on run to see more info about this demo
5
 
//
6
 
// Paths: src;src\ctrl;src\svg;src\util;src\platform\win;expat-wrap
7
 
//
8
 
program
9
 
 compositing ;
10
 
 
11
 
uses
12
 
 Math ,SysUtils ,
13
 
 
14
 
 agg_basics ,
15
 
 agg_platform_support ,
16
 
 
17
 
 agg_color ,
18
 
 agg_pixfmt ,
19
 
 agg_pixfmt_rgba ,
20
 
 
21
 
 agg_ctrl ,
22
 
 agg_rbox_ctrl ,
23
 
 agg_slider_ctrl ,
24
 
 
25
 
 agg_rendering_buffer ,
26
 
 agg_renderer_base ,
27
 
 agg_renderer_scanline ,
28
 
 agg_rasterizer_scanline_aa ,
29
 
 agg_scanline ,
30
 
 agg_scanline_u ,
31
 
 agg_render_scanlines ,
32
 
 
33
 
 agg_math ,
34
 
 agg_array ,
35
 
 agg_ellipse ,
36
 
 agg_conv_stroke ,
37
 
 agg_trans_affine ,
38
 
 agg_rounded_rect ,
39
 
 agg_span_gradient ,
40
 
 agg_span_allocator ,
41
 
 agg_gsv_text ,
42
 
 agg_span_interpolator_linear ,
43
 
 file_utils_ ;
44
 
 
45
 
{$I agg_mode.inc }
46
 
 
47
 
const
48
 
 flip_y = true;
49
 
 
50
 
 base_shift = agg_color.base_shift;
51
 
 
52
 
type
53
 
 gradient_linear_color = object(array_base )
54
 
   m_c1  ,
55
 
   m_c2  ,
56
 
   m_res : aggclr;
57
 
 
58
 
   constructor Construct; overload;
59
 
   constructor Construct(c1 ,c2 : aggclr_ptr ); overload;
60
 
 
61
 
   procedure colors(c1 ,c2 : aggclr_ptr );
62
 
 
63
 
   function  size : unsigned; virtual;
64
 
   function  array_operator(i : unsigned ) : pointer; virtual;
65
 
 
66
 
  end;
67
 
 
68
 
 the_application = object(platform_support )
69
 
   m_alpha_src ,
70
 
   m_alpha_dst : slider_ctrl;
71
 
   m_comp_op   : rbox_ctrl;
72
 
 
73
 
   constructor Construct(format_ : pix_format_e; flip_y_ : boolean );
74
 
   destructor  Destruct;
75
 
 
76
 
   procedure render_scene(rbuf : rendering_buffer_ptr; pixf : pixel_formats_ptr );
77
 
 
78
 
   procedure on_init; virtual;
79
 
   procedure on_draw; virtual;
80
 
 
81
 
   procedure on_mouse_move       (x ,y : int; flags : unsigned ); virtual;
82
 
   procedure on_mouse_button_down(x ,y : int; flags : unsigned ); virtual;
83
 
   procedure on_mouse_button_up  (x ,y : int; flags : unsigned ); virtual;
84
 
 
85
 
   procedure on_key(x ,y : int; key ,flags : unsigned ); virtual;
86
 
 
87
 
  end;
88
 
 
89
 
{ gradient_affine }
90
 
procedure gradient_affine(var mtx : trans_affine; x1 ,y1 ,x2 ,y2 : double; gradient_d2 : double = 100.0 );
91
 
var
92
 
 dx ,dy : double;
93
 
 
94
 
 tas : trans_affine_scaling;
95
 
 tar : trans_affine_rotation;
96
 
 tat : trans_affine_translation;
97
 
 
98
 
begin
99
 
 mtx.Construct;
100
 
 
101
 
 dx:=x2 - x1;
102
 
 dy:=y2 - y1;
103
 
 
104
 
 mtx.reset;
105
 
 
106
 
 tas.Construct(Sqrt(dx * dx + dy * dy ) / gradient_d2 ); mtx.multiply(@tas );
107
 
 tar.Construct(ArcTan2(dy ,dx ) ); mtx.multiply(@tar );
108
 
 tat.Construct(x1 ,y1 ); mtx.multiply(@tat );
109
 
 
110
 
 mtx.invert;
111
 
 
112
 
end;
113
 
 
114
 
{ circle }
115
 
procedure circle(rbase : renderer_base_ptr; c1 ,c2 : aggclr_ptr; x1 ,y1 ,x2 ,y2 ,shadow_alpha : double );
116
 
var
117
 
 color_func : gradient_linear_color;
118
 
 
119
 
 gradient_func  : gradient_x;
120
 
 gradient_mtx   : trans_affine;
121
 
 span_gradient_ : span_gradient;
122
 
 ren_gradient   : renderer_scanline_aa;
123
 
 ren_solid      : renderer_scanline_aa_solid;
124
 
 
125
 
 span_interpolator : span_interpolator_linear;
126
 
 span_allocator_   : span_allocator;
127
 
 
128
 
 rgba : aggclr;
129
 
 
130
 
 ras : rasterizer_scanline_aa;
131
 
 sl  : scanline_u8;
132
 
 ell : ellipse;
133
 
 
134
 
 r : double;
135
 
 
136
 
begin
137
 
 gradient_func.Construct;                      // The gradient function
138
 
 gradient_affine(gradient_mtx ,x1 ,y1 ,x2 ,y2 ,100 );
139
 
 
140
 
 span_interpolator.Construct(@gradient_mtx );  // Span interpolator
141
 
 span_allocator_.Construct;                    // Span Allocator
142
 
 color_func.Construct(c1 ,c2 );
143
 
 
144
 
 span_gradient_.Construct(
145
 
  @span_allocator_ ,
146
 
  @span_interpolator,
147
 
  @gradient_func,
148
 
  @color_func,
149
 
  0 ,100 );
150
 
 
151
 
 ren_gradient.Construct(rbase ,@span_gradient_ );
152
 
 ras.Construct;
153
 
 sl.Construct;
154
 
 
155
 
 r:=calc_distance(x1 ,y1 ,x2 ,y2 ) / 2;
156
 
 
157
 
 ell.Construct      ((x1 + x2 ) / 2 + 5 ,(y1 + y2 ) / 2 - 3 ,r ,r ,100 );
158
 
 ren_solid.Construct(rbase );
159
 
 rgba.ConstrDbl     (0.6 ,0.6 ,0.6 ,0.7 * shadow_alpha );
160
 
 ren_solid.color_   (@rgba );
161
 
 ras.add_path       (@ell );
162
 
 render_scanlines   (@ras ,@sl ,@ren_solid );
163
 
 
164
 
 ell.init        ((x1 + x2 ) / 2 ,(y1 + y2 ) / 2 ,r ,r ,100 );
165
 
 ras.add_path    (@ell );
166
 
 render_scanlines(@ras ,@sl ,@ren_gradient );
167
 
 
168
 
// Free
169
 
 ras.Destruct;
170
 
 sl.Destruct;
171
 
 span_allocator_.Destruct;
172
 
 
173
 
end;
174
 
 
175
 
{ dst_shape }
176
 
procedure dst_shape(rbase : renderer_base_ptr; c1 ,c2 : aggclr_ptr; x1 ,y1 ,x2 ,y2 : double );
177
 
var
178
 
 color_func : gradient_linear_color;
179
 
 shape      : rounded_rect;
180
 
 
181
 
 gradient_func : gradient_x;
182
 
 gradient_mtx  : trans_affine;
183
 
 ren_gradient  : renderer_scanline_aa;
184
 
 
185
 
 span_interpolator : span_interpolator_linear;
186
 
 span_allocator_   : span_allocator;
187
 
 span_gradient_    : span_gradient;
188
 
 
189
 
 ras : rasterizer_scanline_aa;
190
 
 sl  : scanline_u8;
191
 
 
192
 
begin
193
 
 gradient_func.Construct;                      // The gradient function
194
 
 gradient_affine(gradient_mtx ,x1 ,y1 ,x2 ,y2 ,100 );
195
 
 
196
 
 span_interpolator.Construct(@gradient_mtx);   // Span interpolator
197
 
 span_allocator_.Construct;                    // Span Allocator
198
 
 color_func.Construct(c1 ,c2 );
199
 
 
200
 
 span_gradient_.Construct(
201
 
  @span_allocator_ ,
202
 
  @span_interpolator ,
203
 
  @gradient_func ,
204
 
  @color_func ,
205
 
  0 ,100 );
206
 
 
207
 
 ren_gradient.Construct(rbase ,@span_gradient_ );
208
 
 ras.Construct;
209
 
 sl.Construct;
210
 
 
211
 
 shape.Construct (x1 ,y1 ,x2 ,y2 ,40 );
212
 
 ras.add_path    (@shape );
213
 
 render_scanlines(@ras ,@sl ,@ren_gradient );
214
 
 
215
 
// Free
216
 
 ras.Destruct;
217
 
 sl.Destruct;
218
 
 span_allocator_.Destruct;
219
 
 
220
 
end;
221
 
 
222
 
{ CONSTRUCT }
223
 
constructor gradient_linear_color.Construct;
224
 
begin
225
 
 m_c1.Construct;
226
 
 m_c2.Construct;
227
 
 m_res.Construct;
228
 
 
229
 
end;
230
 
 
231
 
{ CONSTRUCT }
232
 
constructor gradient_linear_color.Construct(c1 ,c2 : aggclr_ptr );
233
 
begin
234
 
 m_res.Construct;
235
 
 
236
 
 m_c1:=c1^;
237
 
 m_c2:=c2^;
238
 
 
239
 
end;
240
 
 
241
 
{ COLORS }
242
 
procedure gradient_linear_color.colors;
243
 
begin
244
 
 m_c1:=c1^;
245
 
 m_c2:=c2^;
246
 
 
247
 
end;
248
 
 
249
 
{ SIZE }
250
 
function gradient_linear_color.size;
251
 
begin
252
 
 result:=256
253
 
 
254
 
end;
255
 
 
256
 
{ ARRAY_OPERATOR }
257
 
function gradient_linear_color.array_operator;
258
 
begin
259
 
 i:=i shl (base_shift - 8 );
260
 
 
261
 
 m_res.r:=int8u((((m_c2.r - m_c1.r ) * i ) + (m_c1.r shl base_shift ) ) shr base_shift );
262
 
 m_res.g:=int8u((((m_c2.g - m_c1.g ) * i ) + (m_c1.g shl base_shift ) ) shr base_shift );
263
 
 m_res.b:=int8u((((m_c2.b - m_c1.b ) * i ) + (m_c1.b shl base_shift ) ) shr base_shift );
264
 
 m_res.a:=int8u((((m_c2.a - m_c1.a ) * i ) + (m_c1.a shl base_shift ) ) shr base_shift );
265
 
 
266
 
 result:=@m_res;
267
 
 
268
 
end;
269
 
 
270
 
{ CONSTRUCT }
271
 
constructor the_application.Construct;
272
 
begin
273
 
 inherited Construct(format_ ,flip_y_ );
274
 
 
275
 
 m_alpha_src.Construct(5 ,5 ,400 ,11 ,not flip_y_ );
276
 
 m_alpha_dst.Construct(5 ,5 + 15 ,400 ,11 + 15 ,not flip_y_ );
277
 
 m_comp_op.Construct  (420 ,5.0 ,420 + 170.0 ,395.0 ,not flip_y_ );
278
 
 
279
 
 m_alpha_src.label_('Src Alpha=%.2f' );
280
 
 m_alpha_src.value_(1.0 );
281
 
 
282
 
 add_ctrl(@m_alpha_src );
283
 
 
284
 
 m_alpha_dst.label_('Dst Alpha=%.2f' );
285
 
 m_alpha_dst.value_(0.75 );
286
 
 
287
 
 add_ctrl(@m_alpha_dst );
288
 
 
289
 
 m_comp_op.text_size_(7 );
290
 
 m_comp_op.add_item ('clear' );
291
 
 m_comp_op.add_item ('src' );
292
 
 m_comp_op.add_item ('dst' );
293
 
 m_comp_op.add_item ('src-over' );
294
 
 m_comp_op.add_item ('dst-over' );
295
 
 m_comp_op.add_item ('src-in' );
296
 
 m_comp_op.add_item ('dst-in' );
297
 
 m_comp_op.add_item ('src-out' );
298
 
 m_comp_op.add_item ('dst-out' );
299
 
 m_comp_op.add_item ('src-atop' );
300
 
 m_comp_op.add_item ('dst-atop' );
301
 
 m_comp_op.add_item ('xor' );
302
 
 m_comp_op.add_item ('plus' );
303
 
 m_comp_op.add_item ('minus' );
304
 
 m_comp_op.add_item ('multiply' );
305
 
 m_comp_op.add_item ('screen' );
306
 
 m_comp_op.add_item ('overlay' );
307
 
 m_comp_op.add_item ('darken' );
308
 
 m_comp_op.add_item ('lighten' );
309
 
 m_comp_op.add_item ('color-dodge' );
310
 
 m_comp_op.add_item ('color-burn' );
311
 
 m_comp_op.add_item ('hard-light' );
312
 
 m_comp_op.add_item ('soft-light' );
313
 
 m_comp_op.add_item ('difference' );
314
 
 m_comp_op.add_item ('exclusion' );
315
 
 m_comp_op.add_item ('contrast' );
316
 
 m_comp_op.cur_item_(3 );
317
 
 
318
 
 add_ctrl(@m_comp_op );
319
 
 
320
 
end;
321
 
 
322
 
{ DESTRUCT }
323
 
destructor the_application.Destruct;
324
 
begin
325
 
 inherited Destruct;
326
 
 
327
 
 m_alpha_src.Destruct;
328
 
 m_alpha_dst.Destruct;
329
 
 m_comp_op.Destruct;
330
 
 
331
 
end;
332
 
 
333
 
{ RENDER_SCENE }
334
 
procedure the_application.render_scene;
335
 
var
336
 
 ren_pixf ,px : pixel_formats;
337
 
 renderer ,rb : renderer_base;
338
 
 
339
 
 rgba ,rgbb : aggclr;
340
 
 
341
 
 v : double;
342
 
 
343
 
begin
344
 
 pixfmt_custom_blend_rgba(ren_pixf ,rbuf ,@comp_op_adaptor_rgba ,bgra_order );
345
 
 
346
 
 renderer.Construct(@ren_pixf );
347
 
 rb.Construct      (pixf );
348
 
 
349
 
 pixfmt_bgra32(px ,rbuf_img(1 ) );
350
 
 rb.blend_from(@px ,NIL ,250 ,180 ,unsigned(trunc(m_alpha_src._value * 255 ) ) );
351
 
 
352
 
 rgba.ConstrInt($FD ,$F0 ,$6F ,unsigned(trunc(m_alpha_src._value * 255 ) ) );
353
 
 rgbb.ConstrInt($FE ,$9F ,$34 ,unsigned(trunc(m_alpha_src._value * 255 ) ) );
354
 
 
355
 
 circle(
356
 
  @rb ,@rgba ,@rgbb ,
357
 
  70 * 3 ,100 + 24 * 3 ,37 * 3 ,100 + 79 * 3 ,
358
 
  m_alpha_src._value );
359
 
 
360
 
 ren_pixf.comp_op_(m_comp_op._cur_item );
361
 
 
362
 
 if m_comp_op._cur_item = 25 then // Contrast
363
 
  begin
364
 
   v:=m_alpha_dst._value;
365
 
 
366
 
   rgba.ConstrDbl(v ,v ,v );
367
 
 
368
 
   dst_shape(
369
 
    @renderer ,
370
 
    @rgba ,@rgba ,
371
 
    300 + 50 ,100 + 24 * 3 ,107 + 50 ,100 + 79 * 3 );
372
 
 
373
 
  end
374
 
 else
375
 
  begin
376
 
   rgba.ConstrInt($7F ,$C1 ,$FF ,unsigned(trunc(m_alpha_dst._value * 255 ) ) );
377
 
   rgbb.ConstrInt($05 ,$00 ,$5F ,unsigned(trunc(m_alpha_dst._value * 255 ) ) );
378
 
 
379
 
   dst_shape(
380
 
    @renderer ,
381
 
    @rgba ,@rgbb ,
382
 
    300 + 50 ,100 + 24 * 3 ,107 + 50 ,100 + 79 * 3 );
383
 
 
384
 
  end;
385
 
 
386
 
end;
387
 
 
388
 
{ ON_INIT }
389
 
procedure the_application.on_init;
390
 
begin
391
 
end;
392
 
 
393
 
{ ON_DRAW }
394
 
procedure the_application.on_draw;
395
 
var
396
 
 pixf ,pixf2 ,pixf_pre : pixel_formats;
397
 
 
398
 
 rgba : aggclr;
399
 
 
400
 
 rb ,rb2 ,rb_pre : renderer_base;
401
 
 
402
 
 ras : rasterizer_scanline_aa;
403
 
 sl  : scanline_u8;
404
 
 ren : renderer_scanline_aa_solid;
405
 
 
406
 
 y ,x : unsigned;
407
 
 
408
 
 tm  : double;
409
 
 buf : array[0..63 ] of char;
410
 
 t   : gsv_text;
411
 
 pt  : conv_stroke;
412
 
 
413
 
begin
414
 
// Initialize structures
415
 
 pixfmt_bgra32(pixf ,rbuf_window );
416
 
 rb.Construct (@pixf );
417
 
 
418
 
 rgba.ConstrInt(255 ,255 ,255 );
419
 
 rb.clear      (@rgba );
420
 
 
421
 
 y:=0;
422
 
 
423
 
 while y < rb.height do
424
 
  begin
425
 
   x:=((y shr 3 ) and 1) shl 3;
426
 
 
427
 
   while x < rb.width do
428
 
    begin
429
 
     rgba.ConstrInt($df ,$df ,$df );
430
 
 
431
 
     rb.copy_bar(x ,y ,x + 7 ,y + 7 ,@rgba );
432
 
 
433
 
     inc(x ,16 );
434
 
 
435
 
    end;
436
 
 
437
 
   inc(y ,8 );
438
 
 
439
 
  end;
440
 
 
441
 
 create_img(0 ,rbuf_window._width ,rbuf_window._height ); // agg_platform_support functionality
442
 
 
443
 
 pixfmt_bgra32(pixf2 ,rbuf_img(0 ) );
444
 
 rb2.Construct(@pixf2 );
445
 
 
446
 
 rgba.ConstrInt(0 ,0 ,0 ,0 );
447
 
 rb2.clear     (@rgba );
448
 
 
449
 
 pixfmt_bgra32_pre(pixf_pre ,rbuf_window );
450
 
 rb_pre.Construct (@pixf_pre );
451
 
 
452
 
// Render Scene 
453
 
 start_timer;
454
 
 
455
 
 render_scene(rbuf_img(0 ) ,@pixf2 );
456
 
 
457
 
 tm:=elapsed_time;
458
 
 
459
 
 rb_pre.blend_from(@pixf2 );
460
 
 
461
 
// Render Text
462
 
 ras.Construct;
463
 
 sl.Construct;
464
 
 ren.Construct(@rb );
465
 
 
466
 
 t.Construct;
467
 
 t.size_(10.0 );
468
 
 
469
 
 pt.Construct(@t );
470
 
 pt.width_   (1.5 );
471
 
 
472
 
 sprintf       (@buf[0 ] ,'%3.2f ms' ,tm );
473
 
 t.start_point_(10.0 ,35.0 );
474
 
 t.text_       (@buf[0 ] );
475
 
 
476
 
 ras.add_path    (@pt );
477
 
 rgba.ConstrDbl  (0 ,0 ,0 );
478
 
 ren.color_      (@rgba );
479
 
 render_scanlines(@ras ,@sl ,@ren );
480
 
 
481
 
// Render the controls
482
 
 render_ctrl(@ras ,@sl ,@ren ,@m_alpha_src );
483
 
 render_ctrl(@ras ,@sl ,@ren ,@m_alpha_dst );
484
 
 render_ctrl(@ras ,@sl ,@ren ,@m_comp_op );
485
 
 
486
 
// Free AGG resources
487
 
 ras.Destruct;
488
 
 sl.Destruct;
489
 
 
490
 
 t.Destruct;
491
 
 pt.Destruct;
492
 
 
493
 
end;
494
 
 
495
 
{ ON_MOUSE_MOVE }
496
 
procedure the_application.on_mouse_move;
497
 
begin
498
 
end;
499
 
 
500
 
{ ON_MOUSE_BUTTON_DOWN }
501
 
procedure the_application.on_mouse_button_down;
502
 
begin
503
 
end;
504
 
 
505
 
{ ON_MOUSE_BUTTON_UP }
506
 
procedure the_application.on_mouse_button_up;
507
 
begin
508
 
end;
509
 
 
510
 
{ ON_KEY }
511
 
procedure the_application.on_key;
512
 
begin
513
 
 if key = key_f1 then
514
 
  message_(
515
 
   'AGG is fully compatible with all SVG 1.2 extended compositing modes.  '#13#13 +
516
 
   'How to play with:'#13#13 +
517
 
   'Try to change the alpha values of the source an destination images,'#13 +
518
 
   'to see, how a particular operation composes the resulting image.' +
519
 
   #13#13'Note: F2 key saves current "screenshot" file in this demo''s directory.  ' );
520
 
 
521
 
end;
522
 
 
523
 
VAR
524
 
 app : the_application;
525
 
 buf : array [0..255 ] of char;
526
 
 ext : string[10 ];
527
 
 
528
 
 img_name ,p ,n ,x : shortstring;
529
 
 
530
 
BEGIN
531
 
 app.Construct(pix_format_bgra32 ,flip_y );
532
 
 app.caption_ ('AGG Example. Compositing Modes (F1-Help)' );
533
 
 
534
 
 img_name:='compositing';
535
 
 
536
 
{$IFDEF WIN32 }
537
 
 if ParamCount > 0 then
538
 
  begin
539
 
   spread_name(ParamStr(1 ) ,p ,n ,x );
540
 
 
541
 
   img_name:=fold_name(p ,n ,'' );
542
 
 
543
 
  end;
544
 
 
545
 
{$ENDIF }  
546
 
 
547
 
 if not app.load_img(1 ,img_name ) then
548
 
  begin
549
 
   img_name:=img_name + #0;
550
 
   ext     :=app._img_ext + #0;
551
 
 
552
 
   if img_name = 'compositing'#0 then
553
 
    begin
554
 
     sprintf(@buf[0 ]             ,'File not found: %s' ,ptrcomp(@img_name[1 ] ) );
555
 
     sprintf(@buf[StrLen(@buf ) ] ,'%s. '#13'Download http://www.antigrain.com/' ,ptrcomp(@ext[1 ] ) );
556
 
     sprintf(@buf[StrLen(@buf ) ] ,'%s' ,ptrcomp(@img_name[1 ] ) );
557
 
     sprintf(@buf[StrLen(@buf ) ] ,'%s'#13'or copy it from another directory if available.' ,ptrcomp(@ext[1 ] ) );
558
 
 
559
 
    end
560
 
   else
561
 
    begin
562
 
     sprintf(@buf[0 ]             ,'File not found: %s' ,ptrcomp(@img_name[1 ] ) );
563
 
     sprintf(@buf[StrLen(@buf ) ] ,'%s' ,ptrcomp(@ext[1 ] ) );
564
 
 
565
 
    end;
566
 
 
567
 
   app.message_(@buf[0 ] );
568
 
 
569
 
  end
570
 
 else
571
 
  if app.init(600 ,400 ,window_resize ) then
572
 
   app.run;
573
 
 
574
 
 app.Destruct;
575
 
 
576
 
END.
 
 
b'\\ No newline at end of file'