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

« back to all changes in this revision

Viewing changes to components/aggpas/compositing2.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
 
 compositing2 ;
9
 
 
10
 
uses
11
 
 agg_basics ,
12
 
 agg_color ,
13
 
 agg_platform_support ,
14
 
 agg_ctrl ,
15
 
 agg_slider_ctrl ,
16
 
 agg_rbox_ctrl ,
17
 
 agg_rendering_buffer ,
18
 
 agg_rasterizer_scanline_aa ,
19
 
 agg_scanline_u ,
20
 
 agg_renderer_base ,
21
 
 agg_renderer_scanline ,
22
 
 agg_render_scanlines ,
23
 
 agg_rounded_rect ,
24
 
 agg_pixfmt ,
25
 
 agg_pixfmt_rgba ,
26
 
 agg_span_allocator ,
27
 
 agg_span_gradient ,
28
 
 agg_gsv_text ,
29
 
 agg_span_interpolator_linear ,
30
 
 agg_array ,
31
 
 agg_trans_affine ,
32
 
 agg_ellipse ,
33
 
 agg_conv_transform ;
34
 
 
35
 
{$I agg_mode.inc }
36
 
 
37
 
const
38
 
 flip_y = true;
39
 
 
40
 
type
41
 
 the_application = object(platform_support )
42
 
  private
43
 
   m_alpha_dst ,
44
 
   m_alpha_src : slider_ctrl;
45
 
   m_comp_op   : rbox_ctrl;
46
 
 
47
 
   m_ramp1 ,
48
 
   m_ramp2 : pod_auto_array;
49
 
 
50
 
   m_ras : rasterizer_scanline_aa;
51
 
   m_sl  : scanline_u8;
52
 
 
53
 
  public
54
 
   constructor Construct(format_ : pix_format_e; flip_y_ : boolean );
55
 
   destructor  Destruct;
56
 
 
57
 
   procedure radial_shape(
58
 
              rbase : renderer_base_ptr;
59
 
              colors : array_base_ptr;
60
 
              x1 ,y1 ,x2 ,y2 : double );
61
 
 
62
 
   procedure render_scene(rb : renderer_base_ptr );
63
 
 
64
 
   procedure on_draw; virtual;
65
 
 
66
 
   procedure on_key(x ,y : int; key ,flags : unsigned ); virtual;
67
 
 
68
 
  end;
69
 
 
70
 
{ CONSTRUCT }
71
 
constructor the_application.Construct;
72
 
begin
73
 
 inherited Construct(format_ ,flip_y_ );
74
 
 
75
 
 m_alpha_dst.Construct(5   ,5      ,400         ,11      ,not flip_y_ );
76
 
 m_alpha_src.Construct(5   ,5 + 15 ,400         ,11 + 15 ,not flip_y_ );
77
 
 m_comp_op.Construct  (420 ,5.0    ,420 + 170.0 ,395.0   ,not flip_y_ );
78
 
 
79
 
 m_ramp1.Construct(256 ,sizeof(aggclr ) );
80
 
 m_ramp2.Construct(256 ,sizeof(aggclr ) );
81
 
 
82
 
 m_ras.Construct;
83
 
 m_sl.Construct;
84
 
 
85
 
 m_alpha_dst.label_('Dst Alpha=%.2f' );
86
 
 m_alpha_dst.value_(1.0 );
87
 
 
88
 
 add_ctrl(@m_alpha_dst );
89
 
 
90
 
 m_alpha_src.label_('Src Alpha=%.2f' );
91
 
 m_alpha_src.value_(1.0 );
92
 
 
93
 
 add_ctrl(@m_alpha_src );
94
 
 
95
 
 m_comp_op.text_size_(6.8 );
96
 
 m_comp_op.add_item  ('clear' );
97
 
 m_comp_op.add_item  ('src' );
98
 
 m_comp_op.add_item  ('dst' );
99
 
 m_comp_op.add_item  ('src-over' );
100
 
 m_comp_op.add_item  ('dst-over' );
101
 
 m_comp_op.add_item  ('src-in' );
102
 
 m_comp_op.add_item  ('dst-in' );
103
 
 m_comp_op.add_item  ('src-out' );
104
 
 m_comp_op.add_item  ('dst-out' );
105
 
 m_comp_op.add_item  ('src-atop' );
106
 
 m_comp_op.add_item  ('dst-atop' );
107
 
 m_comp_op.add_item  ('xor' );
108
 
 m_comp_op.add_item  ('plus' );
109
 
 m_comp_op.add_item  ('minus' );
110
 
 m_comp_op.add_item  ('multiply' );
111
 
 m_comp_op.add_item  ('screen' );
112
 
 m_comp_op.add_item  ('overlay' );
113
 
 m_comp_op.add_item  ('darken' );
114
 
 m_comp_op.add_item  ('lighten' );
115
 
 m_comp_op.add_item  ('color-dodge' );
116
 
 m_comp_op.add_item  ('color-burn' );
117
 
 m_comp_op.add_item  ('hard-light' );
118
 
 m_comp_op.add_item  ('soft-light' );
119
 
 m_comp_op.add_item  ('difference' );
120
 
 m_comp_op.add_item  ('exclusion' );
121
 
 m_comp_op.add_item  ('contrast' );
122
 
 m_comp_op.add_item  ('invert' );
123
 
 m_comp_op.add_item  ('invert-rgb' );
124
 
 m_comp_op.cur_item_ (3 );
125
 
 
126
 
 add_ctrl(@m_comp_op );
127
 
 
128
 
end;
129
 
 
130
 
{ DESTRUCT }
131
 
destructor the_application.Destruct;
132
 
begin
133
 
 inherited Destruct;
134
 
 
135
 
 m_alpha_dst.Destruct;
136
 
 m_alpha_src.Destruct;
137
 
 m_comp_op.Destruct;
138
 
 
139
 
 m_ramp1.Destruct;
140
 
 m_ramp2.Destruct;
141
 
 
142
 
 m_ras.Destruct;
143
 
 m_sl.Destruct;
144
 
 
145
 
end;
146
 
 
147
 
{ RADIAL_SHAPE }
148
 
procedure the_application.radial_shape;
149
 
var
150
 
 gradient_func     : gradient_radial;
151
 
 gradient_mtx      : trans_affine;
152
 
 span_interpolator : span_interpolator_linear;
153
 
 span_allocator_   : span_allocator;
154
 
 span_gradient_    : span_gradient;
155
 
 
156
 
 cx ,cy ,r : double;
157
 
 
158
 
 tas : trans_affine_scaling;
159
 
 tat : trans_affine_translation;
160
 
 
161
 
 ell : ellipse;
162
 
 
163
 
 trans : conv_transform;
164
 
 
165
 
 rg : renderer_scanline_aa;
166
 
 
167
 
begin
168
 
 gradient_func.Construct;
169
 
 gradient_mtx.Construct;
170
 
 span_interpolator.Construct(@gradient_mtx );
171
 
 span_allocator_.Construct;
172
 
 span_gradient_.Construct(
173
 
  @span_allocator_ ,
174
 
  @span_interpolator ,
175
 
  @gradient_func ,
176
 
  colors ,
177
 
  0 ,100 );
178
 
 
179
 
 cx:=(x1 + x2 ) / 2.0;
180
 
 cy:=(y1 + y2 ) / 2.0;
181
 
 
182
 
 if (x2 - x1 ) < (y2 - y1 ) then
183
 
  r:=0.5 * (x2 - x1 )
184
 
 else
185
 
  r:=0.5 * (y2 - y1 );
186
 
 
187
 
 tas.Construct        (r / 100.0 );
188
 
 gradient_mtx.multiply(@tas );
189
 
 tat.Construct        (cx ,cy );
190
 
 gradient_mtx.multiply(@tat );
191
 
 gradient_mtx.multiply(_trans_affine_resizing );
192
 
 gradient_mtx.invert;
193
 
 
194
 
 ell.Construct  (cx ,cy ,r ,r ,100 );
195
 
 trans.Construct(@ell ,_trans_affine_resizing );
196
 
 
197
 
 m_ras.add_path(@trans );
198
 
 rg.Construct  (rbase ,@span_gradient_ );
199
 
 
200
 
 render_scanlines(@m_ras ,@m_sl ,@rg );
201
 
 
202
 
 span_allocator_.Destruct;
203
 
 span_gradient_.Destruct;
204
 
 
205
 
end;
206
 
 
207
 
{ RENDER_SCENE }
208
 
procedure the_application.render_scene;
209
 
var
210
 
 pixf : pixel_formats;
211
 
 ren  : renderer_base;
212
 
 
213
 
 cx ,cy : double;
214
 
 
215
 
begin
216
 
 pixfmt_custom_blend_rgba(pixf ,rbuf_window ,@comp_op_adaptor_rgba ,bgra_order );
217
 
 
218
 
 ren.Construct(@pixf );
219
 
 
220
 
 pixf.comp_op_(unsigned(comp_op_difference ) );
221
 
 radial_shape (@ren ,@m_ramp1 ,50 ,50 ,50 + 320 ,50 + 320 );
222
 
 
223
 
 pixf.comp_op_(m_comp_op._cur_item );
224
 
 
225
 
 cx:=50;
226
 
 cy:=50;
227
 
 
228
 
 radial_shape(@ren ,@m_ramp2 ,cx + 120 - 70 ,cy + 120 - 70 ,cx + 120 + 70 ,cy + 120 + 70 );
229
 
 radial_shape(@ren ,@m_ramp2 ,cx + 200 - 70 ,cy + 120 - 70 ,cx + 200 + 70 ,cy + 120 + 70 );
230
 
 radial_shape(@ren ,@m_ramp2 ,cx + 120 - 70 ,cy + 200 - 70 ,cx + 120 + 70 ,cy + 200 + 70 );
231
 
 radial_shape(@ren ,@m_ramp2 ,cx + 200 - 70 ,cy + 200 - 70 ,cx + 200 + 70 ,cy + 200 + 70 );
232
 
 
233
 
end;
234
 
 
235
 
{ generate_color_ramp }
236
 
procedure generate_color_ramp(c : pod_auto_array_ptr; c1 ,c2 ,c3 ,c4 : aggclr_ptr );
237
 
var
238
 
 i : unsigned;
239
 
 
240
 
begin
241
 
 i:=0;
242
 
 
243
 
 while i < 85 do
244
 
  begin
245
 
   aggclr_ptr(c.array_operator(i ) )^:=c1.gradient(c2 ,i / 85.0 );
246
 
 
247
 
   inc(i );
248
 
 
249
 
  end;
250
 
 
251
 
 while i < 170 do
252
 
  begin
253
 
   aggclr_ptr(c.array_operator(i ) )^:=c2.gradient(c3 ,(i - 85 ) / 85.0 );
254
 
 
255
 
   inc(i );
256
 
 
257
 
  end;
258
 
 
259
 
 while i < 256 do
260
 
  begin
261
 
   aggclr_ptr(c.array_operator(i ) )^:=c3.gradient(c4 ,(i - 170 ) / 85.0 );
262
 
 
263
 
   inc(i );
264
 
 
265
 
  end;
266
 
 
267
 
end;
268
 
 
269
 
{ ON_DRAW }
270
 
procedure the_application.on_draw;
271
 
var
272
 
 pixf : pixel_formats;
273
 
 rgba : aggclr;
274
 
 
275
 
 rb : renderer_base;
276
 
 rs : renderer_scanline_aa_solid;
277
 
 
278
 
 c1 ,c2 ,c3 ,c4 : aggclr;
279
 
 
280
 
begin
281
 
// Initialize structures
282
 
// pixfmt_alpha_blend_rgba(pixf ,rbuf_window ,bgra_order ); {!}
283
 
 pixfmt_bgra32(pixf ,rbuf_window );
284
 
 
285
 
 rb.Construct(@pixf );
286
 
 rs.Construct(@rb );
287
 
 
288
 
 rgba.ConstrInt(255 ,255 ,255 );
289
 
 rb.clear      (@rgba );
290
 
 
291
 
// Render
292
 
 c1.ConstrDbl(0 ,0 ,0 ,m_alpha_dst._value );
293
 
 c2.ConstrDbl(0 ,0 ,1 ,m_alpha_dst._value );
294
 
 c3.ConstrDbl(0 ,1 ,0 ,m_alpha_dst._value );
295
 
 c4.ConstrDbl(1 ,0 ,0 ,0 );
296
 
 
297
 
 generate_color_ramp(@m_ramp1 ,@c1 ,@c2 ,@c3 ,@c4 );
298
 
 
299
 
 c1.ConstrDbl(0 ,0 ,0 ,m_alpha_src._value );
300
 
 c2.ConstrDbl(0 ,0 ,1 ,m_alpha_src._value );
301
 
 c3.ConstrDbl(0 ,1 ,0 ,m_alpha_src._value );
302
 
 c4.ConstrDbl(1 ,0 ,0 ,0 );
303
 
 
304
 
 generate_color_ramp(@m_ramp2 ,@c1 ,@c2 ,@c3 ,@c4 );
305
 
 
306
 
 render_scene(@rb );
307
 
 
308
 
// Render the controls
309
 
 render_ctrl(@m_ras ,@m_sl ,@rs ,@m_alpha_dst );
310
 
 render_ctrl(@m_ras ,@m_sl ,@rs ,@m_alpha_src );
311
 
 render_ctrl(@m_ras ,@m_sl ,@rs ,@m_comp_op );
312
 
 
313
 
end;
314
 
 
315
 
{ ON_KEY }
316
 
procedure the_application.on_key;
317
 
begin
318
 
 if key = key_f1 then
319
 
  message_(
320
 
   'Another demo example with extended compositing modes.    ' );
321
 
 
322
 
end;
323
 
 
324
 
VAR
325
 
 app : the_application;
326
 
 
327
 
BEGIN
328
 
 app.Construct(pix_format_bgra32 ,flip_y );
329
 
 app.caption_ ('AGG Example. Compositing Modes (F1-Help)' );
330
 
 
331
 
 if app.init(600 ,400 ,window_resize or window_keep_aspect_ratio ) then
332
 
  app.run;
333
 
 
334
 
 app.Destruct;
335
 
 
336
 
END.
 
 
b'\\ No newline at end of file'