1.10 |
A ColorMap contains a series of sequential color steps that can be used for generating colors by interpolation. More...
#include <color.h>
Public Types | |
enum class | Interpolation { rgba , hsv , hsl } |
Interpolation color space method. More... | |
using | StepsArray = std::vector< Color > |
Type used for color steps array. | |
Public Member Functions | |
ColorMap (Interpolation interp) noexcept | |
template<class T > | |
ColorMap (std::initializer_list< T > steps, Interpolation interp=Interpolation::rgba) | |
ColorMap (StepsArray steps, Interpolation interp=Interpolation::rgba) | |
size_t | count () const |
Count the number of color steps. | |
bool | empty () const |
Are there any color steps? | |
Color | interp (float t) const |
Get a color at the specified offset. | |
Color | interp_cached (float t, size_t accuracy=1000) const |
Get a color at the specified offset. | |
void | step (const Color &color) |
Append a color step. | |
const StepsArray & | steps () const |
Get a reference to the color steps array. | |
void | steps (const StepsArray &steps) |
Set the color steps. | |
Protected Attributes | |
std::array< std::map< size_t, Color >, 3 > | m_cache {} |
Interpolation cache. | |
Interpolation | m_interp {Interpolation::rgba} |
Interpolation color space method. | |
StepsArray | m_steps |
Steps in the color map. | |
A ColorMap contains a series of sequential color steps that can be used for generating colors by interpolation.
using StepsArray = std::vector<Color> |
Type used for color steps array.
|
strong |
|
inlineexplicitnoexcept |
[in] | interp | Interpolation color space. |
|
inlineexplicit |
[in] | steps | Pre-defined color steps. |
[in] | interp | Interpolation color space. |
|
inlineexplicit |
[in] | steps | Pre-defined color steps. |
[in] | interp | Interpolation color space. |
|
inline |
Count the number of color steps.
|
inline |
Are there any color steps?
Color interp | ( | float | t | ) | const |
Get a color at the specified offset.
[in] | t | Offset from 0 to 1. |
Color interp_cached | ( | float | t, |
size_t | accuracy = 1000 |
||
) | const |
Get a color at the specified offset.
This will use a cache to speed up repetitive calls to interpolate.
[in] | t | Offset from 0 to 1. |
[in] | accuracy | Accuracy of the cached result. |
|
inline |
Append a color step.
|
inline |
Get a reference to the color steps array.
|
inline |
Set the color steps.
|
mutableprotected |
Interpolation cache.
|
protected |
Interpolation color space method.
|
protected |
Steps in the color map.