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

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_2D.pas

  • 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
 
// Agg2D - Version 1.0
3
 
// Based on Anti-Grain Geometry
4
 
// Copyright (C) 2005 Maxim Shemanarev (http://www.antigrain.com)
5
 
//
6
 
// Agg2D - Version 1.0 Release Milano 3 (AggPas 2.3 RM3)
7
 
// Pascal Port By: Milan Marusinec alias Milano
8
 
//                 milan@marusinec.sk
9
 
//                 http://www.aggpas.org
10
 
// Copyright (c) 2007
11
 
//
12
 
// Permission to copy, use, modify, sell and distribute this software
13
 
// is granted provided this copyright notice appears in all copies.
14
 
// This software is provided "as is" without express or implied
15
 
// warranty, and with no claim as to its suitability for any purpose.
16
 
//
17
 
//----------------------------------------------------------------------------
18
 
// Contact: mcseem@antigrain.com
19
 
//          mcseemagg@yahoo.com
20
 
//          http://www.antigrain.com
21
 
//
22
 
// [Pascal Port History] -----------------------------------------------------
23
 
//
24
 
// 22.08.2007-Milano: Unit port establishment
25
 
// 23.08.2007-Milano: Porting
26
 
// 11.09.2007-Milano: -"-
27
 
// 13.09.2007-Milano: -"-, Finished OK
28
 
//
29
 
{ agg_2D.pas }
30
 
unit
31
 
 agg_2D ;
32
 
 
33
 
INTERFACE
34
 
 
35
 
{$I agg_mode.inc }
36
 
 
37
 
// With this define uncommented you can use FreeType font engine
38
 
{ $DEFINE AGG2D_USE_FREETYPE }
39
 
 
40
 
uses
41
 
 agg_basics ,
42
 
 agg_array ,
43
 
 agg_trans_affine ,
44
 
 agg_trans_viewport ,
45
 
 agg_path_storage ,
46
 
 agg_conv_stroke ,
47
 
 agg_conv_transform ,
48
 
 agg_conv_curve ,
49
 
 agg_rendering_buffer ,
50
 
 agg_renderer_base ,
51
 
 agg_renderer_scanline ,
52
 
 agg_span_gradient ,
53
 
 agg_span_image_filter_rgba ,
54
 
 agg_span_image_resample_rgba ,
55
 
 agg_span_converter ,
56
 
 agg_span_interpolator_linear ,
57
 
 agg_span_allocator ,
58
 
 agg_rasterizer_scanline_aa ,
59
 
 agg_gamma_functions ,
60
 
 agg_scanline_u ,
61
 
 agg_arc ,
62
 
 agg_bezier_arc ,
63
 
 agg_rounded_rect ,
64
 
 agg_font_engine ,
65
 
 agg_font_cache_manager ,
66
 
 agg_pixfmt ,
67
 
 agg_pixfmt_rgba ,
68
 
 agg_color ,
69
 
 agg_math_stroke ,
70
 
 agg_image_filters ,
71
 
 agg_vertex_source ,
72
 
 agg_render_scanlines ,
73
 
 
74
 
{$IFDEF AGG2D_USE_FREETYPE }
75
 
 agg_font_freetype ,
76
 
 
77
 
{$ENDIF }
78
 
{$IFDEF AGG2D_USE_WINFONTS}
79
 
 agg_font_win32_tt ,
80
 
 Windows ,
81
 
 
82
 
{$ENDIF }
83
 
 
84
 
 Math ;
85
 
 
86
 
{ GLOBAL VARIABLES & CONSTANTS }
87
 
const
88
 
// LineJoin
89
 
 JoinMiter = miter_join;
90
 
 JoinRound = round_join;
91
 
 JoinBevel = bevel_join;
92
 
 
93
 
// LineCap
94
 
 CapButt   = butt_cap;
95
 
 CapSquare = square_cap;
96
 
 CapRound  = round_cap;
97
 
 
98
 
// TextAlignment
99
 
 AlignLeft   = 0;
100
 
 AlignRight  = 1;
101
 
 AlignCenter = 2;
102
 
 AlignTop    = AlignRight;
103
 
 AlignBottom = AlignLeft;
104
 
 
105
 
// BlendMode
106
 
 BlendAlpha      = end_of_comp_op_e;
107
 
 BlendClear      = comp_op_clear;
108
 
 BlendSrc        = comp_op_src;
109
 
 BlendDst        = comp_op_dst;
110
 
 BlendSrcOver    = comp_op_src_over;
111
 
 BlendDstOver    = comp_op_dst_over;
112
 
 BlendSrcIn      = comp_op_src_in;
113
 
 BlendDstIn      = comp_op_dst_in;
114
 
 BlendSrcOut     = comp_op_src_out;
115
 
 BlendDstOut     = comp_op_dst_out;
116
 
 BlendSrcAtop    = comp_op_src_atop;
117
 
 BlendDstAtop    = comp_op_dst_atop;
118
 
 BlendXor        = comp_op_xor;
119
 
 BlendAdd        = comp_op_plus;
120
 
 BlendSub        = comp_op_minus;
121
 
 BlendMultiply   = comp_op_multiply;
122
 
 BlendScreen     = comp_op_screen;
123
 
 BlendOverlay    = comp_op_overlay;
124
 
 BlendDarken     = comp_op_darken;
125
 
 BlendLighten    = comp_op_lighten;
126
 
 BlendColorDodge = comp_op_color_dodge;
127
 
 BlendColorBurn  = comp_op_color_burn;
128
 
 BlendHardLight  = comp_op_hard_light;
129
 
 BlendSoftLight  = comp_op_soft_light;
130
 
 BlendDifference = comp_op_difference;
131
 
 BlendExclusion  = comp_op_exclusion;
132
 
 BlendContrast   = comp_op_contrast;
133
 
 
134
 
{ TYPES DEFINITION }
135
 
type
136
 
 Color_ptr = ^Color;
137
 
 Color     = rgba8;
138
 
 
139
 
 Rect_ = agg_basics.rect;
140
 
 RectD = agg_basics.rect_d;
141
 
 
142
 
 Affine     = trans_affine;
143
 
 Affine_ptr = trans_affine_ptr;
144
 
 
145
 
 FontRasterizer     = gray8_adaptor_type;
146
 
 FontRasterizer_ptr = gray8_adaptor_type_ptr;
147
 
 
148
 
 FontScanline     = gray8_scanline_type;
149
 
 FontScanline_ptr = gray8_scanline_type_ptr;
150
 
 
151
 
{$IFDEF AGG2D_USE_FREETYPE }
152
 
 FontEngine = font_engine_freetype_int32;
153
 
 
154
 
{$ENDIF }
155
 
{$IFDEF AGG2D_USE_WINFONTS}
156
 
 FontEngine = font_engine_win32_tt_int32;
157
 
 
158
 
{$ENDIF }
159
 
 
160
 
 Gradient  = (Solid ,Linear ,Radial );
161
 
 Direction = (CW, CCW );
162
 
 
163
 
 LineJoin_  = int;
164
 
 LineCap_   = int;
165
 
 BlendMode_ = comp_op_e;
166
 
 
167
 
 TextAlignment = int;
168
 
 
169
 
 DrawPathFlag = (
170
 
  FillOnly ,
171
 
  StrokeOnly ,
172
 
  FillAndStroke ,
173
 
  FillWithLineColor );
174
 
 
175
 
 ViewportOption = (
176
 
  Anisotropic ,
177
 
  XMinYMin ,
178
 
  XMidYMin ,
179
 
  XMaxYMin ,
180
 
  XMinYMid ,
181
 
  XMidYMid ,
182
 
  XMaxYMid ,
183
 
  XMinYMax ,
184
 
  XMidYMax ,
185
 
  XMaxYMax );
186
 
 
187
 
 ImageFilter_ = (
188
 
  NoFilter ,
189
 
  Bilinear ,
190
 
  Hanning ,
191
 
  Hermite ,
192
 
  Quadric ,
193
 
  Bicubic ,
194
 
  Catrom ,
195
 
  Spline16 ,
196
 
  Spline36 ,
197
 
  Blackman144 );
198
 
 
199
 
 ImageResample_ = (
200
 
  NoResample ,
201
 
  ResampleAlways ,
202
 
  ResampleOnZoomOut );
203
 
 
204
 
 FontCacheType = (
205
 
  RasterFontCache ,
206
 
  VectorFontCache );
207
 
 
208
 
 Transformations_ptr = ^Transformations_;
209
 
 Transformations_ = record
210
 
   affineMatrix : array[0..5 ] of double;
211
 
 
212
 
  end;
213
 
 
214
 
 Image_ptr = ^Image;
215
 
 Image = object
216
 
   renBuf : rendering_buffer;
217
 
 
218
 
   constructor Construct; overload;
219
 
   constructor Construct(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int ); overload;
220
 
   destructor  Destruct;
221
 
 
222
 
   procedure attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
223
 
 
224
 
   function  width : int;
225
 
   function  height : int;
226
 
 
227
 
   procedure premultiply;
228
 
   procedure demultiply;
229
 
 
230
 
  end;
231
 
 
232
 
 Agg2DRasterizerGamma = object(vertex_source )
233
 
   m_alpha : gamma_multiply;
234
 
   m_gamma : gamma_power;
235
 
 
236
 
   constructor Construct(alpha ,gamma : double );
237
 
 
238
 
   function func_operator_gamma(x : double ) : double; virtual;
239
 
 
240
 
  end;
241
 
 
242
 
 Agg2D_ptr = ^Agg2D;
243
 
 Agg2D = object
244
 
  private
245
 
   m_rbuf : rendering_buffer;
246
 
 
247
 
   m_pixFormat ,m_pixFormatComp ,m_pixFormatPre ,m_pixFormatCompPre : pixel_formats;
248
 
   m_renBase   ,m_renBaseComp   ,m_renBasePre   ,m_renBaseCompPre   : renderer_base;
249
 
 
250
 
   m_renSolid ,m_renSolidComp : renderer_scanline_aa_solid;
251
 
 
252
 
   m_allocator : span_allocator;
253
 
   m_clipBox   : RectD;
254
 
 
255
 
   m_blendMode ,m_imageBlendMode : BlendMode_;
256
 
 
257
 
   m_imageBlendColor : Color;
258
 
 
259
 
   m_scanline   : scanline_u8;
260
 
   m_rasterizer : rasterizer_scanline_aa;
261
 
 
262
 
   m_masterAlpha ,m_antiAliasGamma : double;
263
 
 
264
 
   m_fillColor ,m_lineColor : Color;
265
 
 
266
 
   m_fillGradient ,m_lineGradient : pod_auto_array;
267
 
 
268
 
   m_lineCap  : LineCap_;
269
 
   m_lineJoin : LineJoin_;
270
 
 
271
 
   m_fillGradientFlag ,m_lineGradientFlag : Gradient;
272
 
 
273
 
   m_fillGradientMatrix ,m_lineGradientMatrix : trans_affine;
274
 
 
275
 
   m_fillGradientD1 ,
276
 
   m_lineGradientD1 ,
277
 
   m_fillGradientD2 ,
278
 
   m_lineGradientD2 ,
279
 
   m_textAngle      : double;
280
 
   m_textAlignX     ,
281
 
   m_textAlignY     : TextAlignment;
282
 
   m_textHints      : boolean;
283
 
   m_fontHeight     ,
284
 
   m_fontAscent     ,
285
 
   m_fontDescent    : double;
286
 
   m_fontCacheType  : FontCacheType;
287
 
 
288
 
   m_imageFilter    : ImageFilter_;
289
 
   m_imageResample  : ImageResample_;
290
 
   m_imageFilterLut : image_filter_lut;
291
 
 
292
 
   m_fillGradientInterpolator ,
293
 
   m_lineGradientInterpolator : span_interpolator_linear;
294
 
 
295
 
   m_linearGradientFunction : gradient_x;
296
 
   m_radialGradientFunction : gradient_circle;
297
 
 
298
 
   m_lineWidth   : double;
299
 
   m_evenOddFlag : boolean;
300
 
 
301
 
   m_path      : path_storage;
302
 
   m_transform : trans_affine;
303
 
 
304
 
   m_convCurve  : conv_curve;
305
 
   m_convStroke : conv_stroke;
306
 
 
307
 
   m_pathTransform ,m_strokeTransform : conv_transform;
308
 
 
309
 
  {$IFNDEF AGG2D_NO_FONT}
310
 
   m_fontEngine       : FontEngine;
311
 
   m_fontCacheManager : font_cache_manager;
312
 
  {$ENDIF}
313
 
  {$IFDEF AGG2D_USE_WINFONTS }
314
 
   m_fontDC : HDC;
315
 
  {$ENDIF }
316
 
 
317
 
  // Other Pascal-specific members
318
 
   m_gammaNone  : gamma_none;
319
 
   m_gammaAgg2D : Agg2DRasterizerGamma;
320
 
 
321
 
   m_ifBilinear    : image_filter_bilinear;
322
 
   m_ifHanning     : image_filter_hanning;
323
 
   m_ifHermite     : image_filter_hermite;
324
 
   m_ifQuadric     : image_filter_quadric;
325
 
   m_ifBicubic     : image_filter_bicubic;
326
 
   m_ifCatrom      : image_filter_catrom;
327
 
   m_ifSpline16    : image_filter_spline16;
328
 
   m_ifSpline36    : image_filter_spline36;
329
 
   m_ifBlackman144 : image_filter_blackman144;
330
 
 
331
 
  public
332
 
   constructor Construct;
333
 
   destructor  Destruct;
334
 
 
335
 
  // Setup
336
 
   procedure attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int ); overload;
337
 
   procedure attach(img : Image_ptr ); overload;
338
 
 
339
 
   procedure clipBox(x1 ,y1 ,x2 ,y2 : double ); overload;
340
 
   function  clipBox : RectD; overload;
341
 
 
342
 
   procedure clearAll(c : Color ); overload;
343
 
   procedure clearAll(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
344
 
 
345
 
   procedure clearClipBox(c : Color ); overload;
346
 
   procedure clearClipBox(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
347
 
 
348
 
  // Conversions
349
 
   procedure worldToScreen(x ,y : double_ptr ); overload;
350
 
   procedure screenToWorld(x ,y : double_ptr ); overload;
351
 
   function  worldToScreen(scalar : double ) : double; overload;
352
 
   function  screenToWorld(scalar : double ) : double; overload;
353
 
 
354
 
   procedure alignPoint(x ,y : double_ptr );
355
 
 
356
 
   function  inBox(worldX ,worldY : double ) : boolean;
357
 
 
358
 
  // General Attributes
359
 
   procedure blendMode(m : BlendMode_ ); overload;
360
 
   function  blendMode : BlendMode_; overload;
361
 
 
362
 
   procedure imageBlendMode(m : BlendMode_ ); overload;
363
 
   function  imageBlendMode : BlendMode_; overload;
364
 
 
365
 
   procedure imageBlendColor(c : Color ); overload;
366
 
   procedure imageBlendColor(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
367
 
   function  imageBlendColor : Color; overload;
368
 
 
369
 
   procedure masterAlpha(a : double ); overload;
370
 
   function  masterAlpha : double; overload;
371
 
 
372
 
   procedure antiAliasGamma(g : double ); overload;
373
 
   function  antiAliasGamma : double; overload;
374
 
 
375
 
   procedure fillColor(c : Color ); overload;
376
 
   procedure fillColor(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
377
 
   procedure noFill;
378
 
 
379
 
   procedure lineColor(c : Color ); overload;
380
 
   procedure lineColor(r ,g ,b : unsigned; a : unsigned = 255 ); overload;
381
 
   procedure noLine;
382
 
 
383
 
   function  fillColor : Color; overload;
384
 
   function  lineColor : Color; overload;
385
 
 
386
 
   procedure fillLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
387
 
   procedure lineLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
388
 
 
389
 
   procedure fillRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 ); overload;
390
 
   procedure lineRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 ); overload;
391
 
 
392
 
   procedure fillRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color ); overload;
393
 
   procedure lineRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color ); overload;
394
 
 
395
 
   procedure fillRadialGradient(x ,y ,r : double ); overload;
396
 
   procedure lineRadialGradient(x ,y ,r : double ); overload;
397
 
 
398
 
   procedure lineWidth (w : double );
399
 
   function  lineWidth_(w : double ) : double;
400
 
 
401
 
   procedure lineCap(cap : LineCap_ ); overload;
402
 
   function  lineCap : LineCap_; overload;
403
 
 
404
 
   procedure lineJoin(join : LineJoin_ ); overload;
405
 
   function  lineJoin : LineJoin_; overload;
406
 
 
407
 
   procedure fillEvenOdd(evenOddFlag : boolean ); overload;
408
 
   function  fillEvenOdd : boolean; overload;
409
 
 
410
 
  // Transformations
411
 
   function  transformations : Transformations_; overload;
412
 
   procedure transformations(tr : Transformations_ptr ); overload;
413
 
   procedure resetTransformations;
414
 
 
415
 
   procedure affine(tr : Affine_ptr ); overload;
416
 
   procedure affine(tr : Transformations_ptr ); overload;
417
 
 
418
 
   procedure rotate   (angle : double );
419
 
   procedure scale    (sx ,sy : double );
420
 
   procedure skew     (sx ,sy : double );
421
 
   procedure translate(x ,y : double );
422
 
 
423
 
   procedure parallelogram(x1 ,y1 ,x2 ,y2 : double; para : double_ptr );
424
 
 
425
 
   procedure viewport(
426
 
              worldX1  ,worldY1  ,worldX2  ,worldY2 ,
427
 
              screenX1 ,screenY1 ,screenX2 ,screenY2 : double;
428
 
              opt : ViewportOption = XMidYMid );
429
 
 
430
 
  // Basic Shapes
431
 
   procedure line     (x1 ,y1 ,x2 ,y2 : double );
432
 
   procedure triangle (x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
433
 
   procedure rectangle(x1 ,y1 ,x2 ,y2 : double );
434
 
 
435
 
   procedure roundedRect(x1 ,y1 ,x2 ,y2 ,r : double ); overload;
436
 
   procedure roundedRect(x1 ,y1 ,x2 ,y2 ,rx ,ry : double ); overload;
437
 
   procedure roundedRect(
438
 
              x1 ,y1 ,x2 ,y2 ,
439
 
              rxBottom ,ryBottom ,
440
 
              rxTop ,ryTop : double ); overload;
441
 
 
442
 
   procedure ellipse(cx ,cy ,rx ,ry : double );
443
 
             
444
 
   procedure arc (cx ,cy ,rx ,ry ,start ,sweep : double );
445
 
   procedure star(cx ,cy ,r1 ,r2 ,startAngle : double; numRays : int );
446
 
 
447
 
   procedure curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double ); overload;
448
 
   procedure curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 ,x4 ,y4 : double ); overload;
449
 
 
450
 
   procedure polygon (xy : double_ptr; numPoints : int );
451
 
   procedure polyline(xy : double_ptr; numPoints : int );
452
 
 
453
 
  // Text
454
 
   procedure flipText(flip : boolean );
455
 
 
456
 
   procedure font(
457
 
              fileName : char_ptr; height : double;
458
 
              bold : boolean = false;
459
 
              italic : boolean = false;
460
 
              ch : FontCacheType = RasterFontCache;
461
 
              angle : double = 0.0 );
462
 
 
463
 
   function  fontHeight : double;
464
 
 
465
 
   procedure textAlignment(alignX ,alignY : TextAlignment );
466
 
 
467
 
   function  textHints : boolean; overload;
468
 
   procedure textHints(hints : boolean ); overload;
469
 
   function  textWidth(str : char_ptr ) : double;
470
 
 
471
 
   procedure text(
472
 
              x ,y : double; str : char_ptr;
473
 
              roundOff : boolean = false;
474
 
              ddx : double = 0.0;
475
 
              ddy : double = 0.0 );
476
 
 
477
 
  // Path commands
478
 
   procedure resetPath;
479
 
 
480
 
   procedure moveTo (x ,y : double );
481
 
   procedure moveRel(dx ,dy : double );
482
 
 
483
 
   procedure lineTo (x ,y : double );
484
 
   procedure lineRel(dx ,dy : double );
485
 
 
486
 
   procedure horLineTo (x : double );
487
 
   procedure horLineRel(dx : double );
488
 
 
489
 
   procedure verLineTo (y : double );
490
 
   procedure verLineRel(dy : double );
491
 
 
492
 
   procedure arcTo(
493
 
              rx ,ry ,angle : double;
494
 
              largeArcFlag ,sweepFlag : boolean;
495
 
              x ,y : double );
496
 
 
497
 
   procedure arcRel(
498
 
              rx ,ry ,angle : double;
499
 
              largeArcFlag ,sweepFlag : boolean;
500
 
              dx ,dy : double );
501
 
 
502
 
   procedure quadricCurveTo (xCtrl ,yCtrl ,xTo ,yTo : double ); overload;
503
 
   procedure quadricCurveRel(dxCtrl ,dyCtrl ,dxTo ,dyTo : double ); overload;
504
 
   procedure quadricCurveTo (xTo ,yTo : double ); overload;
505
 
   procedure quadricCurveRel(dxTo ,dyTo : double ); overload;
506
 
 
507
 
   procedure cubicCurveTo (xCtrl1 ,yCtrl1 ,xCtrl2 ,yCtrl2 ,xTo ,yTo : double ); overload;
508
 
   procedure cubicCurveRel(dxCtrl1 ,dyCtrl1 ,dxCtrl2 ,dyCtrl2 ,dxTo ,dyTo : double ); overload;
509
 
   procedure cubicCurveTo (xCtrl2 ,yCtrl2 ,xTo ,yTo : double ); overload;
510
 
   procedure cubicCurveRel(xCtrl2 ,yCtrl2 ,xTo ,yTo : double ); overload;
511
 
 
512
 
   procedure addEllipse(cx ,cy ,rx ,ry : double; dir : Direction );
513
 
   procedure closePolygon;
514
 
 
515
 
   procedure drawPath(flag : DrawPathFlag = FillAndStroke );
516
 
 
517
 
   procedure drawPathNoTransform(flag : DrawPathFlag = FillAndStroke );
518
 
 
519
 
  // Image Transformations
520
 
   procedure imageFilter(f : ImageFilter_ ); overload;
521
 
   function  imageFilter : ImageFilter_; overload;
522
 
 
523
 
   procedure imageResample(f : ImageResample_ ); overload;
524
 
   function  imageResample : ImageResample_; overload;
525
 
 
526
 
   procedure transformImage(
527
 
              img : Image_ptr;
528
 
              imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
529
 
              dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
530
 
 
531
 
   procedure transformImage(
532
 
              img : Image_ptr;
533
 
              dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
534
 
 
535
 
   procedure transformImage(
536
 
              img : Image_ptr;
537
 
              imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
538
 
              parallelogram_ : double_ptr ); overload;
539
 
 
540
 
   procedure transformImage(img : Image_ptr; parallelogram_ : double_ptr ); overload;
541
 
 
542
 
   procedure transformImagePath(
543
 
              img : Image_ptr;
544
 
              imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
545
 
              dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
546
 
 
547
 
   procedure transformImagePath(
548
 
              img : Image_ptr;
549
 
              dstX1 ,dstY1 ,dstX2 ,dstY2 : double ); overload;
550
 
 
551
 
   procedure transformImagePath(
552
 
              img : Image_ptr;
553
 
              imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
554
 
              parallelogram_ : double_ptr ); overload;
555
 
 
556
 
   procedure transformImagePath(img : Image_ptr; parallelogram_ : double_ptr ); overload;
557
 
 
558
 
  // Image Blending (no transformations available)
559
 
   procedure blendImage(
560
 
              img : Image_ptr;
561
 
              imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
562
 
              dstX ,dstY : double; alpha : unsigned = 255 ); overload;
563
 
 
564
 
   procedure blendImage(img : Image_ptr; dstX ,dstY : double; alpha : unsigned = 255 ); overload;
565
 
 
566
 
  // Copy image directly, together with alpha-channel
567
 
   procedure copyImage(
568
 
              img : Image_ptr;
569
 
              imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
570
 
              dstX ,dstY : double ); overload;
571
 
 
572
 
   procedure copyImage(img : Image_ptr; dstX ,dstY : double ); overload;
573
 
 
574
 
  private
575
 
   procedure render(fillColor_ : boolean ); overload;
576
 
   procedure render(ras : FontRasterizer_ptr; sl : FontScanline_ptr ); overload;
577
 
 
578
 
   procedure addLine(x1 ,y1 ,x2 ,y2 : double );
579
 
   procedure updateRasterizerGamma;
580
 
   procedure renderImage(
581
 
              img : Image_ptr;
582
 
              x1 ,y1 ,x2 ,y2 : int;
583
 
              parl : double_ptr );
584
 
 
585
 
  end;
586
 
 
587
 
 SpanConvImageBlend_ptr = ^SpanConvImageBlend;
588
 
 SpanConvImageBlend = object(span_convertor )
589
 
  private
590
 
   m_mode  : BlendMode_;
591
 
   m_color : Color;
592
 
   m_pixel : pixel_formats_ptr; // m_pixFormatCompPre
593
 
 
594
 
  public
595
 
   constructor Construct(m : BlendMode_; c : Color; p : pixel_formats_ptr );
596
 
 
597
 
   procedure convert(span : aggclr_ptr; x ,y : int; len : unsigned ); virtual;
598
 
 
599
 
  end;
600
 
 
601
 
{ GLOBAL PROCEDURES }
602
 
// Auxiliary
603
 
 function  pi : double;
604
 
 function  deg2Rad(v : double ) : double;
605
 
 function  rad2Deg(v : double ) : double;
606
 
 
607
 
 function  operator_is_equal    (c1 ,c2 : Color_ptr ) : boolean;
608
 
 function  operator_is_not_equal(c1 ,c2 : Color_ptr ) : boolean;
609
 
 
610
 
 procedure Agg2DRenderer_render(
611
 
            gr : Agg2D_ptr;
612
 
            renBase : renderer_base_ptr;
613
 
            renSolid : renderer_scanline_aa_solid_ptr;
614
 
            fillColor_ : boolean ); overload;
615
 
 
616
 
 procedure Agg2DRenderer_render(
617
 
            gr : Agg2D_ptr;
618
 
            renBase : renderer_base_ptr;
619
 
            renSolid : renderer_scanline_aa_solid_ptr;
620
 
            ras : gray8_adaptor_type_ptr;
621
 
            sl : gray8_scanline_type_ptr ); overload;
622
 
 
623
 
 procedure Agg2DRenderer_renderImage(
624
 
            gr : Agg2D_ptr;
625
 
            img : Image_ptr;
626
 
            renBase : renderer_base_ptr;
627
 
            interpolator : span_interpolator_linear_ptr );
628
 
 
629
 
 function  Agg2DUsesFreeType : boolean;
630
 
 function  Agg2DUsesWin32TrueType : boolean;
631
 
 
632
 
IMPLEMENTATION
633
 
{ LOCAL VARIABLES & CONSTANTS }
634
 
var
635
 
 g_approxScale : double = 2.0;
636
 
 
637
 
{ UNIT IMPLEMENTATION }
638
 
{ CONSTRUCT }
639
 
constructor Image.Construct;
640
 
begin
641
 
end;
642
 
 
643
 
{ CONSTRUCT }
644
 
constructor Image.Construct(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
645
 
begin
646
 
 renBuf.Construct(buf ,width_ ,height_ ,stride );
647
 
 
648
 
end;
649
 
 
650
 
{ DESTRUCT }
651
 
destructor Image.Destruct;
652
 
begin
653
 
 renBuf.Destruct;
654
 
 
655
 
end;
656
 
 
657
 
{ ATTACH }
658
 
procedure Image.attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
659
 
begin
660
 
 renBuf.attach(buf ,width_ ,height_ ,stride );
661
 
 
662
 
end;
663
 
 
664
 
{ WIDTH }
665
 
function Image.width : int;
666
 
begin
667
 
 result:=renBuf._width;
668
 
 
669
 
end;
670
 
 
671
 
{ HEIGHT }
672
 
function Image.height : int;
673
 
begin
674
 
 result:=renBuf._height;
675
 
 
676
 
end;
677
 
 
678
 
{ PREMULTIPLY }
679
 
procedure Image.premultiply;
680
 
var
681
 
 pixf : pixel_formats;
682
 
 
683
 
begin
684
 
{ pixfmt_rgba32(pixf ,@renBuf );
685
 
 
686
 
 pixf.premultiply; {!}
687
 
 
688
 
end;
689
 
 
690
 
{ DEMULTIPLY }
691
 
procedure Image.demultiply;
692
 
var
693
 
 pixf : pixel_formats;
694
 
 
695
 
begin
696
 
{ pixfmt_rgba32(pixf ,@renBuf );
697
 
 
698
 
 pixf.demultiply; {!}
699
 
 
700
 
end;
701
 
 
702
 
{ CONSTRUCT }
703
 
constructor Agg2DRasterizerGamma.Construct(alpha ,gamma : double );
704
 
begin
705
 
 m_alpha.Construct(alpha );
706
 
 m_gamma.Construct(gamma );
707
 
 
708
 
end;
709
 
 
710
 
{ FUNC_OPERATOR_GAMMA }
711
 
function Agg2DRasterizerGamma.func_operator_gamma(x : double ) : double;
712
 
begin
713
 
 result:=m_alpha.func_operator_gamma(m_gamma.func_operator_gamma(x ) );
714
 
 
715
 
end;
716
 
 
717
 
{ CONSTRUCT }
718
 
constructor Agg2D.Construct;
719
 
begin
720
 
 m_rbuf.Construct;
721
 
 
722
 
 pixfmt_rgba32           (m_pixFormat ,@m_rbuf );
723
 
 pixfmt_custom_blend_rgba(m_pixFormatComp ,@m_rbuf ,@comp_op_adaptor_rgba ,rgba_order );
724
 
 pixfmt_rgba32           (m_pixFormatPre ,@m_rbuf );
725
 
 pixfmt_custom_blend_rgba(m_pixFormatCompPre ,@m_rbuf ,@comp_op_adaptor_rgba ,rgba_order );
726
 
 
727
 
 m_renBase.Construct       (@m_pixFormat );
728
 
 m_renBaseComp.Construct   (@m_pixFormatComp );
729
 
 m_renBasePre.Construct    (@m_pixFormatPre );
730
 
 m_renBaseCompPre.Construct(@m_pixFormatCompPre );
731
 
 
732
 
 m_renSolid.Construct    (@m_renBase );
733
 
 m_renSolidComp.Construct(@m_renBaseComp );
734
 
 
735
 
 m_allocator.Construct;
736
 
 m_clipBox.Construct(0 ,0 ,0 ,0 );
737
 
 
738
 
 m_blendMode     :=BlendAlpha;
739
 
 m_imageBlendMode:=BlendDst;
740
 
 
741
 
 m_imageBlendColor.Construct(0 ,0 ,0 );
742
 
 
743
 
 m_scanline.Construct;
744
 
 m_rasterizer.Construct;
745
 
 
746
 
 m_masterAlpha   :=1.0;
747
 
 m_antiAliasGamma:=1.0;
748
 
 
749
 
 m_fillColor.Construct(255 ,255 ,255 );
750
 
 m_lineColor.Construct(0   ,0   ,0 );
751
 
 
752
 
 m_fillGradient.Construct(256 ,sizeof(aggclr ) );
753
 
 m_lineGradient.Construct(256 ,sizeof(aggclr ) );
754
 
 
755
 
 m_lineCap :=CapRound;
756
 
 m_lineJoin:=JoinRound;
757
 
 
758
 
 m_fillGradientFlag:=Solid;
759
 
 m_lineGradientFlag:=Solid;
760
 
 
761
 
 m_fillGradientMatrix.Construct;
762
 
 m_lineGradientMatrix.Construct;
763
 
 
764
 
 m_fillGradientD1:=0.0;
765
 
 m_lineGradientD1:=0.0;
766
 
 m_fillGradientD2:=100.0;
767
 
 m_lineGradientD2:=100.0;
768
 
 
769
 
 m_textAngle  :=0.0;
770
 
 m_textAlignX :=AlignLeft;
771
 
 m_textAlignY :=AlignBottom;
772
 
 m_textHints  :=true;
773
 
 m_fontHeight :=0.0;
774
 
 m_fontAscent :=0.0;
775
 
 m_fontDescent:=0.0;
776
 
 
777
 
 m_fontCacheType:=RasterFontCache;
778
 
 m_imageFilter  :=Bilinear;
779
 
 m_imageResample:=NoResample;
780
 
 
781
 
 m_gammaNone.Construct;
782
 
 
783
 
 m_ifBilinear.Construct;
784
 
 m_ifHanning.Construct;
785
 
 m_ifHermite.Construct;
786
 
 m_ifQuadric.Construct;
787
 
 m_ifBicubic.Construct;
788
 
 m_ifCatrom.Construct;
789
 
 m_ifSpline16.Construct;
790
 
 m_ifSpline36.Construct;
791
 
 m_ifBlackman144.Construct;
792
 
 
793
 
 m_imageFilterLut.Construct(@m_ifBilinear ,true );
794
 
 
795
 
 m_linearGradientFunction.Construct;
796
 
 m_radialGradientFunction.Construct;
797
 
 
798
 
 m_fillGradientInterpolator.Construct(@m_fillGradientMatrix );
799
 
 m_lineGradientInterpolator.Construct(@m_lineGradientMatrix );
800
 
 
801
 
 m_lineWidth  :=1;
802
 
 m_evenOddFlag:=false;
803
 
 
804
 
 m_path.Construct;
805
 
 m_transform.Construct;
806
 
 
807
 
 m_convCurve.Construct (@m_path );
808
 
 m_convStroke.Construct(@m_convCurve );
809
 
 
810
 
 m_pathTransform.Construct  (@m_convCurve ,@m_transform );
811
 
 m_strokeTransform.Construct(@m_convStroke ,@m_transform );
812
 
 
813
 
{$IFDEF AGG2D_USE_FREETYPE }
814
 
 m_fontEngine.Construct;
815
 
 
816
 
{$ENDIF }
817
 
{$IFDEF AGG2D_USE_WINFONTS}
818
 
 
819
 
 m_fontDC:=GetDC(0 );
820
 
 
821
 
 m_fontEngine.Construct(m_fontDC );
822
 
 
823
 
{$ENDIF }
824
 
{$IFNDEF AGG2D_NO_FONT}
825
 
 m_fontCacheManager.Construct(@m_fontEngine );
826
 
{$ENDIF}
827
 
 
828
 
 
829
 
 lineCap (m_lineCap );
830
 
 lineJoin(m_lineJoin );
831
 
 
832
 
end;
833
 
 
834
 
{ DESTRUCT }
835
 
destructor Agg2D.Destruct;
836
 
begin
837
 
 m_rbuf.Destruct;
838
 
 
839
 
 m_allocator.Destruct;
840
 
 
841
 
 m_scanline.Destruct;
842
 
 m_rasterizer.Destruct;
843
 
 
844
 
 m_fillGradient.Destruct;
845
 
 m_lineGradient.Destruct;
846
 
 
847
 
 m_imageFilterLut.Destruct;
848
 
 m_path.Destruct;
849
 
 
850
 
 m_convCurve.Destruct;
851
 
 m_convStroke.Destruct;
852
 
 
853
 
{$IFNDEF AGG2D_NO_FONT}
854
 
 m_fontEngine.Destruct;
855
 
 m_fontCacheManager.Destruct;
856
 
{$ENDIF}
857
 
{$IFDEF AGG2D_USE_WINFONTS }
858
 
 ReleaseDC(0 ,m_fontDC );
859
 
 
860
 
{$ENDIF }
861
 
 
862
 
end;
863
 
 
864
 
{ ATTACH }
865
 
procedure Agg2D.attach(buf : int8u_ptr; width_ ,height_ : unsigned; stride : int );
866
 
begin
867
 
 m_rbuf.attach(buf ,width_ ,height_ ,stride );
868
 
 
869
 
 m_renBase.reset_clipping       (true );
870
 
 m_renBaseComp.reset_clipping   (true );
871
 
 m_renBasePre.reset_clipping    (true );
872
 
 m_renBaseCompPre.reset_clipping(true );
873
 
 
874
 
 resetTransformations;
875
 
 
876
 
 lineWidth(1.0 );
877
 
 lineColor(0   ,0   ,0 );
878
 
 fillColor(255 ,255 ,255 );
879
 
 
880
 
 textAlignment(AlignLeft ,AlignBottom );
881
 
 
882
 
 clipBox (0 ,0 ,width_ ,height_ );
883
 
 lineCap (CapRound );
884
 
 lineJoin(JoinRound );
885
 
 flipText(false );
886
 
 
887
 
 imageFilter  (Bilinear );
888
 
 imageResample(NoResample );
889
 
 
890
 
 m_masterAlpha   :=1.0;
891
 
 m_antiAliasGamma:=1.0;
892
 
 
893
 
 m_rasterizer.gamma(@m_gammaNone );
894
 
 
895
 
 m_blendMode:=BlendAlpha;
896
 
 
897
 
end;
898
 
 
899
 
{ ATTACH }
900
 
procedure Agg2D.attach(img : Image_ptr );
901
 
begin
902
 
 attach(img.renBuf._buf ,img.renBuf._width ,img.renBuf._height ,img.renBuf._stride );
903
 
 
904
 
end;
905
 
 
906
 
{ CLIPBOX }
907
 
procedure Agg2D.clipBox(x1 ,y1 ,x2 ,y2 : double );
908
 
var
909
 
 rx1 ,ry1 ,rx2 ,ry2 : int;
910
 
 
911
 
begin
912
 
 m_clipBox.Construct(x1 ,y1 ,x2 ,y2 );
913
 
 
914
 
 rx1:=Trunc(x1 );
915
 
 ry1:=Trunc(y1 );
916
 
 rx2:=Trunc(x2 );
917
 
 ry2:=Trunc(y2 );
918
 
 
919
 
 m_renBase.clip_box_       (rx1 ,ry1 ,rx2 ,ry2 );
920
 
 m_renBaseComp.clip_box_   (rx1 ,ry1 ,rx2 ,ry2 );
921
 
 m_renBasePre.clip_box_    (rx1 ,ry1 ,rx2 ,ry2 );
922
 
 m_renBaseCompPre.clip_box_(rx1 ,ry1 ,rx2 ,ry2 );
923
 
 
924
 
 m_rasterizer.clip_box(x1 ,y1 ,x2 ,y2 );
925
 
 
926
 
end;
927
 
 
928
 
{ CLIPBOX }
929
 
function Agg2D.clipBox : RectD;
930
 
begin
931
 
 result:=m_clipBox;
932
 
 
933
 
end;
934
 
 
935
 
{ CLEARALL }
936
 
procedure Agg2D.clearAll(c : Color );
937
 
var
938
 
 clr : aggclr;
939
 
 
940
 
begin
941
 
 clr.Construct  (c );
942
 
 m_renBase.clear(@clr );
943
 
 
944
 
end;
945
 
 
946
 
{ CLEARALL }
947
 
procedure Agg2D.clearAll(r ,g ,b : unsigned; a : unsigned = 255 );
948
 
var
949
 
 clr : Color;
950
 
 
951
 
begin
952
 
 clr.Construct(r ,g ,b ,a );
953
 
 clearAll     (clr );
954
 
 
955
 
end;
956
 
 
957
 
{ CLEARCLIPBOX }
958
 
procedure Agg2D.clearClipBox(c : Color );
959
 
var
960
 
 clr : aggclr;
961
 
 
962
 
begin
963
 
 clr.Construct(c );
964
 
 
965
 
 m_renBase.copy_bar(0 ,0 ,m_renBase.width ,m_renBase.height ,@clr );
966
 
 
967
 
end;
968
 
 
969
 
{ CLEARCLIPBOX }
970
 
procedure Agg2D.clearClipBox(r ,g ,b : unsigned; a : unsigned = 255 );
971
 
var
972
 
 clr : Color;
973
 
 
974
 
begin
975
 
 clr.Construct(r ,g ,b ,a );
976
 
 clearClipBox (clr );
977
 
 
978
 
end;
979
 
 
980
 
{ WORLDTOSCREEN }
981
 
procedure Agg2D.worldToScreen(x ,y : double_ptr );
982
 
begin
983
 
 m_transform.transform(@m_transform ,x ,y );
984
 
 
985
 
end;
986
 
 
987
 
{ SCREENTOWORLD }
988
 
procedure Agg2D.screenToWorld(x ,y : double_ptr );
989
 
begin
990
 
 m_transform.inverse_transform(@m_transform ,x ,y );
991
 
 
992
 
end;
993
 
 
994
 
{ WORLDTOSCREEN }
995
 
function Agg2D.worldToScreen(scalar : double ) : double;
996
 
var
997
 
 x1 ,y1 ,x2 ,y2 : double;
998
 
 
999
 
begin
1000
 
 x1:=0;
1001
 
 y1:=0;
1002
 
 x2:=scalar;
1003
 
 y2:=scalar;
1004
 
 
1005
 
 worldToScreen(@x1 ,@y1 );
1006
 
 worldToScreen(@x2 ,@y2 );
1007
 
 
1008
 
 result:=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) ) * 0.7071068;
1009
 
 
1010
 
end;
1011
 
 
1012
 
{ SCREENTOWORLD }
1013
 
function Agg2D.screenToWorld(scalar : double ) : double;
1014
 
var
1015
 
 x1 ,y1 ,x2 ,y2 : double;
1016
 
 
1017
 
begin
1018
 
 x1:=0;
1019
 
 y1:=0;
1020
 
 x2:=scalar;
1021
 
 y2:=scalar;
1022
 
 
1023
 
 screenToWorld(@x1 ,@y1 );
1024
 
 screenToWorld(@x2 ,@y2 );
1025
 
 
1026
 
 result:=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) ) * 0.7071068;
1027
 
 
1028
 
end;
1029
 
 
1030
 
{ ALIGNPOINT }
1031
 
procedure Agg2D.alignPoint(x ,y : double_ptr );
1032
 
begin
1033
 
 worldToScreen(x ,y );
1034
 
 
1035
 
 x^:=Floor(x^ ) + 0.5;
1036
 
 y^:=Floor(y^ ) + 0.5;
1037
 
 
1038
 
 screenToWorld(x ,y );
1039
 
 
1040
 
end;
1041
 
 
1042
 
{ INBOX }
1043
 
function Agg2D.inBox(worldX ,worldY : double ) : boolean;
1044
 
begin
1045
 
 worldToScreen(@worldX ,@worldY );
1046
 
 
1047
 
 result:=m_renBase.inbox(Trunc(worldX ) ,Trunc(worldY ) );
1048
 
 
1049
 
end;
1050
 
 
1051
 
{ BLENDMODE }
1052
 
procedure Agg2D.blendMode(m : BlendMode_ );
1053
 
begin
1054
 
 m_blendMode:=m;
1055
 
 
1056
 
 m_pixFormatComp.comp_op_   (unsigned(m ) );
1057
 
 m_pixFormatCompPre.comp_op_(unsigned(m ) );
1058
 
 
1059
 
end;
1060
 
 
1061
 
{ BLENDMODE }
1062
 
function Agg2D.blendMode : BlendMode_;
1063
 
begin
1064
 
 result:=m_blendMode;
1065
 
 
1066
 
end;
1067
 
 
1068
 
{ IMAGEBLENDMODE }
1069
 
procedure Agg2D.imageBlendMode(m : BlendMode_ );
1070
 
begin
1071
 
 m_imageBlendMode:=m;
1072
 
 
1073
 
end;
1074
 
 
1075
 
{ IMAGEBLENDMODE }
1076
 
function Agg2D.imageBlendMode : BlendMode_;
1077
 
begin
1078
 
 result:=m_imageBlendMode;
1079
 
 
1080
 
end;
1081
 
 
1082
 
{ IMAGEBLENDCOLOR }
1083
 
procedure Agg2D.imageBlendColor(c : Color );
1084
 
begin
1085
 
 m_imageBlendColor:=c;
1086
 
 
1087
 
end;
1088
 
 
1089
 
{ IMAGEBLENDCOLOR }
1090
 
procedure Agg2D.imageBlendColor(r ,g ,b : unsigned; a : unsigned = 255 );
1091
 
var
1092
 
 clr : Color;
1093
 
 
1094
 
begin
1095
 
 clr.Construct  (r ,g ,b ,a );
1096
 
 imageBlendColor(clr );
1097
 
 
1098
 
end;
1099
 
 
1100
 
{ IMAGEBLENDCOLOR }
1101
 
function Agg2D.imageBlendColor : Color;
1102
 
begin
1103
 
 result:=m_imageBlendColor;
1104
 
 
1105
 
end;
1106
 
 
1107
 
{ MASTERALPHA }
1108
 
procedure Agg2D.masterAlpha(a : double );
1109
 
begin
1110
 
 m_masterAlpha:=a;
1111
 
 
1112
 
 updateRasterizerGamma;
1113
 
 
1114
 
end;
1115
 
 
1116
 
{ MASTERALPHA }
1117
 
function Agg2D.masterAlpha : double;
1118
 
begin
1119
 
 result:=m_masterAlpha;
1120
 
 
1121
 
end;
1122
 
 
1123
 
{ ANTIALIASGAMMA }
1124
 
procedure Agg2D.antiAliasGamma(g : double );
1125
 
begin
1126
 
 m_antiAliasGamma:=g;
1127
 
 
1128
 
 updateRasterizerGamma;
1129
 
 
1130
 
end;
1131
 
 
1132
 
{ ANTIALIASGAMMA }
1133
 
function Agg2D.antiAliasGamma : double;
1134
 
begin
1135
 
 result:=m_antiAliasGamma;
1136
 
 
1137
 
end;
1138
 
 
1139
 
{ FILLCOLOR }
1140
 
procedure Agg2D.fillColor(c : Color );
1141
 
begin
1142
 
 m_fillColor       :=c;
1143
 
 m_fillGradientFlag:=Solid;
1144
 
 
1145
 
end;
1146
 
 
1147
 
{ FILLCOLOR }
1148
 
procedure Agg2D.fillColor(r ,g ,b : unsigned; a : unsigned = 255 );
1149
 
var
1150
 
 clr : Color;
1151
 
 
1152
 
begin
1153
 
 clr.Construct(r ,g ,b ,a );
1154
 
 fillColor    (clr );
1155
 
 
1156
 
end;
1157
 
 
1158
 
{ NOFILL }
1159
 
procedure Agg2D.noFill;
1160
 
var
1161
 
 clr : Color;
1162
 
 
1163
 
begin
1164
 
 clr.Construct(0 ,0 ,0 ,0 );
1165
 
 fillColor    (clr );
1166
 
 
1167
 
end;
1168
 
 
1169
 
{ LINECOLOR }
1170
 
procedure Agg2D.lineColor(c : Color );
1171
 
begin
1172
 
 m_lineColor       :=c;
1173
 
 m_lineGradientFlag:=Solid;
1174
 
 
1175
 
end;
1176
 
 
1177
 
{ LINECOLOR }
1178
 
procedure Agg2D.lineColor(r ,g ,b : unsigned; a : unsigned = 255 );
1179
 
var
1180
 
 clr : Color;
1181
 
 
1182
 
begin
1183
 
 clr.Construct(r ,g ,b ,a );
1184
 
 lineColor    (clr );
1185
 
 
1186
 
end;
1187
 
 
1188
 
{ NOLINE }
1189
 
procedure Agg2D.noLine;
1190
 
var
1191
 
 clr : Color;
1192
 
 
1193
 
begin
1194
 
 clr.Construct(0 ,0 ,0 ,0 );
1195
 
 lineColor    (clr );
1196
 
 
1197
 
end;
1198
 
 
1199
 
{ FILLCOLOR }
1200
 
function Agg2D.fillColor : Color;
1201
 
begin
1202
 
 result:=m_fillColor;
1203
 
 
1204
 
end;
1205
 
 
1206
 
{ LINECOLOR }
1207
 
function Agg2D.lineColor : Color;
1208
 
begin
1209
 
 result:=m_lineColor;
1210
 
 
1211
 
end;
1212
 
 
1213
 
{ FILLLINEARGRADIENT }
1214
 
procedure Agg2D.fillLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
1215
 
var
1216
 
 i ,startGradient ,endGradient : int;
1217
 
 
1218
 
 k ,angle : double;
1219
 
 
1220
 
 c : Color;
1221
 
 
1222
 
 clr : aggclr;
1223
 
 tar : trans_affine_rotation;
1224
 
 tat : trans_affine_translation;
1225
 
 
1226
 
begin
1227
 
 startGradient:=128 - Trunc(profile * 127.0 );
1228
 
 endGradient  :=128 + Trunc(profile * 127.0 );
1229
 
 
1230
 
 if endGradient <= startGradient then
1231
 
  endGradient:=startGradient + 1;
1232
 
 
1233
 
 k:=1.0 / (endGradient - startGradient );
1234
 
 i:=0;
1235
 
 
1236
 
 while i < startGradient do
1237
 
  begin
1238
 
   clr.Construct(c1 );
1239
 
 
1240
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1241
 
   inc (i );
1242
 
 
1243
 
  end;
1244
 
 
1245
 
 while i < endGradient do
1246
 
  begin
1247
 
   c:=c1.gradient(c2 ,(i - startGradient ) * k );
1248
 
 
1249
 
   clr.Construct(c );
1250
 
 
1251
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1252
 
   inc (i );
1253
 
 
1254
 
  end;
1255
 
 
1256
 
 while i < 256 do
1257
 
  begin
1258
 
   clr.Construct(c2 );
1259
 
 
1260
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1261
 
   inc (i );
1262
 
 
1263
 
  end;
1264
 
 
1265
 
 angle:=ArcTan2(y2 - y1 ,x2 - x1 );
1266
 
 
1267
 
 m_fillGradientMatrix.reset;
1268
 
 
1269
 
 tar.Construct(angle );
1270
 
 
1271
 
 m_fillGradientMatrix.multiply(@tar );
1272
 
 
1273
 
 tat.Construct(x1 ,y1 );
1274
 
 
1275
 
 m_fillGradientMatrix.multiply(@tat );
1276
 
 m_fillGradientMatrix.multiply(@m_transform );
1277
 
 m_fillGradientMatrix.invert;
1278
 
 
1279
 
 m_fillGradientD1  :=0.0;
1280
 
 m_fillGradientD2  :=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) );
1281
 
 m_fillGradientFlag:=Linear;
1282
 
 
1283
 
 m_fillColor.Construct(0 ,0 ,0 );  // Set some real color
1284
 
 
1285
 
end;
1286
 
 
1287
 
{ LINELINEARGRADIENT }
1288
 
procedure Agg2D.lineLinearGradient(x1 ,y1 ,x2 ,y2 : double; c1 ,c2 : Color; profile : double = 1.0 );
1289
 
var
1290
 
 i ,startGradient ,endGradient : int;
1291
 
 
1292
 
 k ,angle : double;
1293
 
 
1294
 
 c : Color;
1295
 
 
1296
 
 clr : aggclr;
1297
 
 tar : trans_affine_rotation;
1298
 
 tat : trans_affine_translation;
1299
 
 
1300
 
begin
1301
 
 startGradient:=128 - Trunc(profile * 128.0 );
1302
 
 endGradient  :=128 + Trunc(profile * 128.0 );
1303
 
 
1304
 
 if endGradient <= startGradient then
1305
 
  endGradient:=startGradient + 1;
1306
 
 
1307
 
 k:=1.0 / (endGradient - startGradient );
1308
 
 i:=0;
1309
 
 
1310
 
 while i < startGradient do
1311
 
  begin
1312
 
   clr.Construct(c1 );
1313
 
 
1314
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1315
 
   inc (i );
1316
 
 
1317
 
  end;
1318
 
 
1319
 
 while i < endGradient do
1320
 
  begin
1321
 
   c:=c1.gradient(c2 ,(i - startGradient) * k );
1322
 
 
1323
 
   clr.Construct(c );
1324
 
 
1325
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1326
 
   inc (i );
1327
 
 
1328
 
  end;
1329
 
 
1330
 
 while i < 256 do
1331
 
  begin
1332
 
   clr.Construct(c2 );
1333
 
 
1334
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1335
 
   inc (i );
1336
 
 
1337
 
  end;
1338
 
 
1339
 
 angle:=ArcTan2(y2 - y1 ,x2 - x1 );
1340
 
 
1341
 
 m_lineGradientMatrix.reset;
1342
 
 
1343
 
 tar.Construct(angle );
1344
 
 
1345
 
 m_lineGradientMatrix.multiply(@tar );
1346
 
 
1347
 
 tat.Construct(x1 ,y1 );
1348
 
 
1349
 
 m_lineGradientMatrix.multiply(@tat );
1350
 
 m_lineGradientMatrix.multiply(@m_transform ); {!}
1351
 
 m_lineGradientMatrix.invert;
1352
 
 
1353
 
 m_lineGradientD1  :=0.0;
1354
 
 m_lineGradientD2  :=Sqrt((x2 - x1 ) * (x2 - x1 ) + (y2 - y1 ) * (y2 - y1 ) );
1355
 
 m_lineGradientFlag:=Linear;
1356
 
 
1357
 
 m_lineColor.Construct(0 ,0 ,0 );  // Set some real color
1358
 
 
1359
 
end;
1360
 
 
1361
 
{ FILLRADIALGRADIENT }
1362
 
procedure Agg2D.fillRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 );
1363
 
var
1364
 
 i ,startGradient ,endGradient : int;
1365
 
 
1366
 
 k : double;
1367
 
 c : Color;
1368
 
 
1369
 
 clr : aggclr;
1370
 
 tat : trans_affine_translation;
1371
 
 
1372
 
begin
1373
 
 startGradient:=128 - Trunc(profile * 127.0 );
1374
 
 endGradient  :=128 + Trunc(profile * 127.0 );
1375
 
 
1376
 
 if endGradient <= startGradient then
1377
 
  endGradient:=startGradient + 1;
1378
 
 
1379
 
 k:=1.0 / (endGradient - startGradient );
1380
 
 i:=0;
1381
 
 
1382
 
 while i < startGradient do
1383
 
  begin
1384
 
   clr.Construct(c1 );
1385
 
 
1386
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1387
 
   inc (i );
1388
 
 
1389
 
  end;
1390
 
 
1391
 
 while i < endGradient do
1392
 
  begin
1393
 
   c:=c1.gradient(c2 ,(i - startGradient ) * k );
1394
 
 
1395
 
   clr.Construct(c );
1396
 
 
1397
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1398
 
   inc (i );
1399
 
 
1400
 
  end;
1401
 
 
1402
 
 while i < 256 do
1403
 
  begin
1404
 
   clr.Construct(c2 );
1405
 
 
1406
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1407
 
   inc (i );
1408
 
 
1409
 
  end;
1410
 
 
1411
 
 m_fillGradientD2:=worldToScreen(r );
1412
 
 
1413
 
 worldToScreen(@x ,@y );
1414
 
 
1415
 
 m_fillGradientMatrix.reset;
1416
 
 
1417
 
 tat.Construct(x ,y );
1418
 
 
1419
 
 m_fillGradientMatrix.multiply(@tat );
1420
 
 m_fillGradientMatrix.invert;
1421
 
 
1422
 
 m_fillGradientD1  :=0;
1423
 
 m_fillGradientFlag:=Radial;
1424
 
 
1425
 
 m_fillColor.Construct(0 ,0 ,0 );  // Set some real color
1426
 
 
1427
 
end;
1428
 
 
1429
 
{ LINERADIALGRADIENT }
1430
 
procedure Agg2D.lineRadialGradient(x ,y ,r : double; c1 ,c2 : Color; profile : double = 1.0 );
1431
 
var
1432
 
 i ,startGradient ,endGradient : int;
1433
 
 
1434
 
 k : double;
1435
 
 c : Color;
1436
 
 
1437
 
 clr : aggclr;
1438
 
 tat : trans_affine_translation;
1439
 
 
1440
 
begin
1441
 
 startGradient:=128 - Trunc(profile * 128.0 );
1442
 
 endGradient  :=128 + Trunc(profile * 128.0 );
1443
 
 
1444
 
 if endGradient <= startGradient then
1445
 
  endGradient:=startGradient + 1;
1446
 
 
1447
 
 k:=1.0 / (endGradient - startGradient );
1448
 
 i:=0;
1449
 
 
1450
 
 while i < startGradient do
1451
 
  begin
1452
 
   clr.Construct(c1 );
1453
 
 
1454
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1455
 
   inc (i );
1456
 
 
1457
 
  end;
1458
 
 
1459
 
 while i < endGradient do
1460
 
  begin
1461
 
   c:=c1.gradient(c2 ,(i - startGradient ) * k );
1462
 
 
1463
 
   clr.Construct(c );
1464
 
 
1465
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1466
 
   inc (i );
1467
 
 
1468
 
  end;
1469
 
 
1470
 
 while i < 256 do
1471
 
  begin
1472
 
   clr.Construct(c2 );
1473
 
 
1474
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1475
 
   inc (i );
1476
 
 
1477
 
  end;
1478
 
 
1479
 
 m_lineGradientD2:=worldToScreen(r );
1480
 
 
1481
 
 worldToScreen(@x ,@y );
1482
 
 
1483
 
 m_lineGradientMatrix.reset;
1484
 
 
1485
 
 tat.Construct(x ,y );
1486
 
 
1487
 
 m_lineGradientMatrix.multiply(@tat );
1488
 
 m_lineGradientMatrix.invert;
1489
 
 
1490
 
 m_lineGradientD1  :=0;
1491
 
 m_lineGradientFlag:=Radial;
1492
 
 
1493
 
 m_lineColor.Construct(0 ,0 ,0 );  // Set some real color
1494
 
 
1495
 
end;
1496
 
 
1497
 
{ FILLRADIALGRADIENT }
1498
 
procedure Agg2D.fillRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color );
1499
 
var
1500
 
 i : int;
1501
 
 c : Color;
1502
 
 
1503
 
 clr : aggclr;
1504
 
 tat : trans_affine_translation;
1505
 
 
1506
 
begin
1507
 
 i:=0;
1508
 
 
1509
 
 while i < 128 do
1510
 
  begin
1511
 
   c:=c1.gradient(c2 ,i / 127.0 );
1512
 
 
1513
 
   clr.Construct(c );
1514
 
 
1515
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1516
 
   inc (i );
1517
 
 
1518
 
  end;
1519
 
 
1520
 
 while i < 256 do
1521
 
  begin
1522
 
   c:=c2.gradient(c3 ,(i - 128 ) / 127.0 );
1523
 
 
1524
 
   clr.Construct(c );
1525
 
 
1526
 
   move(clr ,m_fillGradient.array_operator(i )^ ,sizeof(aggclr ) );
1527
 
   inc (i );
1528
 
 
1529
 
  end;
1530
 
 
1531
 
 m_fillGradientD2:=worldToScreen(r );
1532
 
 
1533
 
 worldToScreen(@x ,@y );
1534
 
 
1535
 
 m_fillGradientMatrix.reset;
1536
 
 
1537
 
 tat.Construct(x ,y );
1538
 
 
1539
 
 m_fillGradientMatrix.multiply(@tat );
1540
 
 m_fillGradientMatrix.invert;
1541
 
 
1542
 
 m_fillGradientD1  :=0;
1543
 
 m_fillGradientFlag:=Radial;
1544
 
 
1545
 
 m_fillColor.Construct(0 ,0 ,0 ); // Set some real color
1546
 
 
1547
 
end;
1548
 
 
1549
 
{ LINERADIALGRADIENT }
1550
 
procedure Agg2D.lineRadialGradient(x ,y ,r : double; c1 ,c2 ,c3 : Color );
1551
 
var
1552
 
 i : int;
1553
 
 c : Color;
1554
 
 
1555
 
 clr : aggclr;
1556
 
 tat : trans_affine_translation;
1557
 
 
1558
 
begin
1559
 
 i:=0;
1560
 
 
1561
 
 while i < 128 do
1562
 
  begin
1563
 
   c:=c1.gradient(c2 ,i / 127.0 );
1564
 
 
1565
 
   clr.Construct(c );
1566
 
 
1567
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1568
 
   inc (i );
1569
 
 
1570
 
  end;
1571
 
 
1572
 
 while i < 256 do
1573
 
  begin
1574
 
   c:=c2.gradient(c3 ,(i - 128 ) / 127.0 );
1575
 
 
1576
 
   clr.Construct(c );
1577
 
 
1578
 
   move(clr ,m_lineGradient.array_operator(i )^ ,sizeof(aggclr ) );
1579
 
   inc (i );
1580
 
 
1581
 
  end;
1582
 
 
1583
 
 m_lineGradientD2:=worldToScreen(r );
1584
 
 
1585
 
 worldToScreen(@x ,@y );
1586
 
 
1587
 
 m_lineGradientMatrix.reset;
1588
 
 
1589
 
 tat.Construct(x ,y );
1590
 
 
1591
 
 m_lineGradientMatrix.multiply(@tat );
1592
 
 m_lineGradientMatrix.invert;
1593
 
 
1594
 
 m_lineGradientD1  :=0;
1595
 
 m_lineGradientFlag:=Radial;
1596
 
 
1597
 
 m_lineColor.Construct(0 ,0 ,0 ); // Set some real color
1598
 
 
1599
 
end;
1600
 
 
1601
 
{ FILLRADIALGRADIENT }
1602
 
procedure Agg2D.fillRadialGradient(x ,y ,r : double );
1603
 
var
1604
 
 tat : trans_affine_translation;
1605
 
 
1606
 
begin
1607
 
 m_fillGradientD2:=worldToScreen(r );
1608
 
 
1609
 
 worldToScreen(@x ,@y );
1610
 
 
1611
 
 m_fillGradientMatrix.reset;
1612
 
 
1613
 
 tat.Construct(x ,y );
1614
 
 
1615
 
 m_fillGradientMatrix.multiply(@tat );
1616
 
 m_fillGradientMatrix.invert;
1617
 
 
1618
 
 m_fillGradientD1:=0;
1619
 
 
1620
 
end;
1621
 
 
1622
 
{ LINERADIALGRADIENT }
1623
 
procedure Agg2D.lineRadialGradient(x ,y ,r : double );
1624
 
var
1625
 
 tat : trans_affine_translation;
1626
 
 
1627
 
begin
1628
 
 m_lineGradientD2:=worldToScreen(r );
1629
 
 
1630
 
 worldToScreen(@x ,@y );
1631
 
 
1632
 
 m_lineGradientMatrix.reset;
1633
 
 
1634
 
 tat.Construct(x ,y );
1635
 
 
1636
 
 m_lineGradientMatrix.multiply(@tat );
1637
 
 m_lineGradientMatrix.invert;
1638
 
 
1639
 
 m_lineGradientD1:=0;
1640
 
 
1641
 
end;
1642
 
 
1643
 
{ LINEWIDTH }
1644
 
procedure Agg2D.lineWidth(w : double );
1645
 
begin
1646
 
 m_lineWidth:=w;
1647
 
 
1648
 
 m_convStroke.width_(w );
1649
 
 
1650
 
end;
1651
 
 
1652
 
{ LINEWIDTH_ }
1653
 
function Agg2D.lineWidth_(w : double ) : double;
1654
 
begin
1655
 
 result:=m_lineWidth;
1656
 
 
1657
 
end;
1658
 
 
1659
 
{ LINECAP }
1660
 
procedure Agg2D.lineCap(cap : LineCap_ );
1661
 
begin
1662
 
 m_lineCap:=cap;
1663
 
 
1664
 
 m_convStroke.line_cap_(cap );
1665
 
 
1666
 
end;
1667
 
 
1668
 
{ LINECAP }
1669
 
function Agg2D.lineCap : LineCap_;
1670
 
begin
1671
 
 result:=m_lineCap;
1672
 
 
1673
 
end;
1674
 
 
1675
 
{ LINEJOIN }
1676
 
procedure Agg2D.lineJoin(join : LineJoin_ );
1677
 
begin
1678
 
 m_lineJoin:=join;
1679
 
 
1680
 
 m_convStroke.line_join_(join );
1681
 
 
1682
 
end;
1683
 
 
1684
 
{ LINEJOIN }
1685
 
function Agg2D.lineJoin : LineJoin_;
1686
 
begin
1687
 
 result:=m_lineJoin;
1688
 
 
1689
 
end;
1690
 
 
1691
 
{ FILLEVENODD }
1692
 
procedure Agg2D.fillEvenOdd(evenOddFlag : boolean );
1693
 
begin
1694
 
 m_evenOddFlag:=evenOddFlag;
1695
 
 
1696
 
 if evenOddFlag then
1697
 
  m_rasterizer.filling_rule(fill_even_odd )
1698
 
 else
1699
 
  m_rasterizer.filling_rule(fill_non_zero );
1700
 
 
1701
 
end;
1702
 
 
1703
 
{ FILLEVENODD }
1704
 
function Agg2D.fillEvenOdd : boolean;
1705
 
begin
1706
 
 result:=m_evenOddFlag;
1707
 
 
1708
 
end;
1709
 
 
1710
 
{ TRANSFORMATIONS }
1711
 
function Agg2D.transformations : Transformations_;
1712
 
begin
1713
 
 m_transform.store_to(@result.affineMatrix[0 ] );
1714
 
 
1715
 
end;
1716
 
 
1717
 
{ TRANSFORMATIONS }
1718
 
procedure Agg2D.transformations(tr : Transformations_ptr );
1719
 
begin
1720
 
 m_transform.load_from(@tr.affineMatrix[0 ] );
1721
 
 
1722
 
 m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1723
 
 m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1724
 
 
1725
 
end;
1726
 
 
1727
 
{ RESETTRANSFORMATIONS }
1728
 
procedure Agg2D.resetTransformations;
1729
 
begin
1730
 
 m_transform.reset;
1731
 
 
1732
 
end;
1733
 
 
1734
 
{ AFFINE }
1735
 
procedure Agg2D.affine(tr : Affine_ptr );
1736
 
begin
1737
 
 m_transform.multiply(tr );
1738
 
 
1739
 
 m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1740
 
 m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1741
 
 
1742
 
end;
1743
 
 
1744
 
{ AFFINE }
1745
 
procedure Agg2D.affine(tr : Transformations_ptr );
1746
 
var
1747
 
 ta : trans_affine;
1748
 
 
1749
 
begin
1750
 
 ta.Construct(
1751
 
  tr.affineMatrix[0 ] ,tr.affineMatrix[1 ] ,tr.affineMatrix[2 ] ,
1752
 
  tr.affineMatrix[3 ] ,tr.affineMatrix[4 ] ,tr.affineMatrix[5 ] );
1753
 
 
1754
 
 affine(Affine_ptr(@ta ) );
1755
 
 
1756
 
end;
1757
 
 
1758
 
{ ROTATE }
1759
 
procedure Agg2D.rotate(angle : double );
1760
 
var
1761
 
 tar : trans_affine_rotation;
1762
 
 
1763
 
begin
1764
 
 tar.Construct(angle );
1765
 
 
1766
 
 m_transform.multiply(@tar );
1767
 
 
1768
 
end;
1769
 
 
1770
 
{ SCALE }
1771
 
procedure Agg2D.scale(sx ,sy : double );
1772
 
var
1773
 
 tas : trans_affine_scaling;
1774
 
 
1775
 
begin
1776
 
 tas.Construct(sx ,sy );
1777
 
 
1778
 
 m_transform.multiply(@tas );
1779
 
 
1780
 
 m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1781
 
 m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1782
 
 
1783
 
end;
1784
 
 
1785
 
{ SKEW }
1786
 
procedure Agg2D.skew(sx ,sy : double );
1787
 
var
1788
 
 tas : trans_affine_skewing;
1789
 
 
1790
 
begin
1791
 
 tas.Construct(sx ,sy );
1792
 
 
1793
 
 m_transform.multiply(@tas );
1794
 
 
1795
 
end;
1796
 
 
1797
 
{ TRANSLATE }
1798
 
procedure Agg2D.translate(x ,y : double );
1799
 
var
1800
 
 tat : trans_affine_translation;
1801
 
 
1802
 
begin
1803
 
 tat.Construct(x ,y );
1804
 
 
1805
 
 m_transform.multiply(@tat );
1806
 
 
1807
 
end;
1808
 
 
1809
 
{ PARALLELOGRAM }
1810
 
procedure Agg2D.parallelogram(x1 ,y1 ,x2 ,y2 : double; para : double_ptr );
1811
 
var
1812
 
 ta : trans_affine;
1813
 
 
1814
 
begin
1815
 
 ta.Construct(x1 ,y1 ,x2 ,y2 ,parallelo_ptr(para ) );
1816
 
 
1817
 
 m_transform.multiply(@ta );
1818
 
 
1819
 
 m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1820
 
 m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1821
 
 
1822
 
end;
1823
 
 
1824
 
{ VIEWPORT }
1825
 
procedure Agg2D.viewport(
1826
 
           worldX1  ,worldY1  ,worldX2  ,worldY2 ,
1827
 
           screenX1 ,screenY1 ,screenX2 ,screenY2 : double;
1828
 
           opt : ViewportOption = XMidYMid );
1829
 
var
1830
 
 vp : trans_viewport;
1831
 
 mx : trans_affine;
1832
 
 
1833
 
begin
1834
 
 vp.Construct;
1835
 
 
1836
 
 case opt of
1837
 
  Anisotropic :
1838
 
   vp.preserve_aspect_ratio(0.0 ,0.0 ,aspect_ratio_stretch );
1839
 
 
1840
 
  XMinYMin :
1841
 
   vp.preserve_aspect_ratio(0.0 ,0.0 ,aspect_ratio_meet );
1842
 
 
1843
 
  XMidYMin :
1844
 
   vp.preserve_aspect_ratio(0.5 ,0.0 ,aspect_ratio_meet );
1845
 
 
1846
 
  XMaxYMin :
1847
 
   vp.preserve_aspect_ratio(1.0 ,0.0 ,aspect_ratio_meet );
1848
 
 
1849
 
  XMinYMid :
1850
 
   vp.preserve_aspect_ratio(0.0 ,0.5 ,aspect_ratio_meet );
1851
 
 
1852
 
  XMidYMid :
1853
 
   vp.preserve_aspect_ratio(0.5 ,0.5 ,aspect_ratio_meet );
1854
 
 
1855
 
  XMaxYMid :
1856
 
   vp.preserve_aspect_ratio(1.0 ,0.5 ,aspect_ratio_meet );
1857
 
 
1858
 
  XMinYMax :
1859
 
   vp.preserve_aspect_ratio(0.0 ,1.0 ,aspect_ratio_meet );
1860
 
 
1861
 
  XMidYMax :
1862
 
   vp.preserve_aspect_ratio(0.5 ,1.0 ,aspect_ratio_meet );
1863
 
 
1864
 
  XMaxYMax :
1865
 
   vp.preserve_aspect_ratio(1.0 ,1.0 ,aspect_ratio_meet );
1866
 
 
1867
 
 end;
1868
 
 
1869
 
 vp.world_viewport (worldX1  ,worldY1  ,worldX2  ,worldY2 );
1870
 
 vp.device_viewport(screenX1 ,screenY1 ,screenX2 ,screenY2 );
1871
 
 
1872
 
 mx.Construct;
1873
 
 
1874
 
 vp.to_affine        (@mx );
1875
 
 m_transform.multiply(@mx );
1876
 
 
1877
 
 m_convCurve.approximation_scale_ (worldToScreen(1.0 ) * g_approxScale );
1878
 
 m_convStroke.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1879
 
 
1880
 
end;
1881
 
 
1882
 
{ LINE }
1883
 
procedure Agg2D.line(x1 ,y1 ,x2 ,y2 : double );
1884
 
begin
1885
 
 m_path.remove_all;
1886
 
 
1887
 
 addLine (x1 ,y1 ,x2 ,y2 );
1888
 
 drawPath(StrokeOnly );
1889
 
 
1890
 
end;
1891
 
 
1892
 
{ TRIANGLE }
1893
 
procedure Agg2D.triangle(x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
1894
 
begin
1895
 
 m_path.remove_all;
1896
 
 m_path.move_to(x1 ,y1 );
1897
 
 m_path.line_to(x2 ,y2 );
1898
 
 m_path.line_to(x3 ,y3 );
1899
 
 m_path.close_polygon;
1900
 
 
1901
 
 drawPath(FillAndStroke );
1902
 
 
1903
 
end;
1904
 
 
1905
 
{ RECTANGLE }
1906
 
procedure Agg2D.rectangle(x1 ,y1 ,x2 ,y2 : double );
1907
 
begin
1908
 
 m_path.remove_all;
1909
 
 m_path.move_to(x1 ,y1 );
1910
 
 m_path.line_to(x2 ,y1 );
1911
 
 m_path.line_to(x2 ,y2 );
1912
 
 m_path.line_to(x1 ,y2 );
1913
 
 m_path.close_polygon;
1914
 
 
1915
 
 drawPath(FillAndStroke );
1916
 
 
1917
 
end;
1918
 
 
1919
 
{ ROUNDEDRECT }
1920
 
procedure Agg2D.roundedRect(x1 ,y1 ,x2 ,y2 ,r : double );
1921
 
var
1922
 
 rc : rounded_rect;
1923
 
 
1924
 
begin
1925
 
 m_path.remove_all;
1926
 
 rc.Construct(x1 ,y1 ,x2 ,y2 ,r );
1927
 
 
1928
 
 rc.normalize_radius;
1929
 
 rc.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1930
 
 
1931
 
 m_path.add_path(@rc ,0 ,false );
1932
 
 
1933
 
 drawPath(FillAndStroke );
1934
 
 
1935
 
end;
1936
 
 
1937
 
{ ROUNDEDRECT }
1938
 
procedure Agg2D.roundedRect(x1 ,y1 ,x2 ,y2 ,rx ,ry : double );
1939
 
var
1940
 
 rc : rounded_rect;
1941
 
 
1942
 
begin
1943
 
 m_path.remove_all;
1944
 
 rc.Construct;
1945
 
 
1946
 
 rc.rect  (x1 ,y1 ,x2 ,y2 );
1947
 
 rc.radius(rx ,ry );
1948
 
 rc.normalize_radius;
1949
 
 
1950
 
 m_path.add_path(@rc ,0 ,false );
1951
 
 
1952
 
 drawPath(FillAndStroke );
1953
 
 
1954
 
end;
1955
 
 
1956
 
{ ROUNDEDRECT }
1957
 
procedure Agg2D.roundedRect(
1958
 
           x1 ,y1 ,x2 ,y2 ,
1959
 
           rxBottom ,ryBottom ,
1960
 
           rxTop ,ryTop : double );
1961
 
var
1962
 
 rc : rounded_rect;
1963
 
 
1964
 
begin
1965
 
 m_path.remove_all;
1966
 
 rc.Construct;
1967
 
 
1968
 
 rc.rect  (x1 ,y1 ,x2 ,y2 );
1969
 
 rc.radius(rxBottom ,ryBottom ,rxTop ,ryTop );
1970
 
 rc.normalize_radius;
1971
 
 
1972
 
 rc.approximation_scale_(worldToScreen(1.0 ) * g_approxScale );
1973
 
 
1974
 
 m_path.add_path(@rc ,0 ,false );
1975
 
 
1976
 
 drawPath(FillAndStroke );
1977
 
 
1978
 
end;
1979
 
 
1980
 
{ ELLIPSE }
1981
 
procedure Agg2D.ellipse(cx ,cy ,rx ,ry : double );
1982
 
var
1983
 
 el : bezier_arc;
1984
 
 
1985
 
begin
1986
 
 m_path.remove_all;
1987
 
 
1988
 
 el.Construct(cx ,cy ,rx ,ry ,0 ,2 * pi );
1989
 
 
1990
 
 m_path.add_path(@el ,0 ,false );
1991
 
 m_path.close_polygon;
1992
 
 
1993
 
 drawPath(FillAndStroke );
1994
 
 
1995
 
end;
1996
 
 
1997
 
{ ARC }
1998
 
procedure Agg2D.arc(cx ,cy ,rx ,ry ,start ,sweep : double );
1999
 
var
2000
 
 ar : {bezier_}agg_arc.arc;
2001
 
 
2002
 
begin
2003
 
 m_path.remove_all;
2004
 
 
2005
 
 ar.Construct(cx ,cy ,rx ,ry ,start ,sweep ,false );
2006
 
 
2007
 
 m_path.add_path(@ar ,0 ,false );
2008
 
 
2009
 
 drawPath(StrokeOnly );
2010
 
 
2011
 
end;
2012
 
 
2013
 
{ STAR }
2014
 
procedure Agg2D.star(cx ,cy ,r1 ,r2 ,startAngle : double; numRays : int );
2015
 
var
2016
 
 da ,a ,x ,y : double;
2017
 
 
2018
 
 i : int;
2019
 
 
2020
 
begin
2021
 
 m_path.remove_all;
2022
 
 
2023
 
 da:=pi / numRays;
2024
 
 a :=startAngle;
2025
 
 
2026
 
 i:=0;
2027
 
 
2028
 
 while i < numRays do
2029
 
  begin
2030
 
   x:=Cos(a ) * r2 + cx;
2031
 
   y:=Sin(a ) * r2 + cy;
2032
 
 
2033
 
   if i <> 0 then
2034
 
    m_path.line_to(x ,y )
2035
 
   else
2036
 
    m_path.move_to(x ,y );
2037
 
 
2038
 
   a:=a + da;
2039
 
 
2040
 
   m_path.line_to(Cos(a ) * r1 + cx ,Sin(a ) * r1 + cy );
2041
 
 
2042
 
   a:=a + da;
2043
 
 
2044
 
   inc(i );
2045
 
 
2046
 
  end;
2047
 
 
2048
 
 closePolygon;
2049
 
 drawPath(FillAndStroke );
2050
 
 
2051
 
end;
2052
 
 
2053
 
{ CURVE }
2054
 
procedure Agg2D.curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
2055
 
begin
2056
 
 m_path.remove_all;
2057
 
 m_path.move_to(x1 ,y1 );
2058
 
 m_path.curve3 (x2 ,y2 ,x3 ,y3 );
2059
 
 
2060
 
 drawPath(StrokeOnly );
2061
 
 
2062
 
end;
2063
 
 
2064
 
{ CURVE }
2065
 
procedure Agg2D.curve(x1 ,y1 ,x2 ,y2 ,x3 ,y3 ,x4 ,y4 : double );
2066
 
begin
2067
 
 m_path.remove_all;
2068
 
 m_path.move_to(x1 ,y1 );
2069
 
 m_path.curve4 (x2 ,y2 ,x3 ,y3 ,x4 ,y4 );
2070
 
 
2071
 
 drawPath(StrokeOnly );
2072
 
 
2073
 
end;
2074
 
 
2075
 
{ POLYGON }
2076
 
procedure Agg2D.polygon(xy : double_ptr; numPoints : int );
2077
 
begin
2078
 
 m_path.remove_all;
2079
 
 m_path.add_poly(double_2_ptr(xy ) ,numPoints );
2080
 
 
2081
 
 closePolygon;
2082
 
 drawPath(FillAndStroke );
2083
 
 
2084
 
end;
2085
 
 
2086
 
{ POLYLINE }
2087
 
procedure Agg2D.polyline(xy : double_ptr; numPoints : int );
2088
 
begin
2089
 
 m_path.remove_all;
2090
 
 m_path.add_poly(double_2_ptr(xy ) ,numPoints );
2091
 
 
2092
 
 drawPath(StrokeOnly );
2093
 
 
2094
 
end;
2095
 
 
2096
 
{ FLIPTEXT }
2097
 
procedure Agg2D.flipText(flip : boolean );
2098
 
begin
2099
 
 {$IFNDEF AGG2D_NO_FONT}
2100
 
 m_fontEngine.flip_y_(flip );
2101
 
 {$ENDIF}
2102
 
end;
2103
 
 
2104
 
{ FONT }
2105
 
procedure Agg2D.font(
2106
 
           fileName : char_ptr; height : double;
2107
 
           bold : boolean = false;
2108
 
           italic : boolean = false;
2109
 
           ch : FontCacheType = RasterFontCache;
2110
 
           angle : double = 0.0 );
2111
 
var
2112
 
 b : int;
2113
 
 
2114
 
begin
2115
 
 m_textAngle    :=angle;
2116
 
 m_fontHeight   :=height;
2117
 
 m_fontCacheType:=ch;
2118
 
 
2119
 
{$IFDEF AGG2D_USE_FREETYPE }
2120
 
 if ch = VectorFontCache then
2121
 
  m_fontEngine.load_font(PChar(fileName ) ,0 ,glyph_ren_outline )
2122
 
 else
2123
 
  m_fontEngine.load_font(PChar(fileName ) ,0 ,glyph_ren_agg_gray8 );
2124
 
 
2125
 
 m_fontEngine.hinting_(m_textHints );
2126
 
 
2127
 
 if ch = VectorFontCache then
2128
 
  m_fontEngine.height_(height )
2129
 
 else
2130
 
  m_fontEngine.height_(worldToScreen(height ) );
2131
 
 
2132
 
{$ENDIF }
2133
 
{$IFDEF AGG2D_USE_WINFONTS}
2134
 
 
2135
 
 m_fontEngine.hinting_(m_textHints );
2136
 
 
2137
 
 if bold then
2138
 
  b:=700
2139
 
 else
2140
 
  b:=400;
2141
 
 
2142
 
 if ch = VectorFontCache then
2143
 
  m_fontEngine.create_font_(PChar(fileName ) ,glyph_ren_outline ,height ,0.0 ,b ,italic )
2144
 
 else
2145
 
  m_fontEngine.create_font_(PChar(fileName ) ,glyph_ren_agg_gray8 ,worldToScreen(height) ,0.0 ,b ,italic );
2146
 
 
2147
 
{$ENDIF }
2148
 
 
2149
 
end;
2150
 
 
2151
 
{ FONTHEIGHT }
2152
 
function Agg2D.fontHeight : double;
2153
 
begin
2154
 
 result:=m_fontHeight;
2155
 
 
2156
 
end;
2157
 
 
2158
 
{ TEXTALIGNMENT }
2159
 
procedure Agg2D.textAlignment(alignX ,alignY : TextAlignment );
2160
 
begin
2161
 
 m_textAlignX:=alignX;
2162
 
 m_textAlignY:=alignY;
2163
 
 
2164
 
end;
2165
 
 
2166
 
{ TEXTHINTS }
2167
 
function Agg2D.textHints : boolean;
2168
 
begin
2169
 
 result:=m_textHints;
2170
 
 
2171
 
end;
2172
 
 
2173
 
{ TEXTHINTS }
2174
 
procedure Agg2D.textHints(hints : boolean );
2175
 
begin
2176
 
 m_textHints:=hints;
2177
 
 
2178
 
end;
2179
 
 
2180
 
{ TEXTWIDTH }
2181
 
function Agg2D.textWidth(str : char_ptr ) : double;
2182
 
{$IFDEF AGG2D_NO_FONT}
2183
 
begin
2184
 
  Result:=0;
2185
 
end;
2186
 
{$ELSE}
2187
 
var
2188
 
 x ,y  : double;
2189
 
 first : boolean;
2190
 
 glyph : glyph_cache_ptr;
2191
 
 
2192
 
begin
2193
 
 x:=0;
2194
 
 y:=0;
2195
 
 
2196
 
 first:=true;
2197
 
 
2198
 
 while str^ <> #0 do
2199
 
  begin
2200
 
   glyph:=m_fontCacheManager.glyph(int32u(str^ ) );
2201
 
 
2202
 
   if glyph <> NIL then
2203
 
    begin
2204
 
     if not first then
2205
 
      m_fontCacheManager.add_kerning(@x ,@y );
2206
 
 
2207
 
     x:=x + glyph.advance_x;
2208
 
     y:=y + glyph.advance_y;
2209
 
 
2210
 
     first:=false; {!}
2211
 
 
2212
 
    end;
2213
 
 
2214
 
   inc(ptrcomp(str ) );
2215
 
 
2216
 
  end;
2217
 
 
2218
 
 if m_fontCacheType = VectorFontCache then
2219
 
  result:=x
2220
 
 else
2221
 
  result:=screenToWorld(x );
2222
 
 
2223
 
end;
2224
 
{$ENDIF}
2225
 
 
2226
 
{ TEXT }
2227
 
procedure Agg2D.text(
2228
 
           x ,y : double; str : char_ptr;
2229
 
           roundOff : boolean = false;
2230
 
           ddx : double = 0.0;
2231
 
           ddy : double = 0.0 );
2232
 
{$IFDEF AGG2D_NO_FONT}
2233
 
begin
2234
 
 
2235
 
end;
2236
 
{$ELSE}
2237
 
var
2238
 
 dx ,dy ,asc ,start_x ,start_y : double;
2239
 
 
2240
 
 glyph : glyph_cache_ptr;
2241
 
 
2242
 
 mtx : trans_affine;
2243
 
 
2244
 
 i : int;
2245
 
 
2246
 
 tat : trans_affine_translation;
2247
 
 tar : trans_affine_rotation;
2248
 
 
2249
 
 tr : conv_transform;
2250
 
 
2251
 
begin
2252
 
 dx:=0.0;
2253
 
 dy:=0.0;
2254
 
 
2255
 
 case m_textAlignX of
2256
 
  AlignCenter :
2257
 
   dx:=-textWidth(str ) * 0.5;
2258
 
 
2259
 
  AlignRight :
2260
 
   dx:=-textWidth(str );
2261
 
 
2262
 
 end;
2263
 
 
2264
 
 asc  :=fontHeight;
2265
 
 glyph:=m_fontCacheManager.glyph(int32u('H' ) );
2266
 
 
2267
 
 if glyph <> NIL then
2268
 
  asc:=glyph.bounds.y2 - glyph.bounds.y1;
2269
 
 
2270
 
 if m_fontCacheType = RasterFontCache then
2271
 
  asc:=screenToWorld(asc );
2272
 
 
2273
 
 case m_textAlignY of
2274
 
  AlignCenter :
2275
 
   dy:=-asc * 0.5;
2276
 
 
2277
 
  AlignTop :
2278
 
   dy:=-asc;
2279
 
 
2280
 
 end;
2281
 
 
2282
 
 if m_fontEngine._flip_y then
2283
 
  dy:=-dy;
2284
 
 
2285
 
 mtx.Construct;
2286
 
 
2287
 
 start_x:=x + dx;
2288
 
 start_y:=y + dy;
2289
 
 
2290
 
 if roundOff then
2291
 
  begin
2292
 
   start_x:=Trunc(start_x );
2293
 
   start_y:=Trunc(start_y );
2294
 
 
2295
 
  end;
2296
 
 
2297
 
 start_x:=start_x + ddx;
2298
 
 start_y:=start_y + ddy;
2299
 
 
2300
 
 tat.Construct(-x ,-y );
2301
 
 mtx.multiply (@tat );
2302
 
 
2303
 
 tar.Construct(m_textAngle );
2304
 
 mtx.multiply (@tar );
2305
 
 
2306
 
 tat.Construct(x ,y );
2307
 
 mtx.multiply (@tat );
2308
 
 
2309
 
 tr.Construct(m_fontCacheManager.path_adaptor ,@mtx );
2310
 
 
2311
 
 if m_fontCacheType = RasterFontCache then
2312
 
  worldToScreen(@start_x ,@start_y );
2313
 
 
2314
 
 i:=0;
2315
 
 
2316
 
 while char_ptr(ptrcomp(str ) + i * sizeof(char ) )^ <> #0 do
2317
 
  begin
2318
 
   glyph:=m_fontCacheManager.glyph(int32u(char_ptr(ptrcomp(str ) + i * sizeof(char ) )^ ) );
2319
 
 
2320
 
   if glyph <> NIL then
2321
 
    begin
2322
 
     if i <> 0 then
2323
 
      m_fontCacheManager.add_kerning(@x ,@y );
2324
 
 
2325
 
     m_fontCacheManager.init_embedded_adaptors(glyph ,start_x ,start_y );
2326
 
 
2327
 
     if glyph.data_type = glyph_data_outline then
2328
 
      begin
2329
 
       m_path.remove_all;
2330
 
       m_path.add_path(@tr ,0 ,false );
2331
 
 
2332
 
       drawPath;
2333
 
 
2334
 
      end;
2335
 
 
2336
 
     if glyph.data_type = glyph_data_gray8 then
2337
 
      begin
2338
 
       render(
2339
 
        m_fontCacheManager.gray8_adaptor ,
2340
 
        m_fontCacheManager.gray8_scanline );
2341
 
 
2342
 
      end;
2343
 
 
2344
 
     start_x:=start_x + glyph.advance_x;
2345
 
     start_y:=start_y + glyph.advance_y;
2346
 
 
2347
 
    end;
2348
 
 
2349
 
   inc(i );
2350
 
 
2351
 
  end;
2352
 
 
2353
 
end;
2354
 
{$ENDIF}
2355
 
 
2356
 
{ RESETPATH }
2357
 
procedure Agg2D.resetPath;
2358
 
begin
2359
 
 m_path.remove_all;
2360
 
 
2361
 
end;
2362
 
 
2363
 
{ MOVETO }
2364
 
procedure Agg2D.moveTo(x ,y : double );
2365
 
begin
2366
 
 m_path.move_to(x ,y );
2367
 
 
2368
 
end;
2369
 
 
2370
 
{ MOVEREL }
2371
 
procedure Agg2D.moveRel(dx ,dy : double );
2372
 
begin
2373
 
 m_path.move_rel(dx ,dy );
2374
 
 
2375
 
end;
2376
 
 
2377
 
{ LINETO }
2378
 
procedure Agg2D.lineTo(x ,y : double );
2379
 
begin
2380
 
 m_path.line_to(x ,y );
2381
 
 
2382
 
end;
2383
 
 
2384
 
{ LINEREL }
2385
 
procedure Agg2D.lineRel(dx ,dy : double );
2386
 
begin
2387
 
 m_path.line_rel(dx ,dy );
2388
 
 
2389
 
end;
2390
 
 
2391
 
{ HORLINETO }
2392
 
procedure Agg2D.horLineTo(x : double );
2393
 
begin
2394
 
 m_path.hline_to(x );
2395
 
 
2396
 
end;
2397
 
 
2398
 
{ HORLINEREL }
2399
 
procedure Agg2D.horLineRel(dx : double );
2400
 
begin
2401
 
 m_path.hline_rel(dx );
2402
 
 
2403
 
end;
2404
 
 
2405
 
{ VERLINETO }
2406
 
procedure Agg2D.verLineTo(y : double );
2407
 
begin
2408
 
 m_path.vline_to(y );
2409
 
 
2410
 
end;
2411
 
 
2412
 
{ VERLINEREL }
2413
 
procedure Agg2D.verLineRel(dy : double );
2414
 
begin
2415
 
 m_path.vline_rel(dy );
2416
 
 
2417
 
end;
2418
 
 
2419
 
{ ARCTO }
2420
 
procedure Agg2D.arcTo(
2421
 
           rx ,ry ,angle : double;
2422
 
           largeArcFlag ,sweepFlag : boolean;
2423
 
           x ,y : double );
2424
 
begin
2425
 
 m_path.arc_to(rx ,ry ,angle ,largeArcFlag ,sweepFlag ,x ,y );
2426
 
 
2427
 
end;
2428
 
 
2429
 
{ ARCREL }
2430
 
procedure Agg2D.arcRel(
2431
 
           rx ,ry ,angle : double;
2432
 
           largeArcFlag ,sweepFlag : boolean;
2433
 
           dx ,dy : double );
2434
 
begin
2435
 
 m_path.arc_rel(rx ,ry ,angle ,largeArcFlag ,sweepFlag ,dx ,dy );
2436
 
 
2437
 
end;
2438
 
 
2439
 
{ QUADRICCURVETO }
2440
 
procedure Agg2D.quadricCurveTo (xCtrl ,yCtrl ,xTo ,yTo : double );
2441
 
begin
2442
 
 m_path.curve3(xCtrl ,yCtrl ,xTo ,yTo );
2443
 
 
2444
 
end;
2445
 
 
2446
 
{ QUADRICCURVEREL }
2447
 
procedure Agg2D.quadricCurveRel(dxCtrl ,dyCtrl ,dxTo ,dyTo : double );
2448
 
begin
2449
 
 m_path.curve3_rel(dxCtrl ,dyCtrl ,dxTo ,dyTo );
2450
 
 
2451
 
end;
2452
 
 
2453
 
{ QUADRICCURVETO }
2454
 
procedure Agg2D.quadricCurveTo (xTo ,yTo : double );
2455
 
begin
2456
 
 m_path.curve3(xTo ,yTo );
2457
 
 
2458
 
end;
2459
 
 
2460
 
{ QUADRICCURVEREL }
2461
 
procedure Agg2D.quadricCurveRel(dxTo ,dyTo : double );
2462
 
begin
2463
 
 m_path.curve3_rel(dxTo ,dyTo );
2464
 
 
2465
 
end;
2466
 
 
2467
 
{ CUBICCURVETO }
2468
 
procedure Agg2D.cubicCurveTo (xCtrl1 ,yCtrl1 ,xCtrl2 ,yCtrl2 ,xTo ,yTo : double );
2469
 
begin
2470
 
 m_path.curve4(xCtrl1 ,yCtrl1 ,xCtrl2 ,yCtrl2 ,xTo ,yTo );
2471
 
 
2472
 
end;
2473
 
 
2474
 
{ CUBICCURVEREL }
2475
 
procedure Agg2D.cubicCurveRel(dxCtrl1 ,dyCtrl1 ,dxCtrl2 ,dyCtrl2 ,dxTo ,dyTo : double );
2476
 
begin
2477
 
 m_path.curve4_rel(dxCtrl1 ,dyCtrl1 ,dxCtrl2 ,dyCtrl2 ,dxTo ,dyTo );
2478
 
 
2479
 
end;
2480
 
 
2481
 
{ CUBICCURVETO }
2482
 
procedure Agg2D.cubicCurveTo (xCtrl2 ,yCtrl2 ,xTo ,yTo : double );
2483
 
begin
2484
 
 m_path.curve4(xCtrl2 ,yCtrl2 ,xTo ,yTo );
2485
 
 
2486
 
end;
2487
 
 
2488
 
{ CUBICCURVEREL }
2489
 
procedure Agg2D.cubicCurveRel(xCtrl2 ,yCtrl2 ,xTo ,yTo : double );
2490
 
begin
2491
 
 m_path.curve4_rel(xCtrl2 ,yCtrl2 ,xTo ,yTo );
2492
 
 
2493
 
end;
2494
 
 
2495
 
{ ADDELLIPSE }
2496
 
procedure Agg2D.addEllipse(cx ,cy ,rx ,ry : double; dir : Direction );
2497
 
var
2498
 
 ar : bezier_arc;
2499
 
 
2500
 
begin
2501
 
 if dir = CCW then
2502
 
  ar.Construct(cx ,cy ,rx ,ry ,0 ,2 * pi )
2503
 
 else
2504
 
  ar.Construct(cx ,cy ,rx ,ry ,0 ,-2 * pi );
2505
 
 
2506
 
 m_path.add_path(@ar ,0 ,false );
2507
 
 m_path.close_polygon;
2508
 
 
2509
 
end;
2510
 
 
2511
 
{ CLOSEPOLYGON }
2512
 
procedure Agg2D.closePolygon;
2513
 
begin
2514
 
 m_path.close_polygon;
2515
 
 
2516
 
end;
2517
 
 
2518
 
{ DRAWPATH }
2519
 
procedure Agg2D.drawPath(flag : DrawPathFlag = FillAndStroke );
2520
 
begin
2521
 
 m_rasterizer.reset;
2522
 
 
2523
 
 case flag of
2524
 
  FillOnly :
2525
 
   if m_fillColor.a <> 0 then
2526
 
    begin
2527
 
     m_rasterizer.add_path(@m_pathTransform );
2528
 
 
2529
 
     render(true );
2530
 
 
2531
 
    end;
2532
 
 
2533
 
  StrokeOnly :
2534
 
   if (m_lineColor.a <> 0 ) and
2535
 
      (m_lineWidth > 0.0 ) then
2536
 
    begin
2537
 
     m_rasterizer.add_path(@m_strokeTransform );
2538
 
 
2539
 
     render(false );
2540
 
 
2541
 
    end;
2542
 
 
2543
 
  FillAndStroke :
2544
 
   begin
2545
 
    if m_fillColor.a <> 0 then
2546
 
     begin
2547
 
      m_rasterizer.add_path(@m_pathTransform );
2548
 
 
2549
 
      render(true );
2550
 
 
2551
 
     end;
2552
 
 
2553
 
    if (m_lineColor.a <> 0 ) and
2554
 
       (m_lineWidth > 0.0 ) then
2555
 
     begin
2556
 
      m_rasterizer.add_path(@m_strokeTransform );
2557
 
 
2558
 
      render(false );
2559
 
 
2560
 
     end;
2561
 
 
2562
 
   end;
2563
 
 
2564
 
  FillWithLineColor :
2565
 
   if m_lineColor.a <> 0 then
2566
 
    begin
2567
 
     m_rasterizer.add_path(@m_pathTransform );
2568
 
 
2569
 
     render(false );
2570
 
 
2571
 
    end;
2572
 
 
2573
 
 end;
2574
 
 
2575
 
end;
2576
 
 
2577
 
{ DRAWPATHNOTRANSFORM }
2578
 
procedure Agg2D.drawPathNoTransform(flag : DrawPathFlag = FillAndStroke );
2579
 
begin
2580
 
end;
2581
 
 
2582
 
{ IMAGEFILTER }
2583
 
procedure Agg2D.imageFilter(f : ImageFilter_ );
2584
 
begin
2585
 
 m_imageFilter:=f;
2586
 
 
2587
 
 case f of
2588
 
  Bilinear :
2589
 
   m_imageFilterLut.calculate(@m_ifBilinear ,true );
2590
 
 
2591
 
  Hanning :
2592
 
   m_imageFilterLut.calculate(@m_ifHanning ,true );
2593
 
 
2594
 
  Hermite :
2595
 
   m_imageFilterLut.calculate(@m_ifHermite ,true );
2596
 
 
2597
 
  Quadric :
2598
 
   m_imageFilterLut.calculate(@m_ifQuadric ,true );
2599
 
 
2600
 
  Bicubic :
2601
 
   m_imageFilterLut.calculate(@m_ifBicubic ,true );
2602
 
 
2603
 
  Catrom :
2604
 
   m_imageFilterLut.calculate(@m_ifCatrom ,true );
2605
 
 
2606
 
  Spline16 :
2607
 
   m_imageFilterLut.calculate(@m_ifSpline16 ,true );
2608
 
 
2609
 
  Spline36 :
2610
 
   m_imageFilterLut.calculate(@m_ifSpline36 ,true );
2611
 
 
2612
 
  Blackman144 :
2613
 
   m_imageFilterLut.calculate(@m_ifBlackman144 ,true );
2614
 
 
2615
 
 end;
2616
 
 
2617
 
end;
2618
 
 
2619
 
{ IMAGEFILTER }
2620
 
function Agg2D.imageFilter : ImageFilter_;
2621
 
begin
2622
 
 result:=m_imageFilter;
2623
 
 
2624
 
end;
2625
 
 
2626
 
{ IMAGERESAMPLE }
2627
 
procedure Agg2D.imageResample(f : ImageResample_ );
2628
 
begin
2629
 
 m_imageResample:=f;
2630
 
 
2631
 
end;
2632
 
 
2633
 
{ IMAGERESAMPLE }
2634
 
function Agg2D.imageResample : ImageResample_;
2635
 
begin
2636
 
 result:=m_imageResample;
2637
 
 
2638
 
end;
2639
 
 
2640
 
{ TRANSFORMIMAGE }
2641
 
procedure Agg2D.transformImage(
2642
 
           img : Image_ptr;
2643
 
           imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2644
 
           dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2645
 
var
2646
 
 parall : array[0..5 ] of double;
2647
 
 
2648
 
begin
2649
 
 resetPath;
2650
 
 moveTo(dstX1 ,dstY1 );
2651
 
 lineTo(dstX2 ,dstY1 );
2652
 
 lineTo(dstX2 ,dstY2 );
2653
 
 lineTo(dstX1 ,dstY2 );
2654
 
 closePolygon;
2655
 
 
2656
 
 parall[0 ]:=dstX1;
2657
 
 parall[1 ]:=dstY1;
2658
 
 parall[2 ]:=dstX2;
2659
 
 parall[3 ]:=dstY1;
2660
 
 parall[4 ]:=dstX2;
2661
 
 parall[5 ]:=dstY2;
2662
 
 
2663
 
 renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,@parall[0 ] );
2664
 
 
2665
 
end;
2666
 
 
2667
 
{ TRANSFORMIMAGE }
2668
 
procedure Agg2D.transformImage(
2669
 
           img : Image_ptr;
2670
 
           dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2671
 
var
2672
 
 parall : array[0..5 ] of double;
2673
 
 
2674
 
begin
2675
 
 resetPath;
2676
 
 moveTo(dstX1 ,dstY1 );
2677
 
 lineTo(dstX2 ,dstY1 );
2678
 
 lineTo(dstX2 ,dstY2 );
2679
 
 lineTo(dstX1 ,dstY2 );
2680
 
 closePolygon;
2681
 
 
2682
 
 parall[0 ]:=dstX1;
2683
 
 parall[1 ]:=dstY1;
2684
 
 parall[2 ]:=dstX2;
2685
 
 parall[3 ]:=dstY1;
2686
 
 parall[4 ]:=dstX2;
2687
 
 parall[5 ]:=dstY2;
2688
 
 
2689
 
 renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,@parall[0 ] );
2690
 
 
2691
 
end;
2692
 
 
2693
 
{ TRANSFORMIMAGE }
2694
 
procedure Agg2D.transformImage(
2695
 
           img : Image_ptr;
2696
 
           imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2697
 
           parallelogram_ : double_ptr );
2698
 
begin
2699
 
 resetPath;
2700
 
 
2701
 
 moveTo(
2702
 
  double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ ,
2703
 
  double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ );
2704
 
 
2705
 
 lineTo(
2706
 
  double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2707
 
  double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2708
 
 
2709
 
 lineTo(
2710
 
  double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ ,
2711
 
  double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ );
2712
 
 
2713
 
 lineTo(
2714
 
  double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ +
2715
 
  double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ -
2716
 
  double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2717
 
  double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ +
2718
 
  double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ -
2719
 
  double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2720
 
 
2721
 
 closePolygon;
2722
 
 
2723
 
 renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,parallelogram_ );
2724
 
 
2725
 
end;
2726
 
 
2727
 
{ TRANSFORMIMAGE }
2728
 
procedure Agg2D.transformImage(img : Image_ptr; parallelogram_ : double_ptr );
2729
 
begin
2730
 
 resetPath;
2731
 
 
2732
 
 moveTo(
2733
 
  double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ ,
2734
 
  double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ );
2735
 
 
2736
 
 lineTo(
2737
 
  double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2738
 
  double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2739
 
 
2740
 
 lineTo(
2741
 
  double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ ,
2742
 
  double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ );
2743
 
 
2744
 
 lineTo(
2745
 
  double_ptr(ptrcomp(parallelogram_ ) + 0 * sizeof(double ) )^ +
2746
 
  double_ptr(ptrcomp(parallelogram_ ) + 4 * sizeof(double ) )^ -
2747
 
  double_ptr(ptrcomp(parallelogram_ ) + 2 * sizeof(double ) )^ ,
2748
 
  double_ptr(ptrcomp(parallelogram_ ) + 1 * sizeof(double ) )^ +
2749
 
  double_ptr(ptrcomp(parallelogram_ ) + 5 * sizeof(double ) )^ -
2750
 
  double_ptr(ptrcomp(parallelogram_ ) + 3 * sizeof(double ) )^ );
2751
 
 
2752
 
 closePolygon;
2753
 
 
2754
 
 renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,parallelogram_ );
2755
 
 
2756
 
end;
2757
 
 
2758
 
{ TRANSFORMIMAGEPATH }
2759
 
procedure Agg2D.transformImagePath(
2760
 
           img : Image_ptr;
2761
 
           imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2762
 
           dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2763
 
var
2764
 
 parall : array[0..5 ] of double;
2765
 
 
2766
 
begin
2767
 
 parall[0 ]:=dstX1;
2768
 
 parall[1 ]:=dstY1;
2769
 
 parall[2 ]:=dstX2;
2770
 
 parall[3 ]:=dstY1;
2771
 
 parall[4 ]:=dstX2;
2772
 
 parall[5 ]:=dstY2;
2773
 
 
2774
 
 renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,@parall[0 ] );
2775
 
 
2776
 
end;
2777
 
 
2778
 
{ TRANSFORMIMAGEPATH }
2779
 
procedure Agg2D.transformImagePath(
2780
 
           img : Image_ptr;
2781
 
           dstX1 ,dstY1 ,dstX2 ,dstY2 : double );
2782
 
var
2783
 
 parall : array[0..5 ] of double;
2784
 
 
2785
 
begin
2786
 
 parall[0 ]:=dstX1;
2787
 
 parall[1 ]:=dstY1;
2788
 
 parall[2 ]:=dstX2;
2789
 
 parall[3 ]:=dstY1;
2790
 
 parall[4 ]:=dstX2;
2791
 
 parall[5 ]:=dstY2;
2792
 
 
2793
 
 renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,@parall[0 ] );
2794
 
 
2795
 
end;
2796
 
 
2797
 
{ TRANSFORMIMAGEPATH }
2798
 
procedure Agg2D.transformImagePath(
2799
 
           img : Image_ptr;
2800
 
           imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2801
 
           parallelogram_ : double_ptr );
2802
 
begin
2803
 
 renderImage(img ,imgX1 ,imgY1 ,imgX2 ,imgY2 ,parallelogram_ );
2804
 
 
2805
 
end;
2806
 
 
2807
 
{ TRANSFORMIMAGEPATH }
2808
 
procedure Agg2D.transformImagePath(img : Image_ptr; parallelogram_ : double_ptr );
2809
 
begin
2810
 
 renderImage(img ,0 ,0 ,img.renBuf._width ,img.renBuf._height ,parallelogram_ );
2811
 
 
2812
 
end;
2813
 
 
2814
 
{ BLENDIMAGE }
2815
 
procedure Agg2D.blendImage(
2816
 
           img : Image_ptr;
2817
 
           imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2818
 
           dstX ,dstY : double; alpha : unsigned = 255 );
2819
 
var
2820
 
 pixF : pixel_formats;
2821
 
 
2822
 
 r : agg_basics.rect;
2823
 
 
2824
 
begin
2825
 
 worldToScreen(@dstX ,@dstY );
2826
 
 pixfmt_rgba32(pixF ,@img.renBuf );
2827
 
 r.Construct  (imgX1 ,imgY1 ,imgX2 ,imgY2 );
2828
 
 
2829
 
 if m_blendMode = BlendAlpha then
2830
 
  m_renBasePre.blend_from(@pixF ,@r ,Trunc(dstX ) - imgX1 ,Trunc(dstY ) - imgY1 ,alpha )
2831
 
 else
2832
 
  m_renBaseCompPre.blend_from(@pixF ,@r ,Trunc(dstX ) - imgX1 ,Trunc(dstY ) - imgY1 ,alpha );
2833
 
 
2834
 
end;
2835
 
 
2836
 
{ BLENDIMAGE }
2837
 
procedure Agg2D.blendImage(img : Image_ptr; dstX ,dstY : double; alpha : unsigned = 255 );
2838
 
var
2839
 
 pixF : pixel_formats;
2840
 
 
2841
 
begin
2842
 
 worldToScreen(@dstX ,@dstY );
2843
 
 pixfmt_rgba32(pixF ,@img.renBuf );
2844
 
 
2845
 
 m_renBasePre.blend_from(@pixF ,NIL ,Trunc(dstX ) ,Trunc(dstY ) ,alpha );
2846
 
 
2847
 
 if m_blendMode = BlendAlpha then
2848
 
  m_renBasePre.blend_from(@pixF ,NIL ,Trunc(dstX ) ,Trunc(dstY ) ,alpha )
2849
 
 else
2850
 
  m_renBaseCompPre.blend_from(@pixF ,NIL ,Trunc(dstX ) ,Trunc(dstY ) ,alpha );
2851
 
 
2852
 
end;
2853
 
 
2854
 
{ COPYIMAGE }
2855
 
procedure Agg2D.copyImage(
2856
 
           img : Image_ptr;
2857
 
           imgX1 ,imgY1 ,imgX2 ,imgY2 : int;
2858
 
           dstX ,dstY : double );
2859
 
var
2860
 
 r : agg_basics.rect;
2861
 
 
2862
 
begin
2863
 
 worldToScreen(@dstX ,@dstY );
2864
 
 r.Construct  (imgX1 ,imgY1 ,imgX2 ,imgY2 );
2865
 
 
2866
 
 m_renBase.copy_from(@img.renBuf ,@r ,Trunc(dstX ) - imgX1 ,Trunc(dstY ) - imgY1 );
2867
 
 
2868
 
end;
2869
 
 
2870
 
{ COPYIMAGE }
2871
 
procedure Agg2D.copyImage(img : Image_ptr; dstX ,dstY : double );
2872
 
begin
2873
 
 worldToScreen(@dstX ,@dstY );
2874
 
 
2875
 
 m_renBase.copy_from(@img.renBuf ,NIL ,Trunc(dstX ) ,Trunc(dstY ) );
2876
 
 
2877
 
end;
2878
 
 
2879
 
{ RENDER }
2880
 
procedure Agg2D.render(fillColor_ : boolean );
2881
 
begin
2882
 
 if m_blendMode = BlendAlpha then
2883
 
  Agg2DRenderer_render(@self ,@m_renBase ,@m_renSolid ,fillColor_ )
2884
 
 else
2885
 
  Agg2DRenderer_render(@self ,@m_renBaseComp ,@m_renSolidComp ,fillColor_ );
2886
 
 
2887
 
end;
2888
 
 
2889
 
{ RENDER }
2890
 
procedure Agg2D.render(ras : FontRasterizer_ptr; sl : FontScanline_ptr );
2891
 
begin
2892
 
 if m_blendMode = BlendAlpha then
2893
 
  Agg2DRenderer_render(@self ,@m_renBase ,@m_renSolid ,ras ,sl )
2894
 
 else
2895
 
  Agg2DRenderer_render(@self ,@m_renBaseComp ,@m_renSolidComp ,ras ,sl );
2896
 
 
2897
 
end;
2898
 
 
2899
 
{ ADDLINE }
2900
 
procedure Agg2D.addLine(x1 ,y1 ,x2 ,y2 : double );
2901
 
begin
2902
 
 m_path.move_to(x1 ,y1 );
2903
 
 m_path.line_to(x2 ,y2 );
2904
 
 
2905
 
end;
2906
 
 
2907
 
{ UPDATERASTERIZERGAMMA }
2908
 
procedure Agg2D.updateRasterizerGamma;
2909
 
begin
2910
 
 m_gammaAgg2D.Construct(m_masterAlpha ,m_antiAliasGamma );
2911
 
 m_rasterizer.gamma    (@m_gammaAgg2D );
2912
 
 
2913
 
end;
2914
 
 
2915
 
{ RENDERIMAGE }
2916
 
procedure Agg2D.renderImage(
2917
 
           img : Image_ptr;
2918
 
           x1 ,y1 ,x2 ,y2 : int;
2919
 
           parl : double_ptr );
2920
 
var
2921
 
 mtx : trans_affine;
2922
 
 
2923
 
 interpolator : span_interpolator_linear;
2924
 
 
2925
 
begin
2926
 
 mtx.Construct(x1 ,y1 ,x2 ,y2 ,parallelo_ptr(parl ) );
2927
 
 mtx.multiply (@m_transform );
2928
 
 mtx.invert;
2929
 
 
2930
 
 m_rasterizer.reset;
2931
 
 m_rasterizer.add_path(@m_pathTransform );
2932
 
 
2933
 
 interpolator.Construct(@mtx );
2934
 
 
2935
 
 if m_blendMode = BlendAlpha then
2936
 
  Agg2DRenderer_renderImage(@self ,img ,@m_renBasePre ,@interpolator )
2937
 
 else
2938
 
  Agg2DRenderer_renderImage(@self ,img ,@m_renBaseCompPre ,@interpolator );
2939
 
 
2940
 
end;
2941
 
 
2942
 
{ CONSTRUCT }
2943
 
constructor SpanConvImageBlend.Construct(m : BlendMode_; c : Color; p : pixel_formats_ptr );
2944
 
begin
2945
 
 m_mode :=m;
2946
 
 m_color:=c;
2947
 
 m_pixel:=p;
2948
 
 
2949
 
end;
2950
 
 
2951
 
{ CONVERT }
2952
 
procedure SpanConvImageBlend.convert(span : aggclr_ptr; x ,y : int; len : unsigned );
2953
 
var
2954
 
 l2 ,a : unsigned;
2955
 
 
2956
 
 s2 : Color_ptr;
2957
 
 
2958
 
begin
2959
 
 if m_mode <> BlendDst then
2960
 
  begin
2961
 
   l2:=len;
2962
 
   s2:=Color_ptr(span );
2963
 
 
2964
 
   repeat
2965
 
    comp_op_adaptor_clip_to_dst_rgba_pre(
2966
 
     m_pixel ,
2967
 
     unsigned(m_mode ) ,
2968
 
     int8u_ptr(s2 ) ,
2969
 
     m_color.r ,
2970
 
     m_color.g ,
2971
 
     m_color.b ,
2972
 
     base_mask ,
2973
 
     cover_full );
2974
 
 
2975
 
    inc(ptrcomp(s2 ) ,sizeof(Color ) );
2976
 
    dec(l2 );
2977
 
 
2978
 
   until l2 = 0;
2979
 
 
2980
 
  end;
2981
 
 
2982
 
 if m_color.a < base_mask then
2983
 
  begin
2984
 
   l2:=len;
2985
 
   s2:=Color_ptr(span );
2986
 
   a :=m_color.a;
2987
 
 
2988
 
   repeat
2989
 
    s2.r:=(s2.r * a ) shr base_shift;
2990
 
    s2.g:=(s2.g * a ) shr base_shift;
2991
 
    s2.b:=(s2.b * a ) shr base_shift;
2992
 
    s2.a:=(s2.a * a ) shr base_shift;
2993
 
 
2994
 
    inc(ptrcomp(s2 ) ,sizeof(Color ) );
2995
 
    dec(l2 );
2996
 
 
2997
 
   until l2 = 0;
2998
 
 
2999
 
  end;
3000
 
 
3001
 
end;
3002
 
 
3003
 
{ PI }
3004
 
function pi : double;
3005
 
begin
3006
 
 result:=agg_basics.pi;
3007
 
 
3008
 
end;
3009
 
 
3010
 
{ DEG2RAD }
3011
 
function deg2Rad(v : double ) : double;
3012
 
begin
3013
 
 result:=v * agg_basics.pi / 180.0;
3014
 
 
3015
 
end;
3016
 
 
3017
 
{ RAD2DEG }
3018
 
function rad2Deg(v : double ) : double;
3019
 
begin
3020
 
 result:=v * 180.0 / agg_basics.pi;
3021
 
 
3022
 
end;
3023
 
 
3024
 
{ OPERATOR_IS_EQUAL }
3025
 
function operator_is_equal(c1 ,c2 : Color_ptr ) : boolean;
3026
 
begin
3027
 
 result:=
3028
 
  (c1.r = c2.r ) and
3029
 
  (c1.g = c2.g ) and
3030
 
  (c1.b = c2.b ) and
3031
 
  (c1.a = c2.a );
3032
 
 
3033
 
end;
3034
 
 
3035
 
{ OPERATOR_IS_NOT_EQUAL }
3036
 
function operator_is_not_equal(c1 ,c2 : Color_ptr ) : boolean;
3037
 
begin
3038
 
 result:=not operator_is_equal(c1 ,c2 );
3039
 
 
3040
 
end;
3041
 
 
3042
 
{ AGG2DRENDERER_RENDER }
3043
 
procedure Agg2DRenderer_render(
3044
 
           gr : Agg2D_ptr;
3045
 
           renBase : renderer_base_ptr;
3046
 
           renSolid : renderer_scanline_aa_solid_ptr;
3047
 
           fillColor_ : boolean );
3048
 
var
3049
 
 span : span_gradient;
3050
 
 ren  : renderer_scanline_aa;
3051
 
 clr  : aggclr;
3052
 
 
3053
 
begin
3054
 
 if (fillColor_ and
3055
 
     (gr.m_fillGradientFlag = Linear ) ) or
3056
 
    (not fillColor_ and
3057
 
     (gr.m_lineGradientFlag = Linear ) ) then
3058
 
  if fillColor_ then
3059
 
   begin
3060
 
    span.Construct(
3061
 
     @gr.m_allocator ,
3062
 
     @gr.m_fillGradientInterpolator ,
3063
 
     @gr.m_linearGradientFunction ,
3064
 
     @gr.m_fillGradient ,
3065
 
     gr.m_fillGradientD1 ,
3066
 
     gr.m_fillGradientD2 );
3067
 
 
3068
 
    ren.Construct   (renBase ,@span );
3069
 
    render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3070
 
 
3071
 
   end
3072
 
  else
3073
 
   begin
3074
 
    span.Construct(
3075
 
     @gr.m_allocator ,
3076
 
     @gr.m_lineGradientInterpolator ,
3077
 
     @gr.m_linearGradientFunction ,
3078
 
     @gr.m_lineGradient ,
3079
 
     gr.m_lineGradientD1 ,
3080
 
     gr.m_lineGradientD2 );
3081
 
 
3082
 
    ren.Construct   (renBase ,@span );
3083
 
    render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3084
 
 
3085
 
   end
3086
 
 else
3087
 
  if (fillColor_ and
3088
 
      (gr.m_fillGradientFlag = Radial ) ) or
3089
 
     (not fillColor_ and
3090
 
      (gr.m_lineGradientFlag = Radial ) ) then
3091
 
   if fillColor_ then
3092
 
    begin
3093
 
     span.Construct(
3094
 
      @gr.m_allocator ,
3095
 
      @gr.m_fillGradientInterpolator ,
3096
 
      @gr.m_radialGradientFunction ,
3097
 
      @gr.m_fillGradient ,
3098
 
      gr.m_fillGradientD1 ,
3099
 
      gr.m_fillGradientD2 );
3100
 
 
3101
 
      ren.Construct   (renBase ,@span );
3102
 
      render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3103
 
 
3104
 
    end
3105
 
   else
3106
 
    begin
3107
 
     span.Construct(
3108
 
      @gr.m_allocator ,
3109
 
      @gr.m_lineGradientInterpolator ,
3110
 
      @gr.m_radialGradientFunction ,
3111
 
      @gr.m_lineGradient ,
3112
 
      gr.m_lineGradientD1 ,
3113
 
      gr.m_lineGradientD2 );
3114
 
 
3115
 
     ren.Construct   (renBase ,@span );
3116
 
     render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ren );
3117
 
 
3118
 
    end
3119
 
  else
3120
 
   begin
3121
 
    if fillColor_ then
3122
 
     clr.Construct(gr.m_fillColor )
3123
 
    else
3124
 
     clr.Construct(gr.m_lineColor );
3125
 
 
3126
 
    renSolid.color_ (@clr );
3127
 
    render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,renSolid );
3128
 
 
3129
 
   end;
3130
 
 
3131
 
end;
3132
 
 
3133
 
{ AGG2DRENDERER_RENDER }
3134
 
procedure Agg2DRenderer_render(
3135
 
           gr : Agg2D_ptr;
3136
 
           renBase : renderer_base_ptr;
3137
 
           renSolid : renderer_scanline_aa_solid_ptr;
3138
 
           ras : gray8_adaptor_type_ptr;
3139
 
           sl : gray8_scanline_type_ptr );
3140
 
var
3141
 
 span : span_gradient;
3142
 
 ren  : renderer_scanline_aa;
3143
 
 clr  : aggclr;
3144
 
 
3145
 
begin
3146
 
 if gr.m_fillGradientFlag = Linear then
3147
 
  begin
3148
 
   span.Construct(
3149
 
    @gr.m_allocator ,
3150
 
    @gr.m_fillGradientInterpolator ,
3151
 
    @gr.m_linearGradientFunction ,
3152
 
    @gr.m_fillGradient ,
3153
 
    gr.m_fillGradientD1 ,
3154
 
    gr.m_fillGradientD2 );
3155
 
 
3156
 
   ren.Construct   (renBase ,@span );
3157
 
   render_scanlines(ras ,sl ,@ren );
3158
 
 
3159
 
  end
3160
 
 else
3161
 
  if gr.m_fillGradientFlag = Radial then
3162
 
   begin
3163
 
    span.Construct(
3164
 
     @gr.m_allocator ,
3165
 
     @gr.m_fillGradientInterpolator ,
3166
 
     @gr.m_radialGradientFunction ,
3167
 
     @gr.m_fillGradient ,
3168
 
     gr.m_fillGradientD1 ,
3169
 
     gr.m_fillGradientD2 );
3170
 
 
3171
 
    ren.Construct   (renBase ,@span );
3172
 
    render_scanlines(ras ,sl ,@ren );
3173
 
 
3174
 
   end
3175
 
  else
3176
 
   begin
3177
 
    clr.Construct   (gr.m_fillColor );
3178
 
    renSolid.color_ (@clr );
3179
 
    render_scanlines(ras ,sl ,renSolid );
3180
 
 
3181
 
   end;
3182
 
 
3183
 
end;
3184
 
 
3185
 
{ AGG2DRENDERER_RENDERIMAGE }
3186
 
procedure Agg2DRenderer_renderImage(
3187
 
           gr : Agg2D_ptr;
3188
 
           img : Image_ptr;
3189
 
           renBase : renderer_base_ptr;
3190
 
           interpolator : span_interpolator_linear_ptr );
3191
 
var
3192
 
 blend : SpanConvImageBlend;
3193
 
 
3194
 
 si : span_image_filter_rgba;
3195
 
 sg : span_image_filter_rgba_nn;
3196
 
 sb : span_image_filter_rgba_bilinear;
3197
 
 s2 : span_image_filter_rgba_2x2;
3198
 
 sa : span_image_resample_rgba_affine;
3199
 
 sc : span_converter;
3200
 
 ri : renderer_scanline_aa;
3201
 
 
3202
 
 clr : aggclr;
3203
 
 
3204
 
 resample : boolean;
3205
 
 
3206
 
 sx ,sy : double;
3207
 
 
3208
 
begin
3209
 
 blend.Construct(gr.m_imageBlendMode ,gr.m_imageBlendColor ,@gr.m_pixFormatCompPre );
3210
 
 
3211
 
 if gr.m_imageFilter = NoFilter then
3212
 
  begin
3213
 
   clr.ConstrInt(0 ,0 ,0 ,0 );
3214
 
   sg.Construct (@gr.m_allocator ,@img.renBuf ,@clr ,interpolator ,rgba_order );
3215
 
   sc.Construct (@sg ,@blend );
3216
 
   ri.Construct (renBase ,@sc );
3217
 
 
3218
 
   render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3219
 
 
3220
 
  end
3221
 
 else
3222
 
  begin
3223
 
   resample:=gr.m_imageResample = ResampleAlways;
3224
 
 
3225
 
   if gr.m_imageResample = ResampleOnZoomOut then
3226
 
    begin
3227
 
     interpolator._transformer.scaling_abs(@sx ,@sy );
3228
 
 
3229
 
     if (sx > 1.125 ) or
3230
 
        (sy > 1.125 ) then
3231
 
      resample:=true;
3232
 
 
3233
 
    end;
3234
 
 
3235
 
   if resample then
3236
 
    begin
3237
 
     clr.ConstrInt(0 ,0 ,0 ,0 );
3238
 
     sa.Construct(
3239
 
      @gr.m_allocator ,
3240
 
      @img.renBuf ,
3241
 
      @clr ,
3242
 
      interpolator ,
3243
 
      @gr.m_imageFilterLut ,
3244
 
      rgba_order );
3245
 
 
3246
 
     sc.Construct(@sa ,@blend );
3247
 
     ri.Construct(renBase ,@sc );
3248
 
 
3249
 
     render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3250
 
 
3251
 
    end
3252
 
   else
3253
 
    if gr.m_imageFilter = Bilinear then
3254
 
     begin
3255
 
      clr.ConstrInt(0 ,0 ,0 ,0 );
3256
 
      sb.Construct(
3257
 
       @gr.m_allocator ,
3258
 
       @img.renBuf ,
3259
 
       @clr ,
3260
 
       interpolator ,
3261
 
       rgba_order );
3262
 
 
3263
 
      sc.Construct(@sb ,@blend );
3264
 
      ri.Construct(renBase ,@sc );
3265
 
 
3266
 
      render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3267
 
 
3268
 
     end
3269
 
    else
3270
 
     if gr.m_imageFilterLut.diameter = 2 then
3271
 
      begin
3272
 
       clr.ConstrInt(0 ,0 ,0 ,0 );
3273
 
       s2.Construct(
3274
 
        @gr.m_allocator ,
3275
 
        @img.renBuf ,
3276
 
        @clr ,
3277
 
        interpolator,
3278
 
        @gr.m_imageFilterLut ,
3279
 
        rgba_order );
3280
 
 
3281
 
       sc.Construct(@s2 ,@blend );
3282
 
       ri.Construct(renBase ,@sc );
3283
 
 
3284
 
       render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3285
 
 
3286
 
      end
3287
 
     else
3288
 
      begin
3289
 
       clr.ConstrInt(0 ,0 ,0 ,0 );
3290
 
       si.Construct(
3291
 
        @gr.m_allocator ,
3292
 
        @img.renBuf ,
3293
 
        @clr ,
3294
 
        interpolator ,
3295
 
        @gr.m_imageFilterLut ,
3296
 
        rgba_order );
3297
 
 
3298
 
       sc.Construct(@si ,@blend );
3299
 
       ri.Construct(renBase ,@sc );
3300
 
 
3301
 
       render_scanlines(@gr.m_rasterizer ,@gr.m_scanline ,@ri );
3302
 
 
3303
 
      end;
3304
 
 
3305
 
  end;
3306
 
 
3307
 
end;
3308
 
 
3309
 
{ AGG2DUSESFREETYPE }
3310
 
function Agg2DUsesFreeType : boolean;
3311
 
begin
3312
 
{$IFDEF AGG2D_USE_FREETYPE }
3313
 
 result:=true;
3314
 
 
3315
 
{$ELSE }
3316
 
 result:=false;
3317
 
 
3318
 
{$ENDIF }
3319
 
 
3320
 
end;
3321
 
 
3322
 
function Agg2DUsesWin32TrueType: boolean;
3323
 
begin
3324
 
{$IFDEF AGG2D_USE_WINFONTS }
3325
 
 result:=true;
3326
 
 
3327
 
{$ELSE }
3328
 
 result:=false;
3329
 
 
3330
 
{$ENDIF }
3331
 
end;
3332
 
 
3333
 
END.
3334
 
 
3335
 
{!}
3336