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

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_ellipse.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
 
// Anti-Grain Geometry - Version 2.4 (Public License)
3
 
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
 
//
5
 
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
 
// Pascal Port By: Milan Marusinec alias Milano
7
 
//                 milan@marusinec.sk
8
 
//                 http://www.aggpas.org
9
 
// Copyright (c) 2005-2006
10
 
//
11
 
// Permission to copy, use, modify, sell and distribute this software
12
 
// is granted provided this copyright notice appears in all copies.
13
 
// This software is provided "as is" without express or implied
14
 
// warranty, and with no claim as to its suitability for any purpose.
15
 
//
16
 
//----------------------------------------------------------------------------
17
 
// Contact: mcseem@antigrain.com
18
 
//          mcseemagg@yahoo.com
19
 
//          http://www.antigrain.com
20
 
//
21
 
//----------------------------------------------------------------------------
22
 
//
23
 
// class ellipse
24
 
//
25
 
// [Pascal Port History] -----------------------------------------------------
26
 
//
27
 
// 18.12.2005-Milano: Unit port establishment
28
 
//
29
 
{ agg_ellipse.pas }
30
 
unit
31
 
 agg_ellipse ;
32
 
 
33
 
INTERFACE
34
 
 
35
 
{$I agg_mode.inc }
36
 
 
37
 
uses
38
 
 Math ,
39
 
 agg_basics ,
40
 
 agg_vertex_source ;
41
 
 
42
 
{ TYPES DEFINITION }
43
 
type
44
 
 ellipse_ptr = ^ellipse;
45
 
 ellipse = object(vertex_source )
46
 
   m_x  ,
47
 
   m_y  ,
48
 
   m_rx ,
49
 
   m_ry ,
50
 
 
51
 
   m_scale : double;
52
 
 
53
 
   m_num  ,
54
 
   m_step : unsigned;
55
 
   m_cw   : boolean;
56
 
 
57
 
   constructor Construct; overload;
58
 
   constructor Construct(x ,y ,rx ,ry : double; num_steps : unsigned = 0; cw : boolean = false ); overload;
59
 
 
60
 
   procedure init(x ,y ,rx ,ry : double; num_steps : unsigned = 0; cw : boolean = false );
61
 
 
62
 
   procedure approximation_scale_(scale : double );
63
 
 
64
 
   procedure rewind(path_id : unsigned ); virtual;
65
 
   function  vertex(x ,y : double_ptr ) : unsigned; virtual;
66
 
 
67
 
   procedure calc_num_steps;
68
 
 
69
 
  end;
70
 
 
71
 
{ GLOBAL PROCEDURES }
72
 
 
73
 
 
74
 
IMPLEMENTATION
75
 
{ LOCAL VARIABLES & CONSTANTS }
76
 
{ UNIT IMPLEMENTATION }
77
 
{ CONSTRUCT }
78
 
constructor ellipse.Construct;
79
 
begin
80
 
 inherited Construct;
81
 
 
82
 
 m_x :=0.0;
83
 
 m_y :=0.0;
84
 
 m_rx:=1.0;
85
 
 m_ry:=1.0;
86
 
 
87
 
 m_scale:=1.0;
88
 
 
89
 
 m_num :=4;
90
 
 m_step:=0;
91
 
 m_cw  :=false;
92
 
 
93
 
end;
94
 
 
95
 
{ CONSTRUCT }
96
 
constructor ellipse.Construct(x ,y ,rx ,ry : double; num_steps : unsigned = 0; cw : boolean = false );
97
 
begin
98
 
 inherited Construct;
99
 
 
100
 
 m_x :=x;
101
 
 m_y :=y;
102
 
 m_rx:=rx;
103
 
 m_ry:=ry;
104
 
 
105
 
 m_scale:=1.0;
106
 
 
107
 
 m_num :=num_steps;
108
 
 m_step:=0;
109
 
 m_cw  :=cw;
110
 
 
111
 
 if m_num = 0 then
112
 
  calc_num_steps;
113
 
 
114
 
end;
115
 
 
116
 
{ INIT }
117
 
procedure ellipse.init;
118
 
begin
119
 
 m_x :=x;
120
 
 m_y :=y;
121
 
 m_rx:=rx;
122
 
 m_ry:=ry;
123
 
 
124
 
 m_num :=num_steps;
125
 
 m_step:=0;
126
 
 m_cw  :=cw;
127
 
 
128
 
 if m_num = 0 then
129
 
  calc_num_steps;
130
 
 
131
 
end;
132
 
 
133
 
{ APPROXIMATION_SCALE_ }
134
 
procedure ellipse.approximation_scale_;
135
 
begin
136
 
 m_scale:=scale;
137
 
 
138
 
 calc_num_steps;
139
 
 
140
 
end;
141
 
 
142
 
{ REWIND }
143
 
procedure ellipse.rewind;
144
 
begin
145
 
 m_step:=0;
146
 
 
147
 
end;
148
 
 
149
 
{ VERTEX }
150
 
function ellipse.vertex;
151
 
var
152
 
 angle : double;
153
 
 
154
 
begin
155
 
 if m_step = m_num then
156
 
  begin
157
 
   inc(m_step );
158
 
 
159
 
   result:=path_cmd_end_poly or path_flags_close or path_flags_ccw;
160
 
 
161
 
   exit;
162
 
 
163
 
  end;
164
 
 
165
 
 if m_step > m_num then
166
 
  begin
167
 
   result:=path_cmd_stop;
168
 
 
169
 
   exit;
170
 
 
171
 
  end;
172
 
 
173
 
 angle:=m_step / m_num * 2.0 * pi;
174
 
 
175
 
 if m_cw then
176
 
  angle:=2.0 * pi - angle;
177
 
 
178
 
 x^:=m_x + Cos(angle ) * m_rx;
179
 
 y^:=m_y + Sin(angle ) * m_ry;
180
 
 
181
 
 inc(m_step );
182
 
 
183
 
 if m_step = 1 then
184
 
  result:=path_cmd_move_to
185
 
 else
186
 
  result:=path_cmd_line_to;
187
 
 
188
 
end;
189
 
 
190
 
{ CALC_NUM_STEPS }
191
 
procedure ellipse.calc_num_steps;
192
 
var
193
 
 ra ,
194
 
 da : double;
195
 
 
196
 
begin
197
 
 ra:=(Abs(m_rx ) + Abs(m_ry ) ) / 2;
198
 
 da:=ArcCos(ra / (ra + 0.125 / m_scale ) ) * 2;
199
 
 
200
 
 m_num:=trunc(2 * pi / da );
201
 
 
202
 
end;
203
 
 
204
 
END.
205