code: разрешен конфликт/добавлен поток чтения

main
TabolinIA 11 месяцев назад
Родитель 1be9b504cc 47c9936890
Сommit 12d7d4c0af

@ -30,7 +30,7 @@ void svg_rect(double x, double y, double width, double height, string stroke = "
void
show_histogram_svg(const vector<size_t>& bins) {
show_histogram_svg(const vector<size_t>& bins, size_t user_block_width) {
const auto IMAGE_WIDTH = 400;
const auto IMAGE_HEIGHT = 300;
@ -38,7 +38,7 @@ show_histogram_svg(const vector<size_t>& bins) {
const auto TEXT_BASELINE = 20;
const auto TEXT_WIDTH = 50;
const auto BIN_HEIGHT = 30;
const auto BLOCK_WIDTH = 10;
const auto BLOCK_WIDTH = user_block_width;
const size_t MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH - 1;
@ -49,27 +49,24 @@ show_histogram_svg(const vector<size_t>& bins) {
}
}
if (maxbin > MAX_WIDTH) {
svg_begin(400, 300);
svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
double top = 0;
if (maxbin<=76){
for (size_t bin : bins) {
const double bin_width = MAX_WIDTH * (bin / maxbin);
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);
top += BIN_HEIGHT;
}
svg_end();
}
svg_begin(400, 300);
double top = 0;
} else {
for (size_t bin : bins) {
const double bin_width = BLOCK_WIDTH * bin;
double bin_width= MAX_WIDTH * (static_cast<double>(bin) / maxbin);
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
top += BIN_HEIGHT;
}
svg_end();
}
}

@ -1,6 +1,6 @@
#ifndef SVG_H_INCLUDED
#define SVG_H_INCLUDED
void
show_histogram_svg(const std::vector<size_t>& bins);
show_histogram_svg(const std::vector<size_t>& bins, size_t user_block_width);
#endif // SVG_H_INCLUDED

Загрузка…
Отмена
Сохранить