1 #ifndef VTESTBED_GRAPHICS_PALETTE_HH 2 #define VTESTBED_GRAPHICS_PALETTE_HH 4 #include <blitz/array.h> 14 using color_type = blitz::TinyVector<T,3>;
17 color_type _colors[3];
20 template <
class ... Color>
22 Palette3(
const Color& ... colors): _colors{colors...} {
23 static_assert(
sizeof...(colors) == 3,
"bad no. of colors");
26 inline color_type operator()(T value)
const {
27 value = blitz::clamp(value, T{-1}, T{1});
28 const auto* colors = this->_colors;
30 if (value < 0) { color = colors[0] + (colors[1]-colors[0])*(value+1); }
31 else { color = colors[1] + (colors[2]-colors[1])*value; }
38 temperaturePalette() {
39 using color_type =
typename Palette3<T>::color_type;
41 color_type{0,0,T{0.878}},
42 color_type{1,1,T{0.878}},
43 color_type{T{0.878},0,0}
51 #endif // vim:filetype=cpp