~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to agg/include/agg_gradient_lut.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
//
30
30
    public:
31
31
        typedef ColorT color_type;
32
32
 
33
 
        color_interpolator(const color_type& c1, 
34
 
                           const color_type& c2, 
 
33
        color_interpolator(const color_type& c1,
 
34
                           const color_type& c2,
35
35
                           unsigned len) :
36
36
            m_c1(c1),
37
37
            m_c2(c2),
63
63
    public:
64
64
        typedef rgba8 color_type;
65
65
 
66
 
        color_interpolator(const color_type& c1, 
67
 
                           const color_type& c2, 
 
66
        color_interpolator(const color_type& c1,
 
67
                           const color_type& c2,
68
68
                           unsigned len) :
69
69
            r(c1.r, c2.r, len),
70
70
            g(c1.g, c2.g, len),
93
93
    public:
94
94
        typedef gray8 color_type;
95
95
 
96
 
        color_interpolator(const color_type& c1, 
97
 
                           const color_type& c2, 
 
96
        color_interpolator(const color_type& c1,
 
97
                           const color_type& c2,
98
98
                           unsigned len) :
99
99
            v(c1.v, c2.v, len),
100
100
            a(c1.a, c2.a, len)
115
115
    };
116
116
 
117
117
    //============================================================gradient_lut
118
 
    template<class ColorInterpolator, 
 
118
    template<class ColorInterpolator,
119
119
             unsigned ColorLutSize=256> class gradient_lut
120
120
    {
121
121
    public:
127
127
        gradient_lut() : m_color_lut(color_lut_size) {}
128
128
 
129
129
        // Build Gradient Lut
130
 
        // First, call remove_all(), then add_color() at least twice, 
131
 
        // then build_lut(). Argument "offset" in add_color must be 
132
 
        // in range [0...1] and defines a color stop as it is described 
133
 
        // in SVG specification, section Gradients and Patterns. 
 
130
        // First, call remove_all(), then add_color() at least twice,
 
131
        // then build_lut(). Argument "offset" in add_color must be
 
132
        // in range [0...1] and defines a color stop as it is described
 
133
        // in SVG specification, section Gradients and Patterns.
134
134
        // The simplest linear gradient is:
135
135
        //    gradient_lut.add_color(0.0, start_color);
136
136
        //    gradient_lut.add_color(1.0, end_color);
139
139
        void add_color(double offset, const color_type& color);
140
140
        void build_lut();
141
141
 
142
 
        // Size-index Interface. This class can be used directly as the 
143
 
        // ColorF in span_gradient. All it needs is two access methods 
 
142
        // Size-index Interface. This class can be used directly as the
 
143
        // ColorF in span_gradient. All it needs is two access methods
144
144
        // size() and operator [].
145
145
        //--------------------------------------------------------------------
146
 
        static unsigned size() 
147
 
        { 
148
 
            return color_lut_size; 
 
146
        static unsigned size()
 
147
        {
 
148
            return color_lut_size;
149
149
        }
150
 
        const color_type& operator [] (unsigned i) const 
151
 
        { 
152
 
            return m_color_lut[i]; 
 
150
        const color_type& operator [] (unsigned i) const
 
151
        {
 
152
            return m_color_lut[i];
153
153
        }
154
154
 
155
155
    private:
160
160
            color_type color;
161
161
 
162
162
            color_point() {}
163
 
            color_point(double off, const color_type& c) : 
 
163
            color_point(double off, const color_type& c) :
164
164
                offset(off), color(c)
165
165
            {
166
166
                if(offset < 0.0) offset = 0.0;
189
189
    //------------------------------------------------------------------------
190
190
    template<class T, unsigned S>
191
191
    void gradient_lut<T,S>::remove_all()
192
 
    { 
193
 
        m_color_profile.remove_all(); 
 
192
    {
 
193
        m_color_profile.remove_all();
194
194
    }
195
195
 
196
196
    //------------------------------------------------------------------------
212
212
            unsigned start = uround(m_color_profile[0].offset * color_lut_size);
213
213
            unsigned end;
214
214
            color_type c = m_color_profile[0].color;
215
 
            for(i = 0; i < start; i++) 
 
215
            for(i = 0; i < start; i++)
216
216
            {
217
217
                m_color_lut[i] = c;
218
218
            }
219
219
            for(i = 1; i < m_color_profile.size(); i++)
220
220
            {
221
221
                end  = uround(m_color_profile[i].offset * color_lut_size);
222
 
                interpolator_type ci(m_color_profile[i-1].color, 
223
 
                                     m_color_profile[i  ].color, 
 
222
                interpolator_type ci(m_color_profile[i-1].color,
 
223
                                     m_color_profile[i  ].color,
224
224
                                     end - start + 1);
225
225
                while(start < end)
226
226
                {