cpe::color Class Reference

Container class for (r,g,b) color. Each component is an integer (in [0,255]) More...

List of all members.

Public Member Functions

 color ()
 empty constructor (0,0,0)
 color (const int &gray)
 direct constructor with gray value (r,b,g)=(gray,gray,gray)
 color (const int &r, const int &g, const int &b)
 direct constructor with (r,b,g) value
void set (const int &r, const int &g, const int &b)
 set color value
const int & r () const
 get red value
int & r ()
 get red value
const int & g () const
 get green value
int & g ()
 get green value
const int & b () const
 get blue value
int & b ()
 get blue value
color clamped () const
 return the clamped version of the color (between 0 and 255)
coloroperator+= (const color &c)
 add a color to the current one
coloroperator*= (const double &alpha)
 internal scaling by a scalar

Static Public Member Functions

static color interpolate_linear (const color &c1, const color &c2, const double &alpha)
 linear interpolation of colors
static color interpolate_linear (const std::vector< color > &v_color, const std::vector< double > &weights)
 linear interpolation of colors

Private Attributes

int internal_r
 internal red component
int internal_g
 internal green component
int internal_b
 internal blue component

Friends

color operator+ (const color &c0, const color &c1)
 sum two colors
color operator* (const double &alpha, const color &c)
 scale color by a scalar value
color operator* (const color &c, const double &alpha)
 scale color by a scalar value
std::ostream & operator<< (std::ostream &stream, const color &c)
 standard output

Detailed Description

Container class for (r,g,b) color. Each component is an integer (in [0,255])


Constructor & Destructor Documentation

empty constructor (0,0,0)

Referenced by clamped(), and interpolate_linear().

cpe::color::color ( const int &  gray)

direct constructor with gray value (r,b,g)=(gray,gray,gray)

cpe::color::color ( const int &  r,
const int &  g,
const int &  b 
)

direct constructor with (r,b,g) value


Member Function Documentation

const int & cpe::color::b ( ) const

get blue value

References internal_b.

Referenced by interpolate_linear(), operator+=(), cpe::operator<<(), and set().

int & cpe::color::b ( )

get blue value

References internal_b.

return the clamped version of the color (between 0 and 255)

References color(), internal_b, internal_g, and internal_r.

+ Here is the call graph for this function:

const int & cpe::color::g ( ) const

get green value

References internal_g.

Referenced by interpolate_linear(), operator+=(), cpe::operator<<(), and set().

int & cpe::color::g ( )

get green value

References internal_g.

color cpe::color::interpolate_linear ( const color c1,
const color c2,
const double &  alpha 
) [static]

linear interpolation of colors

Returns:
(1-alpha)*c1 + alpha*c2

References b(), color(), g(), and r().

+ Here is the call graph for this function:

color cpe::color::interpolate_linear ( const std::vector< color > &  v_color,
const std::vector< double > &  weights 
) [static]

linear interpolation of colors

Parameters:
vector<color>v_color: vector of color to interpolate
vector<double>weights: weights used to interpolate colors
Returns:
Sum v_color[k]*weights[k]

References b(), color(), g(), and r().

+ Here is the call graph for this function:

color & cpe::color::operator*= ( const double &  alpha)

internal scaling by a scalar

References internal_b, internal_g, and internal_r.

color & cpe::color::operator+= ( const color c)

add a color to the current one

References b(), g(), internal_b, internal_g, internal_r, and r().

+ Here is the call graph for this function:

const int & cpe::color::r ( ) const

get red value

References internal_r.

Referenced by interpolate_linear(), operator+=(), cpe::operator<<(), and set().

int & cpe::color::r ( )

get red value

References internal_r.

void cpe::color::set ( const int &  r,
const int &  g,
const int &  b 
)

set color value

References b(), g(), internal_b, internal_g, internal_r, and r().

+ Here is the call graph for this function:


Friends And Related Function Documentation

color operator* ( const double &  alpha,
const color c 
) [friend]

scale color by a scalar value

color operator* ( const color c,
const double &  alpha 
) [friend]

scale color by a scalar value

color operator+ ( const color c0,
const color c1 
) [friend]

sum two colors

std::ostream& operator<< ( std::ostream &  stream,
const color c 
) [friend]

standard output


Member Data Documentation

int cpe::color::internal_b [private]

internal blue component

Referenced by b(), clamped(), operator*=(), operator+=(), and set().

int cpe::color::internal_g [private]

internal green component

Referenced by clamped(), g(), operator*=(), operator+=(), and set().

int cpe::color::internal_r [private]

internal red component

Referenced by clamped(), operator*=(), operator+=(), r(), and set().


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