#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <utility>
#include <vector>
class Graph {
public:
std::vector<int> operator()(int width, int height) const {
std::vector<int> output(width);
for (int i = 0; i < width; ++i) {
float v = 0;
v += 0.1f * sin((i + shift) * 0.1f);
v += 0.2f * sin((i + shift + 10) * 0.15f);
v += 0.1f * sin((i + shift) * 0.03f);
v *= height;
v += 0.5f * height;
output[i] = static_cast<int>(v);
}
return output;
}
int shift = 0;
};
std::vector<int>
triangle(
int width,
int height) {
std::vector<int> output(width);
for (int i = 0; i < width; ++i) {
output[i] = i % (height - 4) + 2;
}
return output;
}
using namespace std::chrono_literals;
Graph my_graph;
std::string reset_position;
for (int i = 0;; ++i) {
std::ignore = i;
auto document = hbox({
vbox({
graph(std::ref(my_graph)),
separator(),
}) | flex,
separator(),
vbox({
graph(std::ref(my_graph)) | color(Color::BlueLight),
separator(),
graph(std::ref(my_graph)) | color(Color::RedLight),
separator(),
graph(std::ref(my_graph)) | color(Color::YellowLight),
}) | flex,
});
document |= border;
const int min_width = 40;
document |= size(HEIGHT, GREATER_THAN, min_width);
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
std::cout << reset_position;
screen.Print();
reset_position = screen.ResetPosition();
const auto sleep_time = 0.03s;
std::this_thread::sleep_for(sleep_time);
}
return 0;
}
std::vector< int > triangle(int width, int height)
The FTXUI ftxui:: namespace.