1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 #include "agg_renderer_outline_aa.h"
21 //---------------------------------------------------------------------
22 void line_profile_aa::width(double w
)
26 if(w
< m_smoother_width
) w
+= w
;
27 else w
+= m_smoother_width
;
31 w
-= m_smoother_width
;
32 double s
= m_smoother_width
;
42 //---------------------------------------------------------------------
43 line_profile_aa::value_type
* line_profile_aa::profile(double w
)
45 m_subpixel_width
= int(w
* subpixel_size
);
46 unsigned size
= m_subpixel_width
+ subpixel_size
* 6;
50 m_profile
= new value_type
[m_size
= size
];
56 //---------------------------------------------------------------------
57 void line_profile_aa::set(double center_width
, double _smoother_width
)
59 double base_val
= 1.0;
60 if(center_width
== 0.0) center_width
= 1.0 / subpixel_size
;
61 if(_smoother_width
== 0.0) _smoother_width
= 1.0 / subpixel_size
;
63 double _width
= center_width
+ _smoother_width
;
64 if(_width
< m_min_width
)
66 double k
= _width
/ m_min_width
;
72 value_type
* ch
= profile(center_width
+ _smoother_width
);
74 unsigned subpixel_center_width
= unsigned(center_width
* subpixel_size
);
75 unsigned subpixel_smoother_width
= unsigned(_smoother_width
* subpixel_size
);
77 value_type
* ch_center
= ch
+ subpixel_size
*2;
78 value_type
* ch_smoother
= ch_center
+ subpixel_center_width
;
82 unsigned val
= m_gamma
[unsigned(base_val
* aa_mask
)];
84 for(i
= 0; i
< subpixel_center_width
; i
++)
86 *ch
++ = (value_type
)val
;
89 for(i
= 0; i
< subpixel_smoother_width
; i
++)
92 m_gamma
[unsigned((base_val
-
94 (double(i
) / subpixel_smoother_width
)) * aa_mask
)];
97 unsigned n_smoother
= profile_size() -
98 subpixel_smoother_width
-
99 subpixel_center_width
-
103 for(i
= 0; i
< n_smoother
; i
++)
105 *ch_smoother
++ = (value_type
)val
;
109 for(i
= 0; i
< subpixel_size
*2; i
++)
111 *--ch
= *ch_center
++;