~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to agg/include/agg_span_gradient.h

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Anti-Grain Geometry - Version 2.4
3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
4
//
5
 
// Permission to copy, use, modify, sell and distribute this software 
6
 
// is granted provided this copyright notice appears in all copies. 
 
5
// Permission to copy, use, modify, sell and distribute this software
 
6
// is granted provided this copyright notice appears in all copies.
7
7
// This software is provided "as is" without express or implied
8
8
// warranty, and with no claim as to its suitability for any purpose.
9
9
//
39
39
    //==========================================================span_gradient
40
40
    template<class ColorT,
41
41
             class Interpolator,
42
 
             class GradientF, 
 
42
             class GradientF,
43
43
             class ColorF>
44
44
    class span_gradient
45
45
    {
49
49
 
50
50
        enum downscale_shift_e
51
51
        {
52
 
            downscale_shift = interpolator_type::subpixel_shift - 
 
52
            downscale_shift = interpolator_type::subpixel_shift -
53
53
                              gradient_subpixel_shift
54
54
        };
55
55
 
60
60
        span_gradient(interpolator_type& inter,
61
61
                      const GradientF& gradient_function,
62
62
                      const ColorF& color_function,
63
 
                      double d1, double d2) : 
 
63
                      double d1, double d2) :
64
64
            m_interpolator(&inter),
65
65
            m_gradient_function(&gradient_function),
66
66
            m_color_function(&color_function),
87
87
 
88
88
        //--------------------------------------------------------------------
89
89
        void generate(color_type* span, int x, int y, unsigned len)
90
 
        {   
 
90
        {
91
91
            int dd = m_d2 - m_d1;
92
92
            if(dd < 1) dd = 1;
93
93
            m_interpolator->begin(x+0.5, y+0.5, len);
94
94
            do
95
95
            {
96
96
                m_interpolator->coordinates(&x, &y);
97
 
                int d = m_gradient_function->calculate(x >> downscale_shift, 
 
97
                int d = m_gradient_function->calculate(x >> downscale_shift,
98
98
                                                       y >> downscale_shift, m_d2);
99
99
                d = ((d - m_d1) * (int)m_color_function->size()) / dd;
100
100
                if(d < 0) d = 0;
117
117
 
118
118
 
119
119
    //=====================================================gradient_linear_color
120
 
    template<class ColorT> 
 
120
    template<class ColorT>
121
121
    struct gradient_linear_color
122
122
    {
123
123
        typedef ColorT color_type;
124
124
 
125
125
        gradient_linear_color() {}
126
 
        gradient_linear_color(const color_type& c1, const color_type& c2, 
 
126
        gradient_linear_color(const color_type& c1, const color_type& c2,
127
127
                              unsigned size = 256) :
128
128
            m_c1(c1), m_c2(c2), m_size(size) {}
129
129
 
130
130
        unsigned size() const { return m_size; }
131
 
        color_type operator [] (unsigned v) const 
 
131
        color_type operator [] (unsigned v) const
132
132
        {
133
133
            return m_c1.gradient(m_c2, double(v) / double(m_size - 1));
134
134
        }
187
187
    {
188
188
    public:
189
189
        //---------------------------------------------------------------------
190
 
        gradient_radial_focus() : 
191
 
            m_r(100 * gradient_subpixel_scale), 
192
 
            m_fx(0), 
 
190
        gradient_radial_focus() :
 
191
            m_r(100 * gradient_subpixel_scale),
 
192
            m_fx(0),
193
193
            m_fy(0)
194
194
        {
195
195
            update_values();
196
196
        }
197
197
 
198
198
        //---------------------------------------------------------------------
199
 
        gradient_radial_focus(double r, double fx, double fy) : 
200
 
            m_r (iround(r  * gradient_subpixel_scale)), 
201
 
            m_fx(iround(fx * gradient_subpixel_scale)), 
 
199
        gradient_radial_focus(double r, double fx, double fy) :
 
200
            m_r (iround(r  * gradient_subpixel_scale)),
 
201
            m_fx(iround(fx * gradient_subpixel_scale)),
202
202
            m_fy(iround(fy * gradient_subpixel_scale))
203
203
        {
204
204
            update_values();
282
282
    class gradient_diamond
283
283
    {
284
284
    public:
285
 
        static AGG_INLINE int calculate(int x, int y, int) 
286
 
        { 
 
285
        static AGG_INLINE int calculate(int x, int y, int)
 
286
        {
287
287
            int ax = abs(x);
288
288
            int ay = abs(y);
289
 
            return ax > ay ? ax : ay; 
 
289
            return ax > ay ? ax : ay;
290
290
        }
291
291
    };
292
292
 
294
294
    class gradient_xy
295
295
    {
296
296
    public:
297
 
        static AGG_INLINE int calculate(int x, int y, int d) 
298
 
        { 
299
 
            return abs(x) * abs(y) / d; 
 
297
        static AGG_INLINE int calculate(int x, int y, int d)
 
298
        {
 
299
            return abs(x) * abs(y) / d;
300
300
        }
301
301
    };
302
302
 
304
304
    class gradient_sqrt_xy
305
305
    {
306
306
    public:
307
 
        static AGG_INLINE int calculate(int x, int y, int) 
308
 
        { 
309
 
            return fast_sqrt(abs(x) * abs(y)); 
 
307
        static AGG_INLINE int calculate(int x, int y, int)
 
308
        {
 
309
            return fast_sqrt(abs(x) * abs(y));
310
310
        }
311
311
    };
312
312
 
314
314
    class gradient_conic
315
315
    {
316
316
    public:
317
 
        static AGG_INLINE int calculate(int x, int y, int d) 
318
 
        { 
 
317
        static AGG_INLINE int calculate(int x, int y, int d)
 
318
        {
319
319
            return uround(fabs(atan2(double(y), double(x))) * double(d) / pi);
320
320
        }
321
321
    };
324
324
    template<class GradientF> class gradient_repeat_adaptor
325
325
    {
326
326
    public:
327
 
        gradient_repeat_adaptor(const GradientF& gradient) : 
 
327
        gradient_repeat_adaptor(const GradientF& gradient) :
328
328
            m_gradient(&gradient) {}
329
329
 
330
330
        AGG_INLINE int calculate(int x, int y, int d) const
342
342
    template<class GradientF> class gradient_reflect_adaptor
343
343
    {
344
344
    public:
345
 
        gradient_reflect_adaptor(const GradientF& gradient) : 
 
345
        gradient_reflect_adaptor(const GradientF& gradient) :
346
346
            m_gradient(&gradient) {}
347
347
 
348
348
        AGG_INLINE int calculate(int x, int y, int d) const