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

« back to all changes in this revision

Viewing changes to components/aggpas/lion_lens.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_lens ;
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
 
 agg_basics ,
22
 
 agg_platform_support ,
23
 
 
24
 
 agg_ctrl ,
25
 
 agg_slider_ctrl ,
26
 
 
27
 
 agg_rasterizer_scanline_aa ,
28
 
 agg_scanline ,
29
 
 agg_scanline_p ,
30
 
 
31
 
 agg_renderer_base ,
32
 
 agg_renderer_scanline ,
33
 
 agg_render_scanlines ,
34
 
 
35
 
 agg_path_storage ,
36
 
 agg_bounding_rect ,
37
 
 agg_trans_affine ,
38
 
 agg_trans_warp_magnifier ,
39
 
 agg_conv_transform ,
40
 
 agg_conv_segmentator ,
41
 
 parse_lion_
42
 
 
43
 
{$I pixel_formats.inc }
44
 
{$I agg_mode.inc }
45
 
 
46
 
const
47
 
 flip_y = true;
48
 
 
49
 
var
50
 
 g_rasterizer : rasterizer_scanline_aa;
51
 
 g_scanline   : scanline_p8;
52
 
 
53
 
 g_path     : path_storage;
54
 
 g_colors   : array[0..99 ] of aggclr;
55
 
 g_path_idx : array[0..99 ] of unsigned;
56
 
 
57
 
 g_npaths : unsigned;
58
 
 
59
 
 g_x1 ,g_y1 ,g_x2 ,g_y2 ,
60
 
 g_base_dx  ,g_base_dy  ,
61
 
 g_angle    ,g_scale    ,
62
 
 g_skew_x   ,g_skew_y   : double;
63
 
 
64
 
 g_nclick : int;
65
 
 
66
 
type
67
 
 the_application = object(platform_support )
68
 
   m_magn_slider   ,
69
 
   m_radius_slider : slider_ctrl;
70
 
 
71
 
   constructor Construct(format_ : pix_format_e; flip_y_ : boolean );
72
 
   destructor  Destruct;
73
 
 
74
 
   procedure on_init; virtual;
75
 
   procedure on_draw; virtual;
76
 
 
77
 
   procedure on_mouse_move       (x ,y : int; flags : unsigned ); virtual;
78
 
   procedure on_mouse_button_down(x ,y : int; flags : unsigned ); virtual;
79
 
 
80
 
   procedure on_key(x ,y : int; key ,flags : unsigned ); virtual;
81
 
 
82
 
  end;
83
 
 
84
 
{ _PARSE_LION_ }
85
 
procedure _parse_lion_;
86
 
begin
87
 
 g_npaths:=parse_lion(@g_path ,@g_colors ,@g_path_idx );
88
 
 
89
 
 bounding_rect(@g_path ,@g_path_idx ,0 ,g_npaths ,@g_x1 ,@g_y1 ,@g_x2 ,@g_y2 );
90
 
 
91
 
 g_base_dx:=(g_x2 - g_x1 ) / 2.0;
92
 
 g_base_dy:=(g_y2 - g_y1 ) / 2.0;
93
 
 
94
 
end;
95
 
 
96
 
{ CONSTRUCT }
97
 
constructor the_application.Construct;
98
 
begin
99
 
 inherited Construct(format_ ,flip_y_ );
100
 
 
101
 
 m_magn_slider.Construct  (5 ,5  ,495 ,12 ,not flip_y_ );
102
 
 m_radius_slider.Construct(5 ,20 ,495 ,27 ,not flip_y_ );
103
 
 
104
 
 _parse_lion_;
105
 
 
106
 
 add_ctrl(@m_magn_slider );
107
 
 
108
 
 m_magn_slider.no_transform;
109
 
 m_magn_slider.range_(0.01 ,4.0 );
110
 
 m_magn_slider.value_(3.0 );
111
 
 m_magn_slider.label_('Scale=%3.2f' );
112
 
 
113
 
 add_ctrl(@m_radius_slider );
114
 
 
115
 
 m_radius_slider.no_transform;
116
 
 m_radius_slider.range_(0.0 ,100.0 );
117
 
 m_radius_slider.value_(70.0 );
118
 
 m_radius_slider.label_('Radius=%3.2f' );
119
 
 
120
 
end;
121
 
 
122
 
{ DESTRUCT }
123
 
destructor the_application.Destruct;
124
 
begin
125
 
 inherited Destruct;
126
 
 
127
 
 m_magn_slider.Destruct;
128
 
 m_radius_slider.Destruct;
129
 
 
130
 
end;
131
 
 
132
 
{ ON_INIT }
133
 
procedure the_application.on_init;
134
 
begin
135
 
 g_x1:=200;
136
 
 g_y1:=150;
137
 
 
138
 
end;
139
 
 
140
 
{ ON_DRAW }
141
 
procedure the_application.on_draw;
142
 
var
143
 
 pixf : pixel_formats;
144
 
 
145
 
 rb : renderer_base;
146
 
 r  : renderer_scanline_aa_solid;
147
 
 
148
 
 rgba : aggclr;
149
 
 
150
 
 lens : trans_warp_magnifier;
151
 
 segm : conv_segmentator;
152
 
 
153
 
 mtx : trans_affine;
154
 
 tat : trans_affine_translation;
155
 
 tar : trans_affine_rotation;
156
 
 
157
 
 trans_mtx  ,
158
 
 trans_lens : conv_transform;
159
 
 
160
 
begin
161
 
// Initialize structures
162
 
 pixfmt(pixf ,rbuf_window );
163
 
 
164
 
 rb.Construct(@pixf );
165
 
 r.Construct (@rb );
166
 
 
167
 
 rgba.ConstrDbl(1 ,1 ,1 );
168
 
 rb.clear      (@rgba );
169
 
 
170
 
// Transform lion
171
 
 lens.Construct;
172
 
 lens.center       (g_x1 ,g_y1 );
173
 
 lens.magnification(m_magn_slider._value );
174
 
 lens.radius       (m_radius_slider._value / m_magn_slider._value );
175
 
 
176
 
 segm.Construct(@g_path );
177
 
 mtx.Construct;
178
 
 
179
 
 tat.Construct(-g_base_dx ,-g_base_dy );
180
 
 mtx.multiply (@tat );
181
 
 
182
 
 tar.Construct(g_angle + pi );
183
 
 mtx.multiply (@tar );
184
 
 
185
 
 tat.Construct(_width / 2 ,_height / 2);
186
 
 mtx.multiply (@tat );
187
 
 
188
 
 trans_mtx.Construct (@segm ,@mtx );
189
 
 trans_lens.Construct(@trans_mtx ,@lens );
190
 
 
191
 
 render_all_paths(@g_rasterizer ,@g_scanline ,@r ,@trans_lens ,@g_colors ,@g_path_idx ,g_npaths );
192
 
 
193
 
// Render the controls
194
 
 render_ctrl(@g_rasterizer ,@g_scanline ,@r ,@m_magn_slider );
195
 
 render_ctrl(@g_rasterizer ,@g_scanline ,@r ,@m_radius_slider );
196
 
 
197
 
// Free
198
 
 segm.Destruct;
199
 
 
200
 
end;
201
 
 
202
 
{ ON_MOUSE_MOVE }
203
 
procedure the_application.on_mouse_move;
204
 
begin
205
 
 on_mouse_button_down(x ,y ,flags );
206
 
 
207
 
end;
208
 
 
209
 
{ ON_MOUSE_BUTTON_DOWN }
210
 
procedure the_application.on_mouse_button_down;
211
 
begin
212
 
 if flags and mouse_left <> 0 then
213
 
  begin
214
 
   g_x1:=x;
215
 
   g_y1:=y;
216
 
 
217
 
   force_redraw;
218
 
 
219
 
  end;
220
 
 
221
 
 if flags and mouse_right <> 0 then
222
 
  begin
223
 
   g_x2:=x;
224
 
   g_y2:=y;
225
 
 
226
 
   force_redraw;
227
 
 
228
 
  end;
229
 
 
230
 
end;
231
 
 
232
 
{ ON_KEY }
233
 
procedure the_application.on_key;
234
 
begin
235
 
 if key = key_f1 then
236
 
  message_(
237
 
   'This example exhibits a non-linear transformer that "magnifies" vertices that fall '#13 +
238
 
   'inside a circle and extends the rest (trans_warp_magnifier). Non-linear transformations '#13 +
239
 
   'are tricky because straight lines become curves. To achieve the correct result we need '#13 +
240
 
   'to divide long line segments into short ones. The example also demonstrates the use of '#13 +
241
 
   'conv_segmentator that does this division job. The transformer can also shrink away '#13 +
242
 
   'the image if the scaling value is less than 1.'#13#13 +
243
 
   'How to play with:'#13#13 +
244
 
   'Drag the center of the "lens" with the left mouse button and change the "Scale" and "Radius".   '#13 +
245
 
   'To watch for an amazing effect, set the scale to the minimum (0.01), decrease the radius '#13 +
246
 
   'to about 1 and drag the "lens". You will see it behaves like a black hole consuming space '#13 +
247
 
   'around it. Move the lens somewhere to the side of the window and change the radius. It looks '#13 +
248
 
   'like changing the event horizon of the "black hole".' +
249
 
   #13#13'Note: F2 key saves current "screenshot" file in this demo''s directory.  ' );
250
 
 
251
 
end;
252
 
 
253
 
VAR
254
 
 app : the_application;
255
 
 
256
 
BEGIN
257
 
// Rendering
258
 
 g_rasterizer.Construct;
259
 
 g_scanline.Construct;
260
 
 g_path.Construct;
261
 
 
262
 
 g_npaths:=0;
263
 
 
264
 
 g_x1:=0;
265
 
 g_y1:=0;
266
 
 g_x2:=0;
267
 
 g_y2:=0;
268
 
 
269
 
 g_base_dx:=0;
270
 
 g_base_dy:=0;
271
 
 
272
 
 g_angle:=0;
273
 
 g_scale:=1.0;
274
 
 
275
 
 g_skew_x:=0;
276
 
 g_skew_y:=0;
277
 
 g_nclick:=0;
278
 
 
279
 
// App
280
 
 app.Construct(pix_format ,flip_y );
281
 
 app.caption_ ('AGG Example. Lion (F1-Help)' );
282
 
 
283
 
 if app.init(500 ,600 ,window_resize ) then
284
 
  app.run;
285
 
 
286
 
 app.Destruct;
287
 
 
288
 
// Free
289
 
 g_rasterizer.Destruct;
290
 
 g_scanline.Destruct;
291
 
 g_path.Destruct;
292
 
 
293
 
END.
 
 
b'\\ No newline at end of file'