FTXUI 6.1.9
C++ functional terminal UI.
载入中...
搜索中...
未找到
examples/dom/linear_gradient.cpp
浏览该文件的文档.
1// Copyright 2023 Arthur Sonzogni. All rights reserved.
2// 本源代码的使用受 MIT 许可协议的约束,该协议可在 LICENSE 文件中找到。
3#include <ftxui/dom/elements.hpp> // 用于 bgcolor, operator|, operator|=, text, center, Element
4#include <ftxui/dom/linear_gradient.hpp> // 用于 LinearGradient::Stop, LinearGradient
5#include <ftxui/screen/screen.hpp> // 用于 Full, Screen
6#include <memory> // 用于 allocator, shared_ptr
7
8#include "ftxui/dom/node.hpp" // 用于 Render
9#include "ftxui/screen/color.hpp" // 用于 Color, Color::DeepPink1, Color::DeepSkyBlue1, Color::Yellow, ftxui
10
11int main() {
12 using namespace ftxui;
13 auto document = text("gradient") | center;
14
15 document |= bgcolor(LinearGradient()
16 .Angle(45)
17 .Stop(Color::DeepPink1)
18 .Stop(Color::DeepSkyBlue1));
19 auto screen = Screen::Create(Dimension::Full(), Dimension::Full());
20 Render(screen, document);
21 screen.Print();
22
23 return 0;
24}
Element bgcolor(const LinearGradient &gradient, Element child)
使用线性渐变效果设置元素的背景色。
一个表示线性渐变颜色效果设置的类。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase