FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
linear_gradient_gallery.cpp
Go to the documentation of this file.
1// Copyright 2023 Arthur Sonzogni. 全著作権所有。
2// このソースコードの使用は、LICENSE ファイルにある MIT ライセンスに従います。
3#include <ftxui/component/component_base.hpp> // for ComponentBase, Component
4#include <ftxui/dom/elements.hpp> // for operator|, Element, flex, bgcolor, text, vbox, center
5#include <ftxui/dom/linear_gradient.hpp> // for LinearGradient
6#include <ftxui/screen/color.hpp> // for Color, Color::Blue, Color::Red
7#include <memory> // for __shared_ptr_access, shared_ptr
8#include <string> // for allocator, operator+, char_traits, string, to_string
9
10#include "ftxui/component/captured_mouse.hpp" // for ftxui
11#include "ftxui/component/component.hpp" // for Slider, Renderer, Vertical
12#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
13
14int main() {
15 using namespace ftxui;
16 auto screen = ScreenInteractive::Fullscreen();
17
18 int angle = 180.f;
19 float start = 0.f;
20 float end = 1.f;
21
22 std::string slider_angle_text;
23 std::string slider_start_text;
24 std::string slider_end_text;
25
26 auto slider_angle = Slider(&slider_angle_text, &angle, 0, 360);
27 auto slider_start = Slider(&slider_start_text, &start, 0.f, 1.f, 0.05f);
28 auto slider_end = Slider(&slider_end_text, &end, 0.f, 1.f, 0.05f);
29
30 auto layout = Container::Vertical({
31 slider_angle,
32 slider_start,
33 slider_end,
34 });
35
36 auto renderer = Renderer(layout, [&] {
37 slider_angle_text = "angle = " + std::to_string(angle) + "°";
38 slider_start_text = "start = " + std::to_string(int(start * 100)) + "%";
39 slider_end_text = "end = " + std::to_string(int(end * 100)) + "%";
40
41 auto background = text("Gradient") | center |
42 bgcolor(LinearGradient()
43 .Angle(angle)
44 .Stop(Color::Blue, start)
45 .Stop(Color::Red, end));
46 return vbox({
47 background | flex,
48 layout->Render(),
49 }) |
50 flex;
51 });
52
53 screen.Loop(renderer);
54}
線形グラデーションカラー効果の設定を表すクラスです。
FTXUI ftxui:: 名前空間
Definition animation.hpp:9