1
//----------------------------------------------------------------------------
2
// Anti-Grain Geometry - Version 2.4 (Public License)
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
// Pascal Port By: Milan Marusinec alias Milano
8
// http://www.aggpas.org
9
// Copyright (c) 2005-2006
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.
16
//----------------------------------------------------------------------------
17
// Contact: mcseem@antigrain.com
18
// mcseemagg@yahoo.com
19
// http://www.antigrain.com
21
//----------------------------------------------------------------------------
25
// [Pascal Port History] -----------------------------------------------------
27
// 18.12.2005-Milano: Unit port establishment
44
ellipse_ptr = ^ellipse;
45
ellipse = object(vertex_source )
57
constructor Construct; overload;
58
constructor Construct(x ,y ,rx ,ry : double; num_steps : unsigned = 0; cw : boolean = false ); overload;
60
procedure init(x ,y ,rx ,ry : double; num_steps : unsigned = 0; cw : boolean = false );
62
procedure approximation_scale_(scale : double );
64
procedure rewind(path_id : unsigned ); virtual;
65
function vertex(x ,y : double_ptr ) : unsigned; virtual;
67
procedure calc_num_steps;
75
{ LOCAL VARIABLES & CONSTANTS }
76
{ UNIT IMPLEMENTATION }
78
constructor ellipse.Construct;
96
constructor ellipse.Construct(x ,y ,rx ,ry : double; num_steps : unsigned = 0; cw : boolean = false );
117
procedure ellipse.init;
133
{ APPROXIMATION_SCALE_ }
134
procedure ellipse.approximation_scale_;
143
procedure ellipse.rewind;
150
function ellipse.vertex;
155
if m_step = m_num then
159
result:=path_cmd_end_poly or path_flags_close or path_flags_ccw;
165
if m_step > m_num then
167
result:=path_cmd_stop;
173
angle:=m_step / m_num * 2.0 * pi;
176
angle:=2.0 * pi - angle;
178
x^:=m_x + Cos(angle ) * m_rx;
179
y^:=m_y + Sin(angle ) * m_ry;
184
result:=path_cmd_move_to
186
result:=path_cmd_line_to;
191
procedure ellipse.calc_num_steps;
197
ra:=(Abs(m_rx ) + Abs(m_ry ) ) / 2;
198
da:=ArcCos(ra / (ra + 0.125 / m_scale ) ) * 2;
200
m_num:=trunc(2 * pi / da );