14 template<
typename PValue >
18 const Color &_firstColor,
19 const Color &_lastColor)
20 : myMin(_minV), myMax(_maxV)
31 template<
typename PValue >
34 : myMin(_other.myMin), myMax(_other.myMax), myColors(_other.myColors)
40 template<
typename PValue >
56 template<
typename PValue >
63 template<
typename PValue >
67 myColors.push_back(_color);
70 template<
typename PValue >
77 template<
typename PValue >
84 template<
typename PValue >
91 template<
typename PValue >
100 if(_colors.size() < 2)
105 double scale =
static_cast< double >(_value - _min) / (_max - _min);
106 const int intervals = (
const int)_colors.size() - 1;
107 int upper_index =
static_cast< int >(ceil(intervals * scale));
112 const Color &firstColor = _colors[upper_index - 1];
113 const Color &lastColor = _colors[upper_index];
114 scale = (scale * intervals) - (upper_index - 1);
116 const unsigned char red =
static_cast< unsigned char >(
117 firstColor.
red() + scale * (lastColor.
red() - firstColor.
red()));
118 const unsigned char green =
static_cast< unsigned char >(
119 firstColor.
green() + scale * (lastColor.
green() - firstColor.
green()));
120 const unsigned char blue =
static_cast< unsigned char >(
121 firstColor.
blue() + scale * (lastColor.
blue() - firstColor.
blue()));
122 return Color(red, green, blue);