move graphing into intermediate

This commit is contained in:
Jan Kuhlmann 2025-01-13 11:54:31 +01:00
parent a1057fe32c
commit 42e9d73719

View File

@ -806,20 +806,10 @@ namespace graphs
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
};
inline void graph(Texture& texture, const Options &options);
// intermediate representation of a graph texture for ease of passing around
struct Intermediate {
// use a graph texture to draw into the terminal
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
for (size_t y = 0; y < options.height; y++) {
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
template <typename T>
auto plot_experimental(const T &data, const Options &options = {}, const Color &color = {color_red}) -> Intermediate {