From e5210dd70ac00130717594b46ce7c56ff453e605 Mon Sep 17 00:00:00 2001 From: KIrsanovEs Date: Mon, 24 Apr 2023 11:11:22 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=B3=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D1=8B=20=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=2010=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BD=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svg.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/svg.cpp b/svg.cpp index c6c1a15..81cbf5c 100644 --- a/svg.cpp +++ b/svg.cpp @@ -17,7 +17,7 @@ svg_text(double left, double baseline, string text) { cout << ""<"; } -void svg_rect(double x, double y, double width, double height,string stroke,string fill){ +void svg_rect(double x, double y, double width, double height,string stroke = "black",string fill = "black"){ cout<<""; } void show_histogram_svg(const vector& bins) { @@ -29,15 +29,13 @@ void show_histogram_svg(const vector& bins) { const auto BIN_HEIGHT = 30; const auto BLOCK_WIDTH = 10; svg_begin(400, 300); - svg_text(20, 20, to_string(bins[0])); - svg_rect(50, 0, bins[0] * 10, 30,"red","#ffeeee"); double top = 0; for (size_t bin : bins) { const double 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_text(top + TEXT_BASELINE,TEXT_LEFT , to_string(bin)); + svg_rect((top+10),(TEXT_WIDTH-20) , BIN_HEIGHT,bin_width , "green", "#aaffee"); top += BIN_HEIGHT; -} + } svg_end(); }