User manual:   Main Page   Overview   Installation   User Interface   Tutorial   Example   FAQ   Version Updates
Reference manual:   Class List   Class Members   Globals, enums and defines

Color Class Reference

Defines an RGB color. More...

List of all members.

Public Methods

 Color ()
 Color (double r, double g, double b)
 Color (COLORREF color)
void setColor (double r, double g, double b)
double & operator[] (COLOR col)
double operator[] (COLOR col) const
Color & operator= (const Color &color)
Color & operator+= (const Color &color)
Color & operator-= (const Color &color)
Color operator+ (const Color &color) const
Color operator- (const Color &color) const
Color operator- () const
Color & operator *= (double d)
Color & operator/= (double d)
Color operator * (double d) const
Color operator/ (double d) const
bool operator== (const Color &color) const
double abs () const
void setRandomColor ()


Detailed Description

Defines an RGB color.

Every component is a double at the range [0.0, 1.0]. After each operation an overflow check is made for every component, and if necessary, the component is updated. For example, if the R component is larger than 1.0, it will be updated to 1.0; if smaller than 0.0, it will be updated to 0.0


Constructor & Destructor Documentation

Color::Color  
 

Default constructor.

Initializes the color to black (0, 0, 0).

Color::Color double    r,
double    g,
double    b
 

Constructor.

Initializes the color to (r, g, b).

Parameters:
r The red component
g The green component
b The blue component

Color::Color COLORREF    color
 

Constructor.

Initializes the color according to the given color.

Parameters:
color A color


Member Function Documentation

double Color::abs   const
 

Returns the absolute value of the color, i.e.

sqrt(r*r+g*g+b*b)

Returns:
The absolute value

Color Color::operator * double    d const
 

Multiplies every color component by d, returns a new Color object.

Parameters:
d The parameter to multiply by
Returns:
A new Color object with the result

Color& Color::operator *= double    d
 

Multiplies every color component by d.

Parameters:
d The parameter to multiply by
Returns:
A reference to this object

Color Color::operator+ const Color &    color const
 

Returns the sum of current color and color.

Parameters:
color The color to add
Returns:
A new Color object with the result

Color& Color::operator+= const Color &    color
 

Adds color to current color.

Parameters:
color The color to add
Returns:
A reference to this object

Color Color::operator-   const
 

Returns the current color multiplied by -1.

Returns:
A new Color object with the result

Color Color::operator- const Color &    color const
 

Subtracts color from current color, returns a new Color object.

Parameters:
color The color to subtract
Returns:
A new Color object with the result

Color& Color::operator-= const Color &    color
 

Subtracts color to current color.

Parameters:
color The color to subtract
Returns:
A reference to this object

Color Color::operator/ double    d const
 

Divides every color component by d, returns a new Color object.

Parameters:
d The parameter to divide by
Returns:
A new Color object with the result

Color& Color::operator/= double    d
 

Divides every color component by d.

Parameters:
d The parameter to divide by
Returns:
A reference to this object

Color& Color::operator= const Color &    color
 

Sets the current color according to the given color.

Parameters:
color The color to copy
Returns:
A reference to this object

bool Color::operator== const Color &    color const
 

Compares 2 colors and returns true if they are the same.

Parameters:
color The color to compare to
Return values:
true The 2 colors are the same
false The colors are different

double Color::operator[] COLOR    col const
 

Returns the R/G/B value (depends on col).

Parameters:
col Specifies the R/G/B component
Returns:
The current R/G/B value

double& Color::operator[] COLOR    col
 

Returns the R/G/B value (depends on col).

Parameters:
col Specifies the R/G/B component
Returns:
The current R/G/B value

void Color::setColor double    r,
double    g,
double    b
 

Set the color components.

Parameters:
r The red component
g The green component
b The blue component

void Color::setRandomColor  
 

Sets a random color.


The documentation for this class was generated from the following file:
MeshMaker 5.2 Manual
This software library was written by Roni Raab, ronir@cs.technion.ac.il.
Last updated on May 2003.
This software is for academic and research use only.