From f8923976e5eda3485c87fc334691a8aa57195d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D1=91=D0=BD=D0=B0=20=D0=90=D1=83=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Wed, 7 Jun 2023 10:52:40 +0300 Subject: [PATCH] fff --- svg.cpp | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 5 deletions(-) diff --git a/svg.cpp b/svg.cpp index 467d8a3..ba66370 100644 --- a/svg.cpp +++ b/svg.cpp @@ -1,11 +1,14 @@ +#include #include +#include #include +#include #include "svg.h" using namespace std; - void -svg_begin(double width, double height) { +svg_begin(double width, double height) +{ cout << "\n"; cout << "\n"; } void -show_histogram_svg(const vector &bins) { - svg_begin(400, 300); +svg_text(double left, double baseline, string text) +{ + cout << "" << text << ""; +} + +void +svg_rect(double x, double y, double width, double height, string stroke, string fill) +{ + cout << ""; + +} + + +void +show_histogram_svg(const vector& bins, size_t number_count) +{ + setlocale(LC_ALL, "Russian"); + int noi=0; + auto IMAGE_WIDTH = 0; + const auto IMAGE_HEIGHT = 300; + const auto TEXT_LEFT = 20; + const auto TEXT_BASELINE = 20; + const auto TEXT_WIDTH = 50; + const auto BIN_HEIGHT = 30; + const auto BLOCK_WIDTH = 10; + const auto MAX_WIDTH = IMAGE_WIDTH-TEXT_WIDTH; +// + cerr<<"Ââåäèòå æåëàåìóþ øèðèíó ñòðîêè"; + //cerr<>IMAGE_WIDTH; + while (noi == 0) + { + cerr<<" in cicle"; + //cerr<> IMAGE_WIDTH; + if ((IMAGE_WIDTH<800)&&(IMAGE_WIDTH>70)&&(IMAGE_WIDTH>(number_count*BLOCK_WIDTH)/3)) + { + noi=noi+1; + } + + if (IMAGE_WIDTH>800) + { + cerr<<" ß æå ñêàçàë ìåíüøå 800. Ââåäèòå çàíîâî"; + // cerr< max_count) + max_count = bins[i]; + } + for (size_t bin : bins) + { + const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH)*(bin/max_count); + svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); + /*/ + cout<<"Ââåäèòå öâåò 1 â ôîðìàòå #RRGGBB"; + cin>> k; + cout<> m; + /*/ + svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,"#00CCFF" /*/k/*/,"#0000FF" /*/m/*/); + top += BIN_HEIGHT; + } + svg_end(); }