Loading...
Searching...
No Matches
linear_gradient.hpp
Go to the documentation of this file.
// Copyright 2023 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#ifndef FTXUI_DOM_LINEAR_GRADIENT_HPP
#define FTXUI_DOM_LINEAR_GRADIENT_HPP
#include <optional>
#include <vector>
#include "ftxui/screen/color.hpp" // for Colors
namespace ftxui {
/// @brief A class representing the settings for linear-gradient color effect.
///
/// Example:
/// ```cpp
/// LinearGradient()
/// .Angle(45)
/// .Stop(Color::Red, 0.0)
/// .Stop(Color::Green, 0.5)
/// .Stop(Color::Blue, 1.0);
/// ```
///
/// There are also shorthand constructors:
/// ```cpp
/// LinearGradient(Color::Red, Color::Blue);
/// LinearGradient(45, Color::Red, Color::Blue);
/// ```
struct LinearGradient {
float angle = 0.f;
struct Stop {
Color color = Color::Default;
std::optional<float> position;
};
std::vector<Stop> stops;
// Simple constructor
LinearGradient();
LinearGradient(Color begin, Color end);
LinearGradient(float angle, Color begin, Color end);
// Modifier using the builder pattern.
LinearGradient& Angle(float angle);
LinearGradient& Stop(Color color, float position);
LinearGradient& Stop(Color color);
};
} // namespace ftxui
#endif // FTXUI_DOM_LINEAR_GRADIENT_HPP
ftxui::Color
A class representing terminal colors.
Definition color.hpp:20
ftxui::Color::Default
@ Default
Definition color.hpp:48
color.hpp
ftxui
Definition animation.hpp:10
ftxui::color
Decorator color(Color)
Decorate using a foreground color.
Definition color.cpp:110
ftxui::LinearGradient::Stop
LinearGradient & Stop(Color color, float position)
Add a color stop to the gradient.
Definition linear_gradient.cpp:225
ftxui::LinearGradient::Angle
LinearGradient & Angle(float angle)
Set the angle of the gradient.
Definition linear_gradient.cpp:216
ftxui::LinearGradient::Stop::position
std::optional< float > position
Definition linear_gradient.hpp:34
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:36
ftxui::LinearGradient::Stop::color
Color color
Definition linear_gradient.hpp:33
ftxui::LinearGradient::angle
float angle
Definition linear_gradient.hpp:31
ftxui::LinearGradient::Stop
Definition linear_gradient.hpp:32