Antiprism 0.23
Public Member Functions | Protected Member Functions

color_map Class Reference

A colour map class. More...

#include <col_map.h>

Inheritance diagram for color_map:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 color_map ()
 Constructor.
virtual ~color_map ()
 Destructor.
virtual bool init (const char *map_name, char *errmsg=0)
 Initialise from a string.
bool init_strip (char *map_name, char *errmsg=0)
 Initialise from a string, stripping parameters from the end.
bool read_params (const char *params, char *errmsg)
 Read parameters.
virtual color_mapget_condensed () const
 Get a copy of the map with any with the values indexed by order.
virtual color_mapclone () const
 Get a copy of the map.
virtual int effective_size () const
 The effective size of the map.
int get_shift () const
 Get the map shift.
void set_shift (int shft)
 Set the map shift.
int get_step () const
 Get the map step.
void set_step (int stp)
 Set the map shift.
int get_wrap () const
 Get the map wrap size.
void set_wrap (int wrp=-1)
 Set the map wrap size.
int get_effective_index (int idx) const
 Get effective index.
virtual col_val get_col (int) const
 Get the colour value for an index number.
void cycle_colors ()
 Cycle the map colours.

Protected Member Functions

void copy_params (const color_map &cmap)
 Copy parameters.

Detailed Description

A colour map class.


Member Function Documentation

virtual color_map* color_map::clone ( ) const [inline, virtual]

Get a copy of the map.

Returns:
a pointer to the dynamically allocated copy, which must be freed by the caller with delete, 0 indicates that the clone failed.

Reimplemented in color_map_remap, color_map_deal, color_map_range, color_map_range_hsv, color_map_range_rgb, color_map_range_rand, color_map_range_rand_hsv, color_map_range_rand_rgb, color_map_spread, color_map_map, and color_map_multi.

void color_map::copy_params ( const color_map cmap) [protected]

Copy parameters.

Parameters:
cmapthe colour map to copy parameters from.
void color_map::cycle_colors ( ) [inline]

Cycle the map colours.

Each colour index number is mapped to the previous colour value in the colour map.

virtual int color_map::effective_size ( ) const [inline, virtual]

The effective size of the map.

The effective size of a map is one greater than the highest index number in the map. It is the size of the smallest map (sequential, starting at 0) that will include all the entries of the map.

Returns:
The effective size

Reimplemented in color_map_deal, color_map_range, color_map_map, and color_map_multi.

virtual col_val color_map::get_col ( int  ) const [inline, virtual]

Get the colour value for an index number.

Returns:
The colour.

Reimplemented in color_map_remap, color_map_deal, color_map_range, color_map_range_rand, color_map_spread, color_map_map, and color_map_multi.

virtual color_map* color_map::get_condensed ( ) const [inline, virtual]

Get a copy of the map with any with the values indexed by order.

Returns:
a pointer to the dynamically allocated condensed copy, which must be freed by the caller with delete, 0 indicates that the copy failed.

Reimplemented in color_map_map.

int color_map::get_effective_index ( int  idx) const [inline]

Get effective index.

The effective index is (shift + index*step)wrap

Parameters:
idxthe index
Returns:
The effective index.
int color_map::get_shift ( ) const [inline]

Get the map shift.

Lookup of colour values is determined by (shift + index*step)wrap

Returns:
the shift
int color_map::get_step ( ) const [inline]

Get the map step.

Look up of colour values is determined by (shift + index*step)wrap

Returns:
the step
int color_map::get_wrap ( ) const [inline]

Get the map wrap size.

Look up of colour values is determined by (shift + index*step)wrap a value of 0 indicates no wrapping.

Returns:
the wrap
bool color_map::init ( const char *  map_name,
char *  errmsg = 0 
) [virtual]

Initialise from a string.

Parameters:
map_namethe map name.
errmsgan array at least MSG_SZ chars long to return any error message.
Returns:
true if the file could be read, otherwise false and the error is detailed in errmsg.

Reimplemented in color_map_deal, color_map_range, color_map_range_hsv, color_map_range_rgb, color_map_range_rand_hsv, color_map_range_rand_rgb, color_map_spread, color_map_map, and color_map_multi.

bool color_map::init_strip ( char *  map_name,
char *  errmsg = 0 
)

Initialise from a string, stripping parameters from the end.

Parameters:
map_namethe map name.
errmsgan array at least MSG_SZ chars long to return any error message.
Returns:
true if the file could be read, otherwise false and the error is detailed in errmsg.
bool color_map::read_params ( const char *  params,
char *  errmsg 
)

Read parameters.

Parameters:
paramsthe map name to read parameters from.
errmsgan array at least MSG_SZ chars long to return any error message.
Returns:
true if the parameters could be read, otherwise false and the error is detailed in errmsg.
void color_map::set_shift ( int  shft) [inline]

Set the map shift.

Lookup of colour values is determined by (shift + index*step)wrap

Parameters:
shftthe shift
void color_map::set_step ( int  stp) [inline]

Set the map shift.

Look up of colour values is determined by (shift + index*step)wrap

Parameters:
stpthe step
void color_map::set_wrap ( int  wrp = -1)

Set the map wrap size.

Look up of colour values is determined by (shift + index*step)wrap a value of 0 indicates no wrapping, a negative value indicates wrapping after the highest index number.

Parameters:
wrpthe wrap

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