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
//----------------------------------------------------------------------------
23
// Rounded rectangle vertex generator
25
// [Pascal Port History] -----------------------------------------------------
27
// 17.01.2006-Milano: Unit port establishment
29
{ agg_rounded_rect.pas }
43
rounded_rect = object(vertex_source )
60
constructor Construct; overload;
61
constructor Construct(x1 ,y1 ,x2 ,y2 ,r : double ); overload;
63
procedure rect(x1 ,y1 ,x2 ,y2 : double );
65
procedure radius(r : double ); overload;
66
procedure radius(rx ,ry : double ); overload;
67
procedure radius(rx_bottom ,ry_bottom ,rx_top ,ry_top : double ); overload;
68
procedure radius(rx1 ,ry1 ,rx2 ,ry2 ,rx3 ,ry3 ,rx4 ,ry4 : double ); overload;
70
procedure normalize_radius;
72
procedure approximation_scale_(s : double );
73
function _approximation_scale : double;
75
procedure rewind(path_id : unsigned ); virtual;
76
function vertex(x ,y : double_ptr ) : unsigned; virtual;
84
{ LOCAL VARIABLES & CONSTANTS }
85
{ UNIT IMPLEMENTATION }
87
constructor rounded_rect.Construct;
109
constructor rounded_rect.Construct(x1 ,y1 ,x2 ,y2 ,r : double );
143
procedure rounded_rect.rect;
167
procedure rounded_rect.radius(r : double );
181
procedure rounded_rect.radius(rx ,ry : double );
195
procedure rounded_rect.radius(rx_bottom ,ry_bottom ,rx_top ,ry_top : double );
209
procedure rounded_rect.radius(rx1 ,ry1 ,rx2 ,ry2 ,rx3 ,ry3 ,rx4 ,ry4 : double );
223
procedure rounded_rect.normalize_radius;
225
dx ,dy ,k ,t : double;
228
dx:=Abs(m_y2 - m_y1 );
229
dy:=Abs(m_x2 - m_x1 );
234
t:=dx / (m_rx1 + m_rx2 );
243
t:=dx / (m_rx3 + m_rx4 );
252
t:=dy / (m_ry1 + m_ry2 );
261
t:=dy / (m_ry3 + m_ry4 );
284
{ APPROXIMATION_SCALE_ }
285
procedure rounded_rect.approximation_scale_;
287
m_arc.approximation_scale_(s );
291
{ _APPROXIMATION_SCALE }
292
function rounded_rect._approximation_scale;
294
result:=m_arc._approximation_scale;
299
procedure rounded_rect.rewind;
306
function rounded_rect.vertex;
311
_1 ,_2 ,_3 ,_4 ,_5 ,_6 ,_7 ,_8 ;
319
m_arc.init (m_x1 + m_rx1 ,m_y1 + m_ry1 ,m_rx1 ,m_ry1 ,pi ,pi + pi * 0.5 );
331
cmd:=m_arc.vertex(x ,y );
333
if is_stop(cmd ) then
353
m_arc.init (m_x2 - m_rx2 ,m_y1 + m_ry2 ,m_rx2 ,m_ry2 ,pi + pi * 0.5 ,0.0 );
365
cmd:=m_arc.vertex(x ,y );
367
if is_stop(cmd ) then
376
result:=path_cmd_line_to;
387
m_arc.init (m_x2 - m_rx3 ,m_y2 - m_ry3 ,m_rx3 ,m_ry3 ,0.0 ,pi * 0.5 );
399
cmd:=m_arc.vertex(x ,y );
401
if is_stop(cmd ) then
410
result:=path_cmd_line_to;
421
m_arc.init (m_x1 + m_rx4 ,m_y2 - m_ry4 ,m_rx4 ,m_ry4 ,pi * 0.5 ,pi );
433
cmd:=m_arc.vertex(x ,y );
435
if is_stop(cmd ) then
444
result:=path_cmd_line_to;
455
cmd:=path_cmd_end_poly or path_flags_close or path_flags_ccw;