svg: пустое изображение
Этот коммит содержится в:
3
main.cpp
3
main.cpp
@@ -3,6 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
#include "svg.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
struct Input {
|
struct Input {
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
@@ -35,6 +36,6 @@ int main()
|
|||||||
|
|
||||||
auto in = input_data();
|
auto in = input_data();
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
show_histogram_text(bins, MAX_ASTERISK, in.bin_count);
|
show_histogram_svg(bins);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
25
svg.cpp
Обычный файл
25
svg.cpp
Обычный файл
@@ -0,0 +1,25 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void
|
||||||
|
svg_begin(double width, double height) {
|
||||||
|
cout << "<?xml version='1.0' encoding='UTF-8'?>\n";
|
||||||
|
cout << "<svg ";
|
||||||
|
cout << "width='" << width << "' ";
|
||||||
|
cout << "height='" << height << "' ";
|
||||||
|
cout << "viewBox='0 0 " << width << " " << height << "' ";
|
||||||
|
cout << "xmlns='http://www.w3.org/2000/svg'>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
svg_end() {
|
||||||
|
cout << "</svg>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
show_histogram_svg(const vector <double>& bins) {
|
||||||
|
svg_begin(400, 300);
|
||||||
|
svg_end();
|
||||||
|
}
|
||||||
|
|
||||||
4
svg.h
Обычный файл
4
svg.h
Обычный файл
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void
|
||||||
|
show_histogram_svg(const std::vector<double>& bins);
|
||||||
2
text.cpp
2
text.cpp
@@ -4,7 +4,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_text (const vector<double>& bins,size_t MAX_ASTERISK, size_t bin_count){
|
show_histogram_text (const vector<double>& bins, size_t MAX_ASTERISK, size_t bin_count){
|
||||||
double max_count = bins[0];
|
double max_count = bins[0];
|
||||||
for (double x: bins){
|
for (double x: bins){
|
||||||
if (x > max_count) {
|
if (x > max_count) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user