From b9cfc11921d083ea3a5b4bdb39904ff3b27c3164 Mon Sep 17 00:00:00 2001 From: byvs Date: Tue, 21 May 2024 23:16:48 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=BE=D0=B1=D1=89=D0=B8=D0=B9=20=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svg.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/svg.cpp b/svg.cpp index fba8a7a..c54d176 100644 --- a/svg.cpp +++ b/svg.cpp @@ -15,28 +15,14 @@ void svg_end() { std::cout << "\n"; } -void svg_text(double left, double baseline, std::string text, std::size_t font_size) { - std::cout << "" << text << ""; +void svg_text(double left, double baseline, std::string text) { + std::cout << "" << text << ""; } void svg_rect(double x, double y, double width, double height, std::string stroke = "black", std::string fill = "black") { std::cout << ""; } -std::size_t in_font_size() { - std::size_t font_size; - do{ - std::cerr << "Enter font size >>"; - std::cin >> font_size; - if (font_size < 8 || font_size > 32) { - std::cerr << "Please, observe the range 8-32!" << std::endl; - } - }while(font_size < 8 || font_size > 32); - - return font_size; -} - - void show_histogram_svg(const std::vector& bins) { const auto IMAGE_WIDTH = 400; @@ -46,7 +32,6 @@ void show_histogram_svg(const std::vector& bins) { const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; const auto BLOCK_WIDTH = 10; - std::size_t font_size = in_font_size(); const std::size_t MAX_ASTERISK = IMAGE_WIDTH - TEXT_WIDTH; svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT); @@ -62,7 +47,7 @@ void show_histogram_svg(const std::vector& bins) { if (maxbin<=76) { for (std::size_t i=0; i < bins.size(); i++) { double bin_width= MAX_ASTERISK * (static_cast(bins[i]) / maxbin); - svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]), font_size); + svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i])); svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); top += BIN_HEIGHT; } @@ -71,7 +56,7 @@ void show_histogram_svg(const std::vector& bins) { else { for (std::size_t i=0; i < bins.size(); i++) { double bin_width = BLOCK_WIDTH * bins[i]; - svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]), font_size); + svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i])); svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); top += BIN_HEIGHT; }