From 0437f9e1c389bdef4b1ae7f417a53b605a9ef5b5 Mon Sep 17 00:00:00 2001 From: GladkyMS Date: Sun, 29 Sep 2024 21:13:27 +0300 Subject: [PATCH] personal variant final --- histogram_internal.h | 5 ++++- svg.cpp | 9 +++++---- svg.h | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/histogram_internal.h b/histogram_internal.h index 3fb3176..6b4b372 100644 --- a/histogram_internal.h +++ b/histogram_internal.h @@ -1,4 +1,7 @@ #pragma once #include +#include -void find_minmax(const std::vector& numbers, double& min, double& max); \ No newline at end of file +void find_minmax(const std::vector& numbers, double& min, double& max); +std::string +bin_color(size_t bin, size_t mxbins); diff --git a/svg.cpp b/svg.cpp index a5de7fc..ace0f9f 100644 --- a/svg.cpp +++ b/svg.cpp @@ -22,6 +22,9 @@ svg_text(double left, double baseline, std::string text) { void svg_rect(double x, double y, double width, double height,std::string stroke = "black", std::string fill = "black") { std::cout << ""; } +//std::string bin_color(size_t bin, size_t mxbins) { +// return("#" + std::to_string((10 - floor((bin) * 9 / mxbins))) + std::to_string((10 - floor((bin) * 9 / mxbins))) + std::to_string((10 - floor((bin) * 9 / mxbins)))); +//} void show_histogram_svg(const std::vector& bins, size_t bin_count) { const auto IMAGE_WIDTH = 400; @@ -45,12 +48,10 @@ void show_histogram_svg(const std::vector& bins, size_t bin_count) { svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT); double top = 0; for (size_t bin : bins) { - int key = (10 - floor((bin) * 9 / mxbins)); - std::string color = "#" +std::to_string(key)+ std::to_string(key)+ std::to_string(key); - + /* std::string color = bin_color(bin,mxbins);*/ const double bin_width = BLOCK_WIDTH * bin*k; svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,color,color); + svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#ffeeee");///color,color для персонального варианта top += BIN_HEIGHT; } svg_end(); diff --git a/svg.h b/svg.h index b96b4c6..01ebb47 100644 --- a/svg.h +++ b/svg.h @@ -1,4 +1,19 @@ #pragma once #include +#include +void +svg_begin(double width, double height); -void show_histogram_svg(const std::vector& bins, size_t bin_count); \ No newline at end of file +void +svg_end(); + +void show_histogram_svg(const std::vector& bins, size_t bin_count); + +void +svg_text(double left, double baseline, std::string text); + +//std::string +//bin_color(size_t bin, size_t mxbins); + +void +svg_rect(double x, double y, double width, double height, std::string stroke , std::string fill );