50 std::vector<Color> result;
61 for(
size_t i = 0; i < n; ++i ) {
62 auto const pos =
static_cast<double>( i ) /
static_cast<double>( n - 1 );
63 result.push_back(
operator()( pos ));
71 if( palette_.size() == 0 ) {
72 return Color( 0.0, 0.0, 0.0 );
74 if( palette_.size() == 1 ) {
79 if( ! std::isfinite( value ) ) {
83 value = std::max( 0.0, value );
86 value = std::min( value, 1.0 );
96 assert( value >= 0.0 && value <= 1.0 );
97 assert( palette_.size() > 0 );
100 auto const val_entry =
static_cast<double>( palette_.size() - 1 ) * value;
101 assert( val_entry >= 0 );
102 assert( val_entry <
static_cast<double>( palette_.size() ));
110 auto const low_idx =
static_cast<size_t>( std::floor( val_entry ) );
111 auto const high_idx =
static_cast<size_t>( std::ceil( val_entry ) );
112 if( low_idx == high_idx ) {
113 return get_entry_( low_idx );
115 assert( low_idx < high_idx );
118 auto const fraction = val_entry - std::floor( val_entry );
119 assert( fraction >= 0.0 && fraction <= 1.0 );
122 return interpolate( get_entry_( low_idx ), get_entry_( high_idx ), fraction );
127 using it_type = std::vector<double>::const_iterator;
128 return operator()<it_type>( values.begin(), values.end() );
139 using it_type = std::vector<double>::const_iterator;
140 return operator()<it_type>( norm, values.begin(), values.end() );