diff --git a/svg.cpp b/svg.cpp index ec6bcf4..6bbef8b 100644 --- a/svg.cpp +++ b/svg.cpp @@ -27,10 +27,18 @@ void svg_text(double left, double baseline, string text) { void svg_rect(double x, double y, double width, double height, string stroke, string fill){ cout << ""; + " ' stroke=' " << stroke << "' fill=' " << fill << " '/>"; } void show_histogram_svg( vector& bins) { + + string colours[bins.size()]; + cerr << "Enter colours: " << endl; + for (size_t i = 0; i < bins.size(); i++) { + cerr << "Enter [" << i << "]: "; cin >> colours[i]; + } + + const auto IMAGE_WIDTH = 400; const auto IMAGE_HEIGHT = 300; const auto TEXT_LEFT = 20; @@ -56,7 +64,7 @@ void show_histogram_svg( vector& bins) { bin_width = MAX_ASTERISK * bins[i] / maxb; } svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i])); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#aaffaa"); + svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT , "#aaffaa", colours [i]); top += BIN_HEIGHT; } svg_end();