Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

# openvrml::color Class Reference
[Base Types]

List of all members.

## Detailed Description

A color.

VRML colors are represented as three single precision floating point components--red, green, and blue--ranging from 0.0 to 1.0.

## Public Member Functions

| color () throw ()
| Construct.
| color (const float(&rgb)[3]) throw ()
| Construct from a 3-element float array.
| color (float r, float g, float b) throw ()
| Construct from red, green, and blue components.
const float & | operator[] (size_t index) const throw ()
| Index-based component access.
float | r () const throw ()
| Get the red component.
float | g () const throw ()
| Get the green component.
float | b () const throw ()
| Get the blue component.
void | r (float value) throw ()
| Set the red component.
void | g (float value) throw ()
| Set the green component.
void | b (float value) throw ()
| Set the blue component.
void | hsv (float(&result)[3]) const throw ()
| Get the color as hue, saturation, and value.
void | hsv (float h, float s, float v) throw ()
| Set the color from hue, saturation, and value.

## Private Attributes

float | rgb [3]
| RGB triplet.

## Related Functions

(Note that these are not member functions.)
bool | operator== (const color &lhs, const color &rhs) throw()
| Compare for equality.
bool | operator!= (const color &lhs, const color &rhs) throw()
| Compare for inequality.
std::ostream & | operator<< (std::ostream &out, const color &c)
| Stream output.

## Constructor & Destructor Documentation

openvrml::color::color | ( |  | ) | throw ()

| Construct.

openvrml::color::color | ( | const float & | rgb[3] | ) | throw ()`[explicit]`

Construct from a 3-element float array.

Parameters:

  | rgb | an array comprising red, green, and blue components.

openvrml::color::color | ( | float | r,
|  | float | g,
|  | float | b
| ) | throw ()

Construct from red, green, and blue components.

Parameters:

  | r | red component.
  | g | green component.
  | b | blue component.

## Member Function Documentation

const float & openvrml::color::operator[] | ( | size_t | index | ) | const throw ()`[inline]`

Index-based component access.

Parameters:

  | index | 0 is the red component, 1 is the green component, and 2 is the blue component.

Returns:
  the component corresponding to `index`.

float openvrml::color::r | ( |  | ) | const throw ()`[inline]`

Get the red component.

Returns:
  the red component.

float openvrml::color::g | ( |  | ) | const throw ()`[inline]`

Get the green component.

Returns:
  the green component.

float openvrml::color::b | ( |  | ) | const throw ()`[inline]`

Get the blue component.

Returns:
  the blue component.

void openvrml::color::r | ( | float | value | ) | throw ()`[inline]`

Set the red component.

Parameters:

  | value | the new component value.

void openvrml::color::g | ( | float | value | ) | throw ()`[inline]`

Set the green component.

Parameters:

  | value | the new component value.

void openvrml::color::b | ( | float | value | ) | throw ()`[inline]`

Set the blue component.

Parameters:

  | value | the new component value.

void openvrml::color::hsv | ( | float & | result[3] | ) | const throw ()

Get the color as hue, saturation, and value.

Return values:

  | result | the hue, saturation, and value.

void openvrml::color::hsv | ( | float | h,
|  | float | s,
|  | float | v
| ) | throw ()

Set the color from hue, saturation, and value.

Parameters:

  | h | hue.
  | s | saturation.
  | v | value.

## Friends And Related Function Documentation

bool operator== | ( | const color & | lhs,
|  | const color & | rhs
| ) | throw()`[related]`

Compare for equality.

Parameters:

  | lhs | left-hand operand.
  | rhs | right-hand operand.

Returns:
  `true` if `lhs` and `rhs` have the same value; `false` otherwise.

bool operator!= | ( | const color & | lhs,
|  | const color & | rhs
| ) | throw()`[related]`

Compare for inequality.

Parameters:

  | lhs | left-hand operand.
  | rhs | right-hand operand.

Returns:
  `true` if `lhs` and `rhs` dot not have the same value; `false` otherwise.

std::ostream & operator<< | ( | std::ostream & | out,
|  | const color & | c
| ) | `[related]`

Stream output.

Parameters:

  | out | output stream.
  | c | a color.

Returns:
  `out`.

## Member Data Documentation

float openvrml::color::rgb[3]`[private]`

| RGB triplet. For internal use only.