personal var
Этот коммит содержится в:
11
svg.cpp
11
svg.cpp
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const auto IMAGE_WIDTH = 400;
|
const auto IMAGE_WIDTH = 300;
|
||||||
const auto IMAGE_HEIGHT = 300;
|
const auto IMAGE_HEIGHT = 400;
|
||||||
const auto TEXT_LEFT = 20;
|
const auto TEXT_LEFT = 10;
|
||||||
const auto TEXT_BASELINE = 20;
|
const auto TEXT_BASELINE = 20;
|
||||||
const auto TEXT_WIDTH = 50;
|
const auto TEXT_WIDTH = 50;
|
||||||
const auto BIN_HEIGHT = 30;
|
const auto BIN_HEIGHT = 30;
|
||||||
@@ -54,8 +54,9 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|||||||
double top = 0;
|
double top = 0;
|
||||||
for (size_t bin : bins) {
|
for (size_t bin : bins) {
|
||||||
const double bin_width = BLOCK_WIDTH * bin;
|
const double bin_width = BLOCK_WIDTH * bin;
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
double bin_height = bin_width / scale;
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width / scale, BIN_HEIGHT, stroke[i], fill[i]);
|
svg_text(TEXT_LEFT + top, maxlen + TEXT_BASELINE, to_string(bin));
|
||||||
|
svg_rect(top, maxlen - bin_height, BIN_HEIGHT, bin_height, stroke[i], fill[i]);
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user