tlp::ColorScale Class Reference
Use this class to create a color scale and perform color mapping. The color scale can be either gradient or predefined colors steps. If the color scale is a gradient, returned color are interpolated in function of the position. If the color scale isn't a gradient returned colors are the predefined colors steps.
More...
#include <ColorScale.h>
List of all members.
Public Member Functions
- ColorScale (const bool gradient=true)
- ColorScale (const std::vector< Color > &colors, const bool gradient=true)
- ColorScale (const ColorScale &scale)
- virtual ~ColorScale ()
- virtual void setColorScale (const std::vector< Color > colors, const bool gradient=true)
- Configure the color scale. This method is used to configure the color scale. If the scale was previously configured the old configuration is lost.
- virtual void setColorAtPos (const float pos, const Color &color)
- Add a color to color scale at specific position. This method is used to add a color to the color scale at a specific position.
- virtual Color getColorAtPos (const float pos) const
- Compute the color for the given value.
- bool colorScaleInitialized () const
- Return true is the color scale was initialized.
- std::map< float, Color > getColorMap () const
- Return a map corresponding to the color scale. The index of the map is the position for the corresponding color in the color scale.
- bool isGradient () const
- Return true if the color scale is a gradient.
Protected Attributes
Detailed Description
Use this class to create a color scale and perform color mapping. The color scale can be either gradient or predefined colors steps. If the color scale is a gradient, returned color are interpolated in function of the position. If the color scale isn't a gradient returned colors are the predefined colors steps.
\
ColorScale colorScale;
\
vector<color> colors;
colors.push_back(Color(0,0,255));
colors.push_back(Color(255,0,0));
colorScale.setColorScale(colors,true);
\
colorScale.getColorAtPos(0.5);
\
vector<color> newColors;
newColors.push_back(Color(0,0,255));
newColors.push_back(Color(255,0,0));
colorScale.setColorScale(colors,false);
\
colorScale.getColorAtPos(0.3);
\
colorScale.getColorAtPos(0.7);
Constructor & Destructor Documentation
tlp::ColorScale::ColorScale |
( |
const bool |
gradient = true |
) |
|
tlp::ColorScale::ColorScale |
( |
const std::vector< Color > & |
colors, |
|
|
const bool |
gradient = true | |
|
) |
| | |
tlp::ColorScale::ColorScale |
( |
const ColorScale & |
scale |
) |
|
virtual tlp::ColorScale::~ColorScale |
( |
|
) |
[virtual] |
Member Function Documentation
bool tlp::ColorScale::colorScaleInitialized |
( |
|
) |
const [inline] |
Return true is the color scale was initialized.
virtual Color tlp::ColorScale::getColorAtPos |
( |
const float |
pos |
) |
const [virtual] |
Compute the color for the given value.
- Parameters:
-
| pos | This value defines the position of the color in the scale and must be between 0 and 1.0. |
- Returns:
- The color corresponding to the position in the scale if the position is beetween 0 and 1.0. If the position is smaller than 0 the color corresponding to the position 0 is returned and if the position is greater than 1.0 the color corresponding to the position 1.0 is returned.
std::map<float, Color> tlp::ColorScale::getColorMap |
( |
|
) |
const [inline] |
Return a map corresponding to the color scale. The index of the map is the position for the corresponding color in the color scale.
bool tlp::ColorScale::isGradient |
( |
|
) |
const [inline] |
Return true if the color scale is a gradient.
virtual void tlp::ColorScale::setColorAtPos |
( |
const float |
pos, |
|
|
const Color & |
color | |
|
) |
| | [virtual] |
Add a color to color scale at specific position. This method is used to add a color to the color scale at a specific position.
- Parameters:
-
| pos | the position in the color scale (0 <= pos <= 1) |
| gradient | If set to true, color scale is a gradient |
virtual void tlp::ColorScale::setColorScale |
( |
const std::vector< Color > |
colors, |
|
|
const bool |
gradient = true | |
|
) |
| | [virtual] |
Configure the color scale. This method is used to configure the color scale. If the scale was previously configured the old configuration is lost.
- Parameters:
-
| colors | The colors to use in the color scale. |
| gradient | If set to true, color scale is a gradient |
Member Data Documentation