FTXUI 6.1.9 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
12 namespace ftxui {
13
14/// @brief A class representing the settings for linear-gradient color effect.
15///
16/// Example:
17/// ```cpp
18/// LinearGradient()
19/// .Angle(45)
20/// .Stop(Color::Red, 0.0)
21/// .Stop(Color::Green, 0.5)
22/// .Stop(Color::Blue, 1.0);
23/// ```
24///
25/// There are also shorthand constructors:
26/// ```cpp
27/// LinearGradient(Color::Red, Color::Blue);
28/// LinearGradient(45, Color::Red, Color::Blue);
29/// ```
30///
31/// @ingroup dom
32 struct LinearGradient {
33 float angle = 0.f;
34
35 /// A stop is a color at a specific position in the gradient.
36 /// The position is a value between 0.0 and 1.0,
37 /// where 0.0 is the start of the gradient
38 /// and 1.0 is the end of the gradient.
39 struct Stop {
40 Color color = Color::Default;
41 std::optional<float> position;
42 };
43 std::vector<Stop> stops;
44
45 // Simple constructor
46 LinearGradient();
47 LinearGradient(Color begin, Color end);
48 LinearGradient(float angle, Color begin, Color end);
49
50 // Modifier using the builder pattern.
51 LinearGradient& Angle(float angle);
52 LinearGradient& Stop(Color color, float position);
53 LinearGradient& Stop(Color color);
54};
55
56} // namespace ftxui
57
58#endif // FTXUI_DOM_LINEAR_GRADIENT_HPP
color.hpp
ftxui::LinearGradient::Stop
LinearGradient & Stop(Color color, float position)
Add a color stop to the gradient.
Definition src/ftxui/dom/linear_gradient.cpp:220
ftxui::LinearGradient::Angle
LinearGradient & Angle(float angle)
Set the angle of the gradient.
Definition src/ftxui/dom/linear_gradient.cpp:212
ftxui::LinearGradient::LinearGradient
LinearGradient()
Build the "empty" gradient. This is often followed by calls to LinearGradient::Angle() and LinearGrad...
ftxui::LinearGradient::stops
std::vector< Stop > stops
Definition linear_gradient.hpp:43
ftxui::LinearGradient::angle
float angle
Definition linear_gradient.hpp:33
ftxui::LinearGradient
A class representing the settings for linear-gradient color effect.
Definition linear_gradient.hpp:32
ftxui::Color::Default
@ Default
Definition color.hpp:50
ftxui::Color
Color is a class that represents a color in the terminal user interface.
Definition color.hpp:22
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::LinearGradient::Stop
Definition linear_gradient.hpp:39
ftxui::LinearGradient::Stop::position
std::optional< float > position
Definition linear_gradient.hpp:41