cgv
Loading...
Searching...
No Matches
cgv::media::continuous_color_scheme Class Reference

This class represents a continuous color scheme using an interpolator to convert continuous scalar values to colors. More...

#include <color_scheme.h>

Inheritance diagram for cgv::media::continuous_color_scheme:
cgv::media::color_scheme

Public Types

using interpolator_type = cgv::math::interpolator< cgv::rgb, float >
 The used interpolator type.
 

Public Member Functions

 continuous_color_scheme ()
 Construct using an interpolator that represents the identity function, basically providing a grayscale color ramp.
 
 continuous_color_scheme (const interpolator_type &interpolator, ColorSchemeType type=ColorSchemeType::kUndefined)
 Construct using the given interpolator and scheme type.
 
std::shared_ptr< const interpolator_typeget_interpolator () const
 Return the interpolator.
 
cgv::rgb interpolate (float t) const
 Evaluate the color scheme at position t.
 
std::vector< cgv::rgbquantize (size_t n) const
 Evaluate the color scheme at n uniformly-spaced positions within the range [0,1].
 

Static Public Member Functions

static continuous_color_scheme linear (const std::vector< cgv::rgb > &colors, ColorSchemeType type=ColorSchemeType::kUndefined)
 Create a continuous_color_scheme using uniform linear interpolation of the given colors.
 
static continuous_color_scheme linear (const std::vector< std::pair< float, cgv::rgb > > &colors, ColorSchemeType type=ColorSchemeType::kUndefined)
 Create a continuous_color_scheme using linear interpolation of the given control points consisting of position and color.
 
static continuous_color_scheme smooth (const std::vector< cgv::rgb > &colors, ColorSchemeType type=ColorSchemeType::kUndefined)
 Create a continuous_color_scheme using uniform b-spline interpolation of the given colors.
 
static continuous_color_scheme function (std::function< cgv::rgb(float)> fn, ColorSchemeType type=ColorSchemeType::kUndefined)
 Create a continuous_color_scheme using a functor as interpolator.
 

Additional Inherited Members

- Public Attributes inherited from cgv::media::color_scheme
ColorSchemeType type = ColorSchemeType::kUndefined
 The type of this color scheme.
 

Detailed Description

This class represents a continuous color scheme using an interpolator to convert continuous scalar values to colors.

Definition at line 68 of file color_scheme.h.

Member Typedef Documentation

◆ interpolator_type

The used interpolator type.

Definition at line 71 of file color_scheme.h.

Constructor & Destructor Documentation

◆ continuous_color_scheme() [1/2]

cgv::media::continuous_color_scheme::continuous_color_scheme ( )
inline

Construct using an interpolator that represents the identity function, basically providing a grayscale color ramp.

Definition at line 74 of file color_scheme.h.

◆ continuous_color_scheme() [2/2]

cgv::media::continuous_color_scheme::continuous_color_scheme ( const interpolator_type interpolator,
ColorSchemeType  type = ColorSchemeType::kUndefined 
)
inline

Construct using the given interpolator and scheme type.

The type should describe the color ramp produced by the interpolator if possible.

Parameters
interpolatorThe used interpolator.
typeThe color scheme type.

Definition at line 80 of file color_scheme.h.

References cgv::media::color_scheme::type.

Member Function Documentation

◆ function()

static continuous_color_scheme cgv::media::continuous_color_scheme::function ( std::function< cgv::rgb(float)>  fn,
ColorSchemeType  type = ColorSchemeType::kUndefined 
)
inlinestatic

Create a continuous_color_scheme using a functor as interpolator.

Parameters
colorsThe function used to map scalars to colors.
typeThe color scheme type.
Returns
The color scheme.

Definition at line 118 of file color_scheme.h.

References cgv::media::color_scheme::type.

◆ get_interpolator()

std::shared_ptr< const interpolator_type > cgv::media::continuous_color_scheme::get_interpolator ( ) const
inline

Return the interpolator.

Definition at line 123 of file color_scheme.h.

Referenced by cgv::media::continuous_color_scale::quantize().

◆ interpolate()

cgv::rgb cgv::media::continuous_color_scheme::interpolate ( float  t) const
inline

Evaluate the color scheme at position t.

Parameters
tThe position at which to evaluate the interpolated values.
Returns
The interpolated color.

Definition at line 131 of file color_scheme.h.

Referenced by cgv::media::continuous_color_scale::get_mapped_color().

◆ linear() [1/2]

static continuous_color_scheme cgv::media::continuous_color_scheme::linear ( const std::vector< cgv::rgb > &  colors,
ColorSchemeType  type = ColorSchemeType::kUndefined 
)
inlinestatic

Create a continuous_color_scheme using uniform linear interpolation of the given colors.

Parameters
colorsThe list of colors to interpolate.
typeThe color scheme type.
Returns
The color scheme.

Definition at line 90 of file color_scheme.h.

References cgv::media::color_scheme::type.

Referenced by cgv::overlay::performance_monitor::init().

◆ linear() [2/2]

static continuous_color_scheme cgv::media::continuous_color_scheme::linear ( const std::vector< std::pair< float, cgv::rgb > > &  colors,
ColorSchemeType  type = ColorSchemeType::kUndefined 
)
inlinestatic

Create a continuous_color_scheme using linear interpolation of the given control points consisting of position and color.

The positions should be within the range [0,1].

Parameters
colorsThe list of control points to interpolate.
typeThe color scheme type.
Returns
The color scheme.

Definition at line 100 of file color_scheme.h.

References cgv::media::color_scheme::type.

◆ quantize()

std::vector< cgv::rgb > cgv::media::continuous_color_scheme::quantize ( size_t  n) const
inline

Evaluate the color scheme at n uniformly-spaced positions within the range [0,1].

Parameters
nThe number of samples to interpolate.
Returns
The sequence of interpolated colors.

Definition at line 139 of file color_scheme.h.

Referenced by cgv::media::transfer_function::set_color_points_from_scheme().

◆ smooth()

static continuous_color_scheme cgv::media::continuous_color_scheme::smooth ( const std::vector< cgv::rgb > &  colors,
ColorSchemeType  type = ColorSchemeType::kUndefined 
)
inlinestatic

Create a continuous_color_scheme using uniform b-spline interpolation of the given colors.

Parameters
colorsThe list of colors to interpolate.
typeThe color scheme type.
Returns
The color scheme.

Definition at line 109 of file color_scheme.h.

References cgv::media::color_scheme::type.


The documentation for this class was generated from the following file: