FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
color_truecolor_RGB.cpp
Go to the documentation of this file.
1// 版權所有 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權條款約束,該條款可在 LICENSE 檔案中找到。
3#include <ftxui/dom/elements.hpp> // 為了 hbox, text, bgcolor, operator|, vbox, Elements, window, Element, Fit
4#include <ftxui/screen/screen.hpp> // 為了 Full, Screen
5#include <memory> // 為了 allocator
6#include <utility> // 為了 move
7
8#include "ftxui/dom/node.hpp" // 為了 Render
9#include "ftxui/screen/color.hpp" // 為了 Color, ftxui
10
11int main() {
12 using namespace ftxui;
13
14 Elements red_line;
15 Elements green_line;
16 Elements blue_line;
17 Elements cyan_line;
18 Elements magenta_line;
19 Elements yellow_line;
20
21 for (int value = 0; value < 255; value += 3) {
22 int v = value * value / 255;
23 red_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, 0)));
24 green_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, 0)));
25 blue_line.push_back(text(" ") | bgcolor(Color::RGB(0, 0, v)));
26 cyan_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, v)));
27 magenta_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, v)));
28 yellow_line.push_back(text(" ") | bgcolor(Color::RGB(v, v, 0)));
29 }
30
31 auto document = vbox({
32 window(text("原色"),
33 vbox({
34 hbox({text("紅色線 :"), hbox(std::move(red_line))}),
35 hbox({text("綠色線 :"), hbox(std::move(green_line))}),
36 hbox({text("藍色線 :"), hbox(std::move(blue_line))}),
37 })),
38 window(text("輔色"),
39 vbox({
40 hbox({text("青色線 :"), hbox(std::move(cyan_line))}),
41 hbox({text("洋紅色線:"), hbox(std::move(magenta_line))}),
42 hbox({text("黃色線 :"), hbox(std::move(yellow_line))}),
43 })),
44 });
45
46 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
47 Render(screen, document);
48
49 screen.Print();
50
51 return 0;
52}
int main()
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上顯示元素。
Definition node.cpp:82
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
std::vector< Element > Elements
Definition elements.hpp:23