FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
linear_gradient.hpp
Go to the documentation of this file.
1// Copyright 2023 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_DOM_LINEAR_GRADIENT_HPP
5#define FTXUI_DOM_LINEAR_GRADIENT_HPP
6
7#include <optional>
8#include <vector>
9
10#include "ftxui/screen/color.hpp" // for Colors
11#include "ftxui/util/export.hpp" // for FTXUI_EXPORT
12
13namespace ftxui {
14
15/// @brief 表示線性漸變顏色效果設定的類別。
16///
17/// 範例:
18/// ```cpp
19/// LinearGradient()
20/// .Angle(45)
21/// .Stop(Color::Red, 0.0)
22/// .Stop(Color::Green, 0.5)
23/// .Stop(Color::Blue, 1.0);
24/// ```
25///
26/// 也有簡寫的建構函式:
27/// ```cpp
28/// LinearGradient(Color::Red, Color::Blue);
29/// LinearGradient(45, Color::Red, Color::Blue);
30/// ```
31///
32/// @ingroup dom
33struct FTXUI_EXPORT(DOM) LinearGradient {
34 float angle = 0.f;
35
36 /// 一個 stop 是漸層中特定位置上的顏色。
37 /// 該位置是介於 0.0 與 1.0 之間的值,
38 /// 0.0 代表漸層的起點,
39 /// 1.0 代表漸層的終點。
40 struct Stop {
41 Color color = Color::Default;
42 std::optional<float> position;
43 };
44 std::vector<Stop> stops;
45
46 // 簡單的建構子
47 LinearGradient();
48 LinearGradient(Color begin, Color end);
49 LinearGradient(float angle, Color begin, Color end);
50
51 // 使用建構器模式的修飾函式。
52 LinearGradient& Angle(float angle);
53 LinearGradient& Stop(Color color, float position);
54 LinearGradient& Stop(Color color);
55};
56
57} // namespace ftxui
58
59#endif // FTXUI_DOM_LINEAR_GRADIENT_HPP
FTXUI ftxui:: 命名空間
Definition animation.hpp:11