MorphoGraphX  2.0-1-227
Public Types | Public Member Functions | Static Public Member Functions | List of all members
util::Palette Class Reference

A utility class for palettes. More...

#include <Palette.hpp>

+ Inheritance diagram for util::Palette:

Public Types

typedef util::Color< GLfloat > Color
 

Public Member Functions

 Palette (std::string filename)
 Construct the palette from a file. More...
 
 Palette ()
 Construct an empty palette with only black colors. More...
 
void reread ()
 Reread the file describing the palette. More...
 
Color getColor (unsigned int index, double alpha=1) const
 Get a color from the palette. More...
 
Color getColor (unsigned int ind1, unsigned int ind2, double w, double alpha=1) const
 Blend two colors in the palette together. More...
 
void useColor (unsigned int index, double alpha=1) const
 Get a color and make it the current OpenGL color. More...
 
void blend (unsigned int ind1, unsigned int ind2, double w, double alpha=1) const
 Blend two colors together and make the result the current OpenGL color. More...
 
void select (unsigned int start, unsigned int end, double w, double alpha=1) const
 Select a color from a range in a palette and make it the current OpenGL color. More...
 
Color selectColor (unsigned int start, unsigned int end, double w, double alpha=1) const
 Select a color from a range in a palette and returns it. More...
 

Static Public Member Functions

static Color blend (const Color &c1, const Color &c2, double w)
 Blend two colors together. More...
 

Detailed Description

A utility class for palettes.

This class provides an interface for VLAB palette files and their use for OpenGL.

Definition at line 23 of file Palette.hpp.

Member Typedef Documentation

◆ Color

typedef util::Color<GLfloat> util::Palette::Color

Definition at line 25 of file Palette.hpp.

Constructor & Destructor Documentation

◆ Palette() [1/2]

util::Palette::Palette ( std::string  filename)

Construct the palette from a file.

Parameters
filenameFile to read the palette from

◆ Palette() [2/2]

util::Palette::Palette ( )

Construct an empty palette with only black colors.

Member Function Documentation

◆ blend() [1/2]

static Color util::Palette::blend ( const Color c1,
const Color c2,
double  w 
)
static

Blend two colors together.

◆ blend() [2/2]

void util::Palette::blend ( unsigned int  ind1,
unsigned int  ind2,
double  w,
double  alpha = 1 
) const

Blend two colors together and make the result the current OpenGL color.

Parameters
ind1Index of the first color
ind2Index of the second color
wBlending coefficient, from 0 to 1. The color is linearly interpolated from ind1 to ind2.
alphaAlpha value to use for this color.

◆ getColor() [1/2]

Color util::Palette::getColor ( unsigned int  ind1,
unsigned int  ind2,
double  w,
double  alpha = 1 
) const

Blend two colors in the palette together.

Parameters
ind1Index of the first color (between 0 and 255)
ind2Index of the second color (between 0 and 255)
wBlending coefficient, from 0 to 1. The color is linearly interpolated from ind1 to ind2. \parma alpha Alpha value to use for this color (between 0 and 1)

◆ getColor() [2/2]

Color util::Palette::getColor ( unsigned int  index,
double  alpha = 1 
) const

Get a color from the palette.

Parameters
indexIndex of the color in the palette (between 0 and 255)
alphaAlpha value to use for this color (between 0 and 1)

◆ reread()

void util::Palette::reread ( )

Reread the file describing the palette.

◆ select()

void util::Palette::select ( unsigned int  start,
unsigned int  end,
double  w,
double  alpha = 1 
) const

Select a color from a range in a palette and make it the current OpenGL color.

Parameters
startIndex of the first color of the range
endIndex of the last color of the range
wPosition within the range, if the value correspond to a color in between two defined colors, they will be linearly interpolated.
alphaAlpha value to use for this color.

◆ selectColor()

Color util::Palette::selectColor ( unsigned int  start,
unsigned int  end,
double  w,
double  alpha = 1 
) const

Select a color from a range in a palette and returns it.

Parameters
startIndex of the first color of the range
endIndex of the last color of the range
wPosition within the range, if the value correspond to a color in between two defined colors, they will be linearly interpolated.
alphaAlpha value to use for this color.

◆ useColor()

void util::Palette::useColor ( unsigned int  index,
double  alpha = 1 
) const

Get a color and make it the current OpenGL color.

Parameters
indexIndex of the color in the palette
alphaAlpha value fo use for this color

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