mirror of
https://github.com/tdulcet/Table-and-Graph-Libs.git
synced 2025-05-08 00:01:21 +08:00
move graphing into intermediate
This commit is contained in:
parent
a1057fe32c
commit
42e9d73719
14
graphs.hpp
14
graphs.hpp
@ -806,20 +806,10 @@ 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
Texture texture;
|
|
||||||
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
|
// draw graph for experimental preview purposes only
|
||||||
for (size_t y = 0; y < options.height; y++) {
|
for (size_t y = 0; y < options.height; y++) {
|
||||||
for (size_t x = 0; x < options.width; x++) {
|
for (size_t x = 0; x < options.width; x++) {
|
||||||
@ -834,6 +824,10 @@ namespace graphs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Texture texture;
|
||||||
|
const Options options;
|
||||||
|
};
|
||||||
|
|
||||||
// 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