FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
color_truecolor_HSV.cpp
浏览该文件的文档.
1// Copyright 2020 Arthur Sonzogni. 版权所有。
2// 本源代码的使用受 MIT 许可协议约束,
3// 该协议可在 LICENSE 文件中找到。
4#include <ftxui/dom/elements.hpp> // for operator|, Elements, Fit, bgcolor, color, hbox, text, vbox, Element
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 int saturation = 255;
16 Elements array;
17 for (int value = 0; value < 255; value += 20) {
18 Elements line;
19 for (int hue = 0; hue < 255; hue += 2) {
20 line.push_back(text("▀") //
21 | color(Color::HSV(hue, saturation, value)) //
22 | bgcolor(Color::HSV(hue, saturation, value + 10)));
23 }
24 array.push_back(hbox(std::move(line)));
25 }
26
27 auto document = vbox(std::move(array));
28
29 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
30 Render(screen, document);
31
32 screen.Print();
33
34 return 0;
35}
Element color(const LinearGradient &gradient, Element child)
使用线性渐变效果设置元素的前景色。
Element bgcolor(const LinearGradient &gradient, Element child)
使用线性渐变效果设置元素的背景色。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::vector< Element > Elements