diff --git a/main.cpp b/main.cpp index 498a824..e2b7482 100644 --- a/main.cpp +++ b/main.cpp @@ -12,7 +12,6 @@ using namespace std; struct Input { vector numbers; size_t bin_count{}; - double USER_BIN_HEIGHT{}; }; Input input_data(istream& stream, bool prompt) { @@ -41,11 +40,6 @@ Input input_data(istream& stream, bool prompt) { } stream >> in.bin_count; - if (prompt){ - cerr << "Enter image height: "; - } - stream >> in.USER_BIN_HEIGHT; - return in; } @@ -78,7 +72,7 @@ int main(int argc, char* argv[]){ auto bins = make_histogram(in.numbers, in.bin_count); - show_histogram_svg(bins, in.USER_BIN_HEIGHT); + show_histogram_svg(bins); } diff --git a/svg.cpp b/svg.cpp index f0ea4ab..3c2b78c 100644 --- a/svg.cpp +++ b/svg.cpp @@ -26,34 +26,8 @@ void svg_rect(double x, double y, double width, double height){ std::cout << ""; } -double calculate_bin_height (const std::vector& bins, double USER_BIN_HEIGHT, double IMAGE_HEIGHT){ - - double BIN_HEIGHT; - - if ( USER_BIN_HEIGHT < 0 ){ - - BIN_HEIGHT = 0; - - } else { - - BIN_HEIGHT = USER_BIN_HEIGHT; - - } - - - - auto USER_IMAGE_HEIGHT = bins.size() * BIN_HEIGHT; - - if (USER_IMAGE_HEIGHT > IMAGE_HEIGHT){ - BIN_HEIGHT = IMAGE_HEIGHT / bins.size(); - } - - return BIN_HEIGHT; - -} - void -show_histogram_svg(const std::vector& bins, double USER_BIN_HEIGHT) { +show_histogram_svg(const std::vector& bins) { const auto IMAGE_WIDTH = 400; const auto IMAGE_HEIGHT = 700; @@ -61,16 +35,13 @@ show_histogram_svg(const std::vector& bins, double USER_BIN_HEIGHT) const auto TEXT_BASELINE = 20; const auto TEXT_WIDTH = 50; const auto BLOCK_WIDTH = 10; + const auto BIN_HEIGHT = 50; - auto BIN_HEIGHT = calculate_bin_height (bins, USER_BIN_HEIGHT, IMAGE_HEIGHT); - - auto USER_IMAGE_HEIGHT = bins.size() * BIN_HEIGHT; - const std::size_t MAX_ASTERISK = IMAGE_WIDTH - TEXT_WIDTH; - svg_begin(IMAGE_WIDTH, USER_IMAGE_HEIGHT); + svg_begin(IMAGE_WIDTH,IMAGE_HEIGHT); double top = 0; diff --git a/svg.h b/svg.h index 7d9b273..c7da98d 100644 --- a/svg.h +++ b/svg.h @@ -4,6 +4,6 @@ #include void -show_histogram_svg(const std::vector& bins, double USER_BIN_HEIGHT); +show_histogram_svg(const std::vector& bins); #endif // SVG_H_INCLUDED