71 std::string
const gradient_id = (
id.empty()
101 throw std::runtime_error(
"Invalid SvgPalette direction." );
106 auto const norm_gradient =
color_stops( map, norm );
110 for(
auto const& g : norm_gradient ) {
111 if( g.first < 0.0 || g.first > 1.0 ) {
112 throw std::runtime_error(
"Color Normalization gradient out of [ 0.0, 1.0 ]" );
114 grad.add_stop({ g.first, g.second });
125 return { grad, group };
130 std::map<double, Color>
const& stops
134 for(
auto it = stops.begin(); it != stops.end(); ++it ) {
137 auto const& pos = it->first;
138 auto const& color = it->second;
139 if( !std::isfinite(pos) || pos < 0.0 || pos > 1.0 ) {
140 throw std::runtime_error(
"Color Normalization stops out of [ 0.0, 1.0 ]" );
155 double next_pos = 1.0;
156 if( next != stops.end() ) {
157 next_pos = next->first;
159 assert( next_pos > pos );
164 double w = settings.
width;
165 double h = settings.
height;
169 h = ( next_pos - pos ) * settings.
height;
173 y = pos * settings.
height;
174 h = ( next_pos - pos ) * settings.
height;
178 x = pos * settings.
width;
179 w = ( next_pos - pos ) * settings.
width;
183 x = settings.
width - next_pos * settings.
width;
184 w = ( next_pos - pos ) * settings.
width;
188 throw std::runtime_error(
"Invalid SvgPalette direction." );
218 auto make_tick = [&](
double rel_pos, std::string label ){
219 assert( std::isfinite(rel_pos) && 0.0 <= rel_pos && rel_pos <= 1.0 );
230 v = rel_pos * settings.
height;
234 h = rel_pos * settings.
width;
238 h = settings.
width - ( rel_pos * settings.
width );
242 throw std::runtime_error(
"Invalid SvgPalette direction." );
276 throw std::runtime_error(
"Invalid SvgPalette direction." );
281 if( rel_pos != 0.0 && rel_pos != 1.0 ) {
283 group <<
SvgLine( line1_p1, line1_p2, stroke );
284 group <<
SvgLine( line2_p1, line2_p2, stroke );
287 if( rel_pos == 1.0 && map.
clip_over() ) {
288 label =
"≥ " + label;
291 label =
"≤ " + label;
293 auto text_s =
SvgText( label );
312 for(
auto const& tick : tickmarks ) {
313 if( !std::isfinite(tick.first) || tick.first < 0.0 || tick.first > 1.0 ) {
314 throw std::runtime_error(
"Color Normalization tickmark out of [ 0.0, 1.0 ]" );
316 make_tick( tick.first, tick.second );
329 std::string
const&
id
333 throw std::runtime_error(
334 "Cannot make SvgPalette with a ColorMap of less than two colors."
338 throw std::runtime_error(
339 "Invaid ColorNormalization settings."
344 auto result = std::pair<SvgGradientLinear, SvgGroup>();
349 if( norm_boundary ) {
350 auto const norm_gradient =
color_stops( map, norm );
369 0.0, i * 15.0, 10.0, 10.0,
378 std::vector<std::string>
const&
labels
382 for(
size_t i = 0; i <
labels.size(); ++i ) {
390 std::vector<Color>
const& colors,
391 std::vector<std::string>
const&
labels
393 if( colors.size() !=
labels.size() ) {
394 throw std::invalid_argument(
"List of colors and list of labels have different size." );
398 for(
size_t i = 0; i <
labels.size(); ++i ) {