|
TachyonUI 1.1.0
High-performance UI for building tools.
|
A gradient of float colors, for data such as a material editor's gradient map: up to kMaxStops stops, each with its own interpolation to the next, blended in colorSpace. More...
#include <gui_core/style/gui_style_gradient.h>
Public Member Functions | |
| bool | AddStop (const color4f &color, float offset, StopInterpolation interpolation=StopInterpolation::Linear) |
| Adds a stop at offset (clamped to 0..1); false when kMaxStops are in use. | |
| int | StopCount () const |
| The stops in use: at most kMaxStops. | |
| color4f | Sample (float t) const |
| The color at t (0..1, clamped), unclamped: HDR stays. | |
| void | WriteTo (std::span< color4f > out) const |
| Samples the gradient evenly across out, unclamped. | |
| void | WriteTo (std::span< color4b > out) const |
| As above, clamped to 0..1 and stored as 8 bits, for display. | |
| void | Assign (const Gradient &gradient) |
| As From, into this one's storage. | |
| Gradient | ToGradient () const |
| The first Gradient::kMaxStops stops as a linear Gradient: colors clamped to 0..1 and stored as 8 bits; the interpolation of each stop is dropped. | |
| bool | operator== (const GradientF &) const =default |
Static Public Member Functions | |
| static GradientF | From (const Gradient &gradient) |
| The same stops as gradient, blending linearly in its color space. | |
Public Attributes | |
| std::vector< GradientStop > | stops |
| in any order | |
| ColorSpace | colorSpace = ColorSpace::sRGB |
| space the stops are blended in | |
Static Public Attributes | |
| static constexpr int | kMaxStops = 64 |
| stops past this are left out | |
A gradient of float colors, for data such as a material editor's gradient map: up to kMaxStops stops, each with its own interpolation to the next, blended in colorSpace.
Gradient (8 stops, 8 bits a channel) is what styles and CSS use; GradientField edits either.
GradientF heat;
heat.AddStop(color4f{ 0.0f, 0.0f, 0.0f, 1.0f }, 0.0f);
heat.AddStop(color4f{ 4.0f, 1.5f, 0.2f, 1.0f }, 1.0f, StopInterpolation::Smooth); // HDR
const color4f mid = heat.Sample(0.5f);
| bool tachyon::GradientF::AddStop | ( | const color4f & | color, |
| float | offset, | ||
| StopInterpolation | interpolation = StopInterpolation::Linear ) |
Adds a stop at offset (clamped to 0..1); false when kMaxStops are in use.
|
inline |
The stops in use: at most kMaxStops.
| color4f tachyon::GradientF::Sample | ( | float | t | ) | const |
The color at t (0..1, clamped), unclamped: HDR stays.
Transparent black without stops; before the first stop its color, after the last that one's.
| void tachyon::GradientF::WriteTo | ( | std::span< color4f > | out | ) | const |
Samples the gradient evenly across out, unclamped.
| void tachyon::GradientF::WriteTo | ( | std::span< color4b > | out | ) | const |
As above, clamped to 0..1 and stored as 8 bits, for display.
The same stops as gradient, blending linearly in its color space.
| void tachyon::GradientF::Assign | ( | const Gradient & | gradient | ) |
As From, into this one's storage.
| Gradient tachyon::GradientF::ToGradient | ( | ) | const |
The first Gradient::kMaxStops stops as a linear Gradient: colors clamped to 0..1 and stored as 8 bits; the interpolation of each stop is dropped.
|
default |
|
staticconstexpr |
stops past this are left out
| std::vector<GradientStop> tachyon::GradientF::stops |
in any order
| ColorSpace tachyon::GradientF::colorSpace = ColorSpace::sRGB |
space the stops are blended in