diff --git a/svg.cpp b/svg.cpp index ae837dc..41250c6 100644 --- a/svg.cpp +++ b/svg.cpp @@ -25,7 +25,7 @@ svg_text(double left, double baseline, string text) { } void svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black"){ - cout << ""; + cout << ""; } void @@ -50,20 +50,22 @@ show_histogram_svg(const vector& bins) { if (bins[j] > maxb) maxb = bins[j]; } - maxb = maxb * BLOCK_WIDTH; + double maxb1 = maxb * BLOCK_WIDTH; for (size_t bin : bins) { double bin_width; - if (maxb > MAX_ASTERISK) + int color = (10 - (bin * 9) / maxb); + + if (maxb1 > MAX_ASTERISK) { - bin_width = BLOCK_WIDTH * MAX_ASTERISK * (bin / maxb); + bin_width = BLOCK_WIDTH * MAX_ASTERISK * (bin / maxb1); } else bin_width = BLOCK_WIDTH * bin; svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "ffeeee"); + svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "violet", to_string(color)); top += BIN_HEIGHT; }