FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
color_truecolor_RGB.cpp
浏览该文件的文档.
1// 版权所有 2020 Arthur Sonzogni。保留所有权利。
2// 本源代码的使用受 MIT 许可证的约束,该许可证可在
3// LICENSE 文件中找到。
4#include <ftxui/dom/elements.hpp> // for hbox, text, bgcolor, operator|, vbox, Elements, window, Element, Fit
5#include <ftxui/screen/screen.hpp> // for Full, Screen
6#include <memory> // for allocator
7#include <utility> // for move
8
9#include "ftxui/dom/node.hpp" // for Render
10#include "ftxui/screen/color.hpp" // for Color, ftxui
11
12int main() {
13 using namespace ftxui;
14
15 Elements red_line;
16 Elements green_line;
17 Elements blue_line;
18 Elements cyan_line;
19 Elements magenta_line;
20 Elements yellow_line;
21
22 for (int value = 0; value < 255; value += 3) {
23 int v = value * value / 255;
24 red_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, 0)));
25 green_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, 0)));
26 blue_line.push_back(text(" ") | bgcolor(Color::RGB(0, 0, v)));
27 cyan_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, v)));
28 magenta_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, v)));
29 yellow_line.push_back(text(" ") | bgcolor(Color::RGB(v, v, 0)));
30 }
31
32 auto document = vbox({
33 window(text("原色"),
34 vbox({
35 hbox({text("红色线条 :"), hbox(std::move(red_line))}),
36 hbox({text("绿色线条 :"), hbox(std::move(green_line))}),
37 hbox({text("蓝色线条 :"), hbox(std::move(blue_line))}),
38 })),
39 window(text("次生色"),
40 vbox({
41 hbox({text("青色线条 :"), hbox(std::move(cyan_line))}),
42 hbox({text("洋红色线条:"), hbox(std::move(magenta_line))}),
43 hbox({text("黄色线条 :"), hbox(std::move(yellow_line))}),
44 })),
45 });
46
47 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
48 Render(screen, document);
49
50 screen.Print();
51
52 return 0;
53}
Element window(Element title, Element content, BorderStyle border)
绘制带有标题和边框的窗口。
Element bgcolor(const LinearGradient &gradient, Element child)
使用线性渐变效果设置元素的背景色。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::vector< Element > Elements