16static std::string charset[] =
17#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
20 {
" ",
" ",
"█",
" ",
"█",
"█",
"█",
"█",
"█"};
22 {
" ",
"▗",
"▐",
"▖",
"▄",
"▟",
"▌",
"▙",
"█"};
25class Graph :
public Node {
28 : graph_function_(std::move(graph_function)) {}
30 void ComputeRequirement()
override {
39 void Render(Screen& screen)
override {
42 if (width <= 0 || height <= 0) {
45 auto data = graph_function_(width, height);
48 const int height_1 = 2 *
box_.
y_max - data[i++];
49 const int height_2 = 2 *
box_.
y_max - data[i++];
52 int i_1 = yy < height_1 ? 0 : yy == height_1 ? 3 : 6;
53 int i_2 = yy < height_2 ? 0 : yy == height_2 ? 1 : 2;
54 screen.at(x, y) = charset[i_1 + i_2];
66 return std::make_shared<Graph>(std::move(graph_function));
std::shared_ptr< Node > Element
std::function< std::vector< int >(int, int)> GraphFunction
Element graph(GraphFunction)
Draw a graph using a GraphFunction.