13 #ifndef OGLPLUS_IMAGES_GRADIENT_1211090818_HPP 
   14 #define OGLPLUS_IMAGES_GRADIENT_1211090818_HPP 
   36     > 
static void _make_gradient(
 
   43         auto point_cur = points.begin(), point_end = points.end();
 
   44         auto grad_cur = gradient.begin(), grad_end = gradient.end();
 
   46         const P step = P(1)/P(dimension);
 
   56         for(GLsizei p=0; p!=dimension; ++p)
 
   58             if(point_cur != point_end)
 
   60                 if(point_cur->first <= curr_point)
 
   62                     prev_point = point_cur->first;
 
   67                         prev_color = point_cur->second;
 
   68                         next_point = npp->first;
 
   69                         next_color = npp->second;
 
   74                         prev_color = background;
 
   76                         next_color = background;
 
   81                     next_point = point_cur->first;
 
   85             if(prev_point != next_point)
 
   86                 factor =(curr_point - prev_point)/
 
   87                     (next_point - prev_point);
 
   89             assert(grad_cur != grad_end);
 
   90             *grad_cur = prev_color*(P(1)-factor)+next_color*factor;
 
   95         assert(grad_cur == grad_end);
 
   96         OGLPLUS_FAKE_USE(grad_end);
 
   99     static GLubyte _cc_max(
void)
 
  104     template <
typename T>
 
  107         if(v < 
T(0)) 
return T(0);
 
  108         if(v > 
T(1)) 
return T(1);
 
  112     template <
typename T, std::
size_t N>
 
  113     static void _apply_gradient(
 
  119         auto gb0 = grad0.begin(), ge0 = grad0.end();
 
  121         for(
auto gp0=gb0; gp0!=ge0; ++gp0)
 
  124             for(std::size_t c=0; c!=N; ++c)
 
  127                 *dp++ = GLubyte(_clamp(color.
At(c))*_cc_max());
 
  130         OGLPLUS_FAKE_USE(de);
 
  134     template <
typename Combine, 
typename T, std::
size_t N>
 
  135     static void _apply_gradient(
 
  143         auto gb0 = grad0.begin(), ge0 = grad0.end();
 
  144         auto gb1 = grad1.begin(), ge1 = grad1.end();
 
  146         for(
auto gp0=gb0; gp0!=ge0; ++gp0)
 
  147         for(
auto gp1=gb1; gp1!=ge1; ++gp1)
 
  150             for(std::size_t c=0; c!=N; ++c)
 
  153                 *dp++ = GLubyte(_clamp(color.
At(c))*_cc_max());
 
  156         OGLPLUS_FAKE_USE(de);
 
  160     template <
typename Combine, 
typename T, std::
size_t N>
 
  161     static void _apply_gradient(
 
  170         auto gb0 = grad0.begin(), ge0 = grad0.end();
 
  171         auto gb1 = grad1.begin(), ge1 = grad1.end();
 
  172         auto gb2 = grad2.begin(), ge2 = grad2.end();
 
  174         for(
auto gp0=gb0; gp0!=ge0; ++gp0)
 
  175         for(
auto gp1=gb1; gp1!=ge1; ++gp1)
 
  176         for(
auto gp2=gb2; gp2!=ge2; ++gp2)
 
  179             for(std::size_t c=0; c!=N; ++c)
 
  182                 *dp++ = GLubyte(_clamp(color.
At(c))*_cc_max());
 
  185         OGLPLUS_FAKE_USE(de);
 
  191         template <
typename T, std::
size_t N>
 
  200         template <
typename T, std::
size_t N>
 
  211     template <
typename P, 
typename T, std::
size_t N>
 
  216     ): 
Image(width, 1, 1, N, (GLubyte*)0)
 
  218         std::vector<Vector<T, N>> x_gradient(width);
 
  225         _apply_gradient(x_gradient, _begin_ub(), _end_ub());
 
  228     template <
typename P, 
typename T, std::
size_t N, 
typename Combine>
 
  236     ): 
Image(width, height, 1, N, (GLubyte*)0)
 
  238         std::vector<Vector<T, N>> y_gradient(height);
 
  246         std::vector<Vector<T, N>> x_gradient(width);
 
  263     template <
typename P, 
typename T, std::
size_t N, 
typename Combine>
 
  273     ): 
Image(width, height, depth, N, (GLubyte*)0)
 
  275         std::vector<Vector<T, N>> z_gradient(depth);
 
  283         std::vector<Vector<T, N>> y_gradient(height);
 
  291         std::vector<Vector<T, N>> x_gradient(width);
 
  313 #endif // include guard 
T At(const Vector &vector, std::size_t i) const T x(void) const 
Returns the value of the i-th coordinate of the vector. 
Definition: vector.hpp:221
 
Wrapper for (texture) image data. 
Definition: image.hpp:45
 
Creates a 1D, 2D or 3D linear gradient image. 
Definition: gradient.hpp:28
 
Basic template for vector types. 
Definition: fwd.hpp:43