Финальная версия
Этот коммит содержится в:
4
main.cpp
4
main.cpp
@@ -78,11 +78,11 @@ int main(int argc, char* argv[])
|
|||||||
string color = "base";
|
string color = "base";
|
||||||
Input in;
|
Input in;
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
for (size_t i = 0; i < argc; i += 1){
|
for (size_t i = 0; i < argc; i++){
|
||||||
if (strcmp(argv[i], "-fill") == 0){
|
if (strcmp(argv[i], "-fill") == 0){
|
||||||
if (i - 1 < 1){
|
if (i - 1 < 1){
|
||||||
in = download(argv[i + 2]);
|
in = download(argv[i + 2]);
|
||||||
color = argv[i + 2];
|
color = argv[i + 1];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (i + 1 >= argc){
|
if (i + 1 >= argc){
|
||||||
|
|||||||
12
svg.cpp
12
svg.cpp
@@ -51,7 +51,7 @@ show_histogram_svg(const vector<size_t>& bins, const std::vector<double>& border
|
|||||||
const auto BIN_HEIGHT = 30;
|
const auto BIN_HEIGHT = 30;
|
||||||
const auto BLOCK_WIDTH = 10;
|
const auto BLOCK_WIDTH = 10;
|
||||||
const auto MAX_WIDTH = IMAGE_WIDTH-TEXT_WIDTH;
|
const auto MAX_WIDTH = IMAGE_WIDTH-TEXT_WIDTH;
|
||||||
vector <string> colors = {"red", "blue", "gold", "lime", "aqua", "green", "orange"};
|
vector <string> colors = {"white", "red", "blue", "gold", "lime", "aqua", "green", "orange"};
|
||||||
size_t border = 0;
|
size_t border = 0;
|
||||||
size_t number_of_blocks;
|
size_t number_of_blocks;
|
||||||
|
|
||||||
@@ -59,7 +59,6 @@ show_histogram_svg(const vector<size_t>& bins, const std::vector<double>& border
|
|||||||
size_t max_bin = *max_element(bins.begin(), bins.end());
|
size_t max_bin = *max_element(bins.begin(), bins.end());
|
||||||
|
|
||||||
double top = 0;
|
double top = 0;
|
||||||
size_t paint_swicher = 0;
|
|
||||||
string color;
|
string color;
|
||||||
double max_count = bins[0];
|
double max_count = bins[0];
|
||||||
for (size_t i = 0; i < bins.size(); i++)
|
for (size_t i = 0; i < bins.size(); i++)
|
||||||
@@ -74,9 +73,10 @@ show_histogram_svg(const vector<size_t>& bins, const std::vector<double>& border
|
|||||||
{
|
{
|
||||||
if (filling != "base"){
|
if (filling != "base"){
|
||||||
color = filling;
|
color = filling;
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
color = colors[paint_swicher];
|
color = colors[0];
|
||||||
}
|
}
|
||||||
number_of_blocks = bin;
|
number_of_blocks = bin;
|
||||||
if ((max_bin * BLOCK_WIDTH) > (IMAGE_WIDTH - TEXT_WIDTH)){
|
if ((max_bin * BLOCK_WIDTH) > (IMAGE_WIDTH - TEXT_WIDTH)){
|
||||||
@@ -85,10 +85,6 @@ show_histogram_svg(const vector<size_t>& bins, const std::vector<double>& border
|
|||||||
const double bin_width = BLOCK_WIDTH * number_of_blocks;
|
const double bin_width = BLOCK_WIDTH * number_of_blocks;
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "black", color);
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "black", color);
|
||||||
paint_swicher += 1;
|
|
||||||
if (paint_swicher > 6){
|
|
||||||
paint_swicher = 0;
|
|
||||||
}
|
|
||||||
if (border < bin_count - 1){
|
if (border < bin_count - 1){
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
svg_text(TEXT_LEFT / 2, top + TEXT_BASELINE , to_string(borders[border]));
|
svg_text(TEXT_LEFT / 2, top + TEXT_BASELINE , to_string(borders[border]));
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user