2
// AggPas 2.4 RM3 Demo application
3
// Note: Press F1 key on run to see more info about this demo
5
// Paths: src;src\ctrl;src\svg;src\util;src\platform\win;expat-wrap
22
agg_platform_support ,
27
agg_rasterizer_scanline_aa ,
32
agg_renderer_scanline ,
33
agg_render_scanlines ,
42
{$I pixel_formats.inc }
52
the_application = object(platform_support )
53
constructor Construct(format_ : pix_format_e; flip_y_ : boolean );
56
procedure on_init; virtual;
57
procedure on_draw; virtual;
59
procedure on_key(x ,y : int; key ,flags : unsigned ); virtual;
64
procedure read_gamma(fname : shortstring );
68
kx1 ,ky1 ,kx2 ,ky2 : double;
71
assignfile(fd ,fname );
79
g_ctrl.values(kx1 ,ky1 ,kx2 ,ky2 );
86
procedure write_gamma_bin(fname : shortstring );
95
assignfile(fd ,fname );
97
blockwrite(fd ,gamma^ ,256 );
103
procedure write_gamma_txt(fname : shortstring );
110
kx1 ,ky1 ,kx2 ,ky2 : double;
115
assignfile(fd ,fname );
118
g_ctrl.values(@kx1 ,@ky1 ,@kx2 ,@ky2 );
120
writeln(fd ,kx1:1:3 );
121
writeln(fd ,ky1:1:3 );
122
writeln(fd ,kx2:1:3 );
123
writeln(fd ,ky2:1:3 );
128
write(fd ,int8u_ptr(ptrcomp(gamma ) + i * 16 + j )^:3 ,',' );
139
constructor the_application.Construct;
141
inherited Construct(format_ ,flip_y_ );
148
destructor the_application.Destruct;
152
write_gamma_txt('gamma.txt' );
153
write_gamma_bin('gamma.bin' );
158
procedure the_application.on_init;
160
read_gamma('gamma.txt' );
165
procedure the_application.on_draw;
167
ewidth ,ecenter : double;
171
pixf : pixel_formats;
174
r : renderer_scanline_aa_solid;
176
ras : rasterizer_scanline_aa;
182
tpoly : conv_transform;
185
tas : trans_affine_skewing;
186
tar : trans_affine_rotation;
187
tat : trans_affine_translation;
190
text1 : gsv_text_outline;
192
trans : conv_transform;
195
// Initialize structures
196
ewidth :=_initial_width / 2 - 10;
197
ecenter:=_initial_width / 2;
199
pixfmt(pixf ,rbuf_window );
201
rb.Construct(@pixf );
204
rgba.ConstrDbl(1 ,1 ,1 );
207
g_ctrl.text_size_(10.0 ,12.0 );
212
// Render the controls
213
render_ctrl(@ras ,@sl ,@r ,@g_ctrl );
219
poly.Construct (@elli );
220
tpoly.Construct(@poly ,_trans_affine_resizing );
222
rgba.ConstrInt(0 ,0 ,0 );
225
elli.init (ecenter ,220 ,ewidth ,15 ,100 );
227
ras.add_path(@tpoly ,0 );
229
render_scanlines(@ras ,@sl ,@r );
231
elli.init (ecenter ,220 ,11 ,11 ,100 );
233
ras.add_path(@tpoly ,0 );
235
render_scanlines(@ras ,@sl ,@r );
237
rgba.ConstrInt(127 ,127 ,127 );
240
elli.init (ecenter ,260 ,ewidth ,15 ,100 );
242
ras.add_path(@tpoly ,0 );
244
render_scanlines(@ras ,@sl ,@r );
246
elli.init (ecenter ,260 ,11 ,11 ,100 );
248
ras.add_path(@tpoly ,0 );
250
render_scanlines(@ras ,@sl ,@r );
252
rgba.ConstrInt(192 ,192 ,192 );
255
elli.init (ecenter ,300 ,ewidth ,15 ,100 );
257
ras.add_path(@tpoly ,0 );
259
render_scanlines(@ras ,@sl ,@r );
261
elli.init (ecenter ,300 ,11 ,11 ,100 );
263
ras.add_path(@tpoly ,0 );
265
render_scanlines(@ras ,@sl ,@r );
267
rgba.ConstrDbl(0.0 ,0.0 ,0.4 );
270
elli.init (ecenter ,340 ,ewidth ,15.5 ,100 );
272
ras.add_path(@tpoly ,0 );
274
render_scanlines(@ras ,@sl ,@r );
276
elli.init (ecenter ,340 ,10.5 ,10.5 ,100 );
278
ras.add_path(@tpoly ,0 );
280
render_scanlines(@ras ,@sl ,@r );
282
elli.init (ecenter ,380 ,ewidth ,15.5 ,100 );
284
ras.add_path(@tpoly ,0 );
286
render_scanlines(@ras ,@sl ,@r );
288
elli.init (ecenter ,380 ,10.5 ,10.5 ,100 );
290
ras.add_path(@tpoly ,0 );
292
render_scanlines(@ras ,@sl ,@r );
294
elli.init (ecenter ,420 ,ewidth ,15.5 ,100 );
296
ras.add_path(@tpoly ,0 );
298
render_scanlines(@ras ,@sl ,@r );
300
elli.init (ecenter ,420 ,10.5 ,10.5 ,100 );
302
ras.add_path(@tpoly ,0 );
304
render_scanlines(@ras ,@sl ,@r );
308
tas.Construct(0.15 ,0.0 );
309
mtx.Multiply (@tas );
310
mtx.Multiply (_trans_affine_resizing );
313
text1.Construct(@text ,@mtx );
315
text.text_ ('Text 2345' );
316
text.size_ (50 ,20 );
318
text.start_point_(320 ,10 );
320
rgba.ConstrDbl(0.0 ,0.5 ,0.0 );
323
ras.add_path (@text1 ,0 );
324
render_scanlines(@ras ,@sl ,@r );
327
rgba.ConstrDbl(0.5 ,0.0 ,0.0 );
331
path.move_to(30 ,-1.0 );
332
path.line_to(60 ,0.0 );
333
path.line_to(30 ,1.0 );
335
path.move_to(27 ,-1.0 );
336
path.line_to(10 ,0.0 );
337
path.line_to(27 ,1.0 );
339
trans.Construct(@path ,@mtx );
343
tar.Construct(i / 35.0 * pi * 2.0 );
344
tat.construct(400 ,130 );
349
mtx.multiply(_trans_affine_resizing );
351
ras.add_path (@trans ,0 );
352
render_scanlines(@ras ,@sl ,@r );
356
// Free AGG resources
368
procedure the_application.on_key;
372
'This is another experiment with gamma correction. See also Gamma Correction. '#13 +
373
'I presumed that we can do better than with a traditional power function. '#13 +
374
'So, I created a special control to have an arbitrary gamma function. '#13 +
375
'The conclusion is that we can really achieve a better visual result with '#13 +
376
'this control, but still, in practice, the traditional power function is good '#13 +
377
'enough too.'#13#13 +
378
'How to play with:'#13#13 +
379
'Feel free to change the gamma curve. The shape you''ll set up, will be'#13 +
380
'stored in external file "gamma.txt".' +
381
#13#13'Note: F2 key saves current "screenshot" file in this demo''s directory. ' );
386
app : the_application;
389
g_ctrl.Construct(10.0 ,10.0 ,300.0 ,200.0 ,not flip_y );
391
app.Construct(pix_format ,flip_y );
392
app.caption_ ('Anti-Aliasing Gamma Correction (F1-Help)' );
394
if app.init(500 ,400 ,window_resize ) then
b'\\ No newline at end of file'