FTXUI  4.1.1
C++ functional terminal UI.
Loading...
Searching...
No Matches
linear_gradient.hpp
Go to the documentation of this file.
1#ifndef FTXUI_DOM_LINEAR_GRADIENT_HPP
2#define FTXUI_DOM_LINEAR_GRADIENT_HPP
3
4#include <optional>
5#include <vector>
6
7#include "ftxui/screen/color.hpp" // for Colors
8
9namespace ftxui {
10
11/// @brief A class representing the settings for linear-gradient color effect.
12///
13/// Example:
14/// ```cpp
15/// LinearGradient()
16/// .Angle(45)
17/// .Stop(Color::Red, 0.0)
18/// .Stop(Color::Green, 0.5)
19/// .Stop(Color::Blue, 1.0);
20/// ```
21///
22/// There are also shorthand constructors:
23/// ```cpp
24/// LinearGradient(Color::Red, Color::Blue);
25/// LinearGradient(45, Color::Red, Color::Blue);
26/// ```
28 float angle = 0.f;
29 struct Stop {
31 std::optional<float> position;
32 };
33 std::vector<Stop> stops;
34
35 // Simple constructor
37 LinearGradient(Color begin, Color end);
38 LinearGradient(float angle, Color begin, Color end);
39
40 // Modifier using the builder pattern.
42 LinearGradient& Stop(Color color, float position);
44};
45
46} // namespace ftxui
47
48#endif // FTXUI_DOM_LINEAR_GRADIENT_HPP
49
50// Copyright 2023 Arthur Sonzogni. All rights reserved.
51// Use of this source code is governed by the MIT license that can be found in
52// the LICENSE file.
A class representing terminal colors.
Definition color.hpp:18
Decorator color(Color)
Decorate using a foreground color.
Definition color.cpp:86
A class representing the settings for linear-gradient color effect.
LinearGradient & Stop(Color color, float position)
Add a color stop to the gradient.
LinearGradient & Angle(float angle)
Set the angle of the gradient.
std::optional< float > position
LinearGradient()
Build the "empty" gradient. This is often followed by calls to LinearGradient::Angle() and LinearGrad...
std::vector< Stop > stops