Classes | Public Member Functions | List of all members
Palette Class Reference

Class for palette definition. More...

#include <palette.hpp>

Classes

struct  Entry
 Palette defining entry. More...
 

Public Member Functions

 Palette ()
 Default constructor for default black and white palette. More...
 
 Palette (const std::vector< Entry > &entries)
 Constructor for defined palette. More...
 
Color operator() (double x) const
 Return the interpolated color value from palette. More...
 
void clear (void)
 Clear current palette. More...
 
void push_back (const Color &color, double val)
 Pushes new entry to palette. More...
 
void norm (void)
 Normalize palette entries. More...
 
void set_stepped_palette (int steps)
 Set stepped palette. More...
 
void debug_print (std::ostream &os) const
 Print debugging information to os. More...
 

Detailed Description

Class for palette definition.

Palette is an object that contains a list of colors and corresponding values. The colors are interpolated linearly between the defined points for a smooth color palette. The palette values are normed so that the end points of palette have values 0.0 and 1.0.

Constructor & Destructor Documentation

Palette::Palette ( )

Default constructor for default black and white palette.

Palette::Palette ( const std::vector< Entry > &  entries)

Constructor for defined palette.

The values are normed to range from 0.0 to 1.0.

Member Function Documentation

void Palette::clear ( void  )

Clear current palette.

Leaves palette with no colors. Used with push_back() to build new palettes on-line.

void Palette::debug_print ( std::ostream &  os) const

Print debugging information to os.

void Palette::norm ( void  )

Normalize palette entries.

Normalize palette to range from 0.0 to 1.0.

Color Palette::operator() ( double  x) const

Return the interpolated color value from palette.

Makes and interpolated color value at value x, where 0 <= x <= 1. If palette has no colors, black will be returned. If palette has one color, that color will be returned. With two or more colors the value returned is interpolated from the colors. Outside the defined range, the closest color value is returned (color 0 if x < 0 and color N-1 if x > 1). If stepped palette is enabled, the palette shades will be limited and hard limits will be shown on palette sweeps.

void Palette::push_back ( const Color color,
double  val 
)

Pushes new entry to palette.

Palette entries are automatically sorted. The palette won't be normed in range. This has to be manually done by calling norm() after adding palette entries.

void Palette::set_stepped_palette ( int  steps)

Set stepped palette.

If steps is less than or equal to 1 a regular interpolated palette will be used (default), otherwise steps is used as the number of separate shades in the palette.


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