c.DrawText(0, 0,
"This is a canvas", [](
Pixel& p) {
});
c.DrawPointLine(10, 10, 80, 10, Color::Red);
c.DrawPointLine(80, 10, 80, 40, Color::Blue);
c.DrawPointLine(80, 40, 10, 10, Color::Green);
c.DrawPointCircle(30, 50, 20);
c.DrawPointCircleFilled(40, 40, 10);
std::vector<int> ys(100);
for (int x = 0; x < 100; x++) {
ys[x] = int(80 + 20 * cos(x * 0.2));
}
for (int x = 0; x < 99; x++) {
c.DrawPointLine(x, ys[x], x + 1, ys[x + 1], Color::Red);
}
auto document =
canvas(&c) | border;
auto screen = Screen::Create(Dimension::Fit(document));
screen.Print();
getchar();
return 0;
}
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上顯示元素。
Element canvas(ConstRef< Canvas > canvas)
從 Canvas 或對 Canvas 的參考中產生一個元素。