optional draw

This commit is contained in:
Jan Kuhlmann 2024-12-09 11:50:54 +01:00
parent 950e3391a8
commit 1d6e7ab716

View File

@ -807,11 +807,24 @@ namespace graphs
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
}; };
// use a graph texture to draw a graph into the terminal // use a graph texture to draw a graph into the terminal
void graph(Texture& texture, Options &options) { inline void graph(Texture& texture, const Options &options) {
// TODO vector<Fragment>& tex = *texture;
// 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 = tex[index];
// draw Fragment
cout << colors[frag.color.col_4];
cout << bars[frag.data];
cout << colors[0];
}
cout << '\n';
}
} }
// use a graph texture to draw a graph into the terminal // use a graph texture to draw a graph into the terminal
void draw(Texture& texture, Options &options) { inline void draw(Texture& texture, const Options &options) {
graph(texture, options); graph(texture, options);
} }
// print histogram using single data set, optionally drawn on top of existing texture // print histogram using single data set, optionally drawn on top of existing texture
@ -895,18 +908,7 @@ namespace graphs
} }
} }
// draw graph for experimental preview purposes only if (options.draw_immediately) draw(texture, options);
for (size_t y = 0; y < height; y++) {
for (size_t x = 0; x < width; x++) {
const size_t index = x + y * width;
const auto& frag = tex[index];
// draw Fragment
cout << colors[frag.color.col_4];
cout << bars[frag.data];
cout << colors[0];
}
cout << '\n';
}
return std::move(texture); return std::move(texture);
} }
// print histogram using multiple data sets, drawn on top of existing texture // print histogram using multiple data sets, drawn on top of existing texture