mirror of
https://github.com/tdulcet/Table-and-Graph-Libs.git
synced 2025-05-07 15:41:20 +08:00
move graphing into intermediate
This commit is contained in:
parent
a1057fe32c
commit
42e9d73719
30
graphs.hpp
30
graphs.hpp
@ -806,34 +806,28 @@ namespace graphs
|
|||||||
bool border = false; // draw border around the graph
|
bool border = false; // draw border around the graph
|
||||||
bool draw_immediately = true; // draw graph immediately after creation. otherwise call draw/graph with the returned texture
|
bool draw_immediately = true; // draw graph immediately after creation. otherwise call draw/graph with the returned texture
|
||||||
};
|
};
|
||||||
inline void graph(Texture& texture, const Options &options);
|
|
||||||
// intermediate representation of a graph texture for ease of passing around
|
// intermediate representation of a graph texture for ease of passing around
|
||||||
struct Intermediate {
|
struct Intermediate {
|
||||||
// use a graph texture to draw into the terminal
|
// use a graph texture to draw into the terminal
|
||||||
inline void draw() {
|
inline void draw() {
|
||||||
graph(texture, options);
|
// draw graph for experimental preview purposes only
|
||||||
|
for (size_t y = 0; y < options.height; y++) {
|
||||||
|
for (size_t x = 0; x < options.width; x++) {
|
||||||
|
const size_t index = x + y * options.width;
|
||||||
|
const auto& frag = texture[index];
|
||||||
|
// draw Fragment
|
||||||
|
cout << colors[frag.color.col_4];
|
||||||
|
cout << dots[frag.data];
|
||||||
|
cout << colors[0];
|
||||||
|
}
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture texture;
|
Texture texture;
|
||||||
const Options options;
|
const Options options;
|
||||||
};
|
};
|
||||||
|
|
||||||
// use a graph texture to draw a graph into the terminal
|
|
||||||
inline void graph(Texture& texture, const Options &options) {
|
|
||||||
// draw graph for experimental preview purposes only
|
|
||||||
for (size_t y = 0; y < options.height; y++) {
|
|
||||||
for (size_t x = 0; x < options.width; x++) {
|
|
||||||
const size_t index = x + y * options.width;
|
|
||||||
const auto& frag = texture[index];
|
|
||||||
// draw Fragment
|
|
||||||
cout << colors[frag.color.col_4];
|
|
||||||
cout << dots[frag.data];
|
|
||||||
cout << colors[0];
|
|
||||||
}
|
|
||||||
cout << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// plot from single data set
|
// plot from single data set
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto plot_experimental(const T &data, const Options &options = {}, const Color &color = {color_red}) -> Intermediate {
|
auto plot_experimental(const T &data, const Options &options = {}, const Color &color = {color_red}) -> Intermediate {
|
||||||
|
Loading…
Reference in New Issue
Block a user