Skip to content

ftxui::LinearGradient ​

cpp
#include <ftxui/dom/linear_gradient.hpp>

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);

Examples: component/input_style, component/linear_gradient_gallery, dom/linear_gradient, dom/style_color

Summary ​

SymbolDescription
angle
stops
LinearGradientBuild the "empty" gradient. This is often followed by calls to LinearGradient::Angle() and LinearGradient::Stop(). Example:
AngleSet the angle of the gradient.
StopAdd a color stop to the gradient.

Public Attributes ​

angle ​

cpp
float angle = 0.f;

stops ​

cpp
std::vector< Stop > stops;

Public Member Functions ​

LinearGradient ​

Build the "empty" gradient. This is often followed by calls to LinearGradient::Angle() and LinearGradient::Stop(). Example:

cpp
auto gradient =
 LinearGradient()
  .Angle(45)
  .Stop(Color::Red, 0.0)
  .Stop(Color::Green, 0.5)
  .Stop(Color::Blue, 1.0);;

Examples: component/input_style, component/linear_gradient_gallery, dom/linear_gradient, dom/style_color

LinearGradient ​

cpp
LinearGradient(Color begin, Color end);

Build a gradient with two colors.

Parameters:

  • begin: The color at the beginning of the gradient.
  • end: The color at the end of the gradient.

Examples: component/input_style, component/linear_gradient_gallery, dom/linear_gradient, dom/style_color

LinearGradient ​

cpp
LinearGradient(float angle, Color begin, Color end);

Build a gradient with two colors and an angle.

Parameters:

  • a: The angle of the gradient.
  • begin: The color at the beginning of the gradient.
  • end: The color at the end of the gradient.

Examples: component/input_style, component/linear_gradient_gallery, dom/linear_gradient, dom/style_color

Angle ​

cpp
LinearGradient & Angle(float angle);

Set the angle of the gradient.

Parameters:

  • a: The angle of the gradient.

Returns: The gradient.

Stop ​

cpp
LinearGradient & Stop(Color color, float position);

Add a color stop to the gradient.

Parameters:

  • c: The color of the stop.
  • p: The position of the stop.

Stop ​

Add a color stop to the gradient.

Parameters:

  • c: The color of the stop.

Returns: The gradient.

Note

The position of the stop is interpolated from nearby stops.