From 4fbe7d24cf2e30a25dfa53fa55aa2eff8178256d Mon Sep 17 00:00:00 2001 From: YusufovYB Date: Mon, 24 Apr 2023 01:32:36 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=98=D0=BD=D0=B4=D0=B8=D0=B2=D0=B8?= =?UTF-8?q?=D0=B4=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svg.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/svg.cpp b/svg.cpp index b36fdc0..7ef7072 100644 --- a/svg.cpp +++ b/svg.cpp @@ -1,3 +1,4 @@ + #include "svg.h" #include using namespace std; @@ -47,19 +48,42 @@ void show_histogram_svg(const vector &bins){ if (bin > max_count) max_count = bin; } - const auto BLOCK_WIDTH = (IMAGE_WIDTH - TEXT_WIDTH) / max_count; + cout << "Block_wight="; + double BLOCK_WIDTH; + cin >> BLOCK_WIDTH; + bool prov=1; + if((BLOCK_WIDTH<3) || (BLOCK_WIDTH>30)){ + prov=0; + while(prov==0){ + cout<< "Error range from 3 to 30 pi" << endl; + cout<< "Block_wight="; + cin >> BLOCK_WIDTH; + if((BLOCK_WIDTH>3) && (BLOCK_WIDTH<30) ){ + prov=1; + } + } + } + for (size_t bin : bins) { const double bin_width = BLOCK_WIDTH * bin; svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#aaffaa"); + svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "green"); top += BIN_HEIGHT; } - // svg_text(20, 20, std::to_string(bins[0])); - // svg_rect(50, 0, bins[0] * 10, 30); + + + + + + + + + + + svg_end(); } -