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

# openvrml::color_rgba Struct Reference

A POD-struct comprising a color with an alpha channel. More...

`#include <openvrml/basetypes.h>`

List of all members.

## Public Member Functions

const float & | operator[] (std::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.
float | a () const throw ()
| Get the alpha 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 | a (float value) throw ()
| Set the alpha component.
void | hsv (float(&result)[4]) const throw ()
| Get the color_rgba as hue, saturation, and value.
void | hsv (float h, float s, float v, float a=1.0f) throw ()
| Set the color_rgba from hue, saturation, and value.

## Public Attributes

float | rgba [4]
| RGB triplet plus alpha.

## Related Functions

(Note that these are not member functions.)
const openvrml::color_rgba | make_color_rgba () throw()
| Create a zero-initialized `color_rgba`.
const openvrml::color_rgba | make_color_rgba (const float(&rgba)[4]) throw()
| Create a `color_rgba`.
const openvrml::color_rgba | make_color_rgba (const float r, const float g, const float b, const float a) throw()
| Create a `color_rgba`.
bool | operator== (const color_rgba &lhs, const color_rgba &rhs) throw()
| Compare for equality.
bool | operator!= (const color_rgba &lhs, const color_rgba &rhs) throw()
| Compare for inequality.
std::istream & | operator>> (std::istream &in, color_rgba &c)
| Stream input.
std::ostream & | operator<< (std::ostream &out, const color_rgba &c)
| Stream output.

## Detailed Description

A POD-struct comprising a color with an alpha channel.

VRML `color_rgbas` are represented as four single-precision floating point components—red, green, blue, and alpha—ranging from 0.0 to 1.0. For the alpha channel, 1.0 is opaque.

## Member Function Documentation

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

Index-based component access.

Parameters:

  `[in]` | index | 0 is the red component, 1 is the green component, 2 is the blue component, and 3 is the alpha component.

Returns:
  the component corresponding to `index`.

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

Get the red component.

Returns:
  the red component.

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

Get the green component.

Returns:
  the green component.

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

Get the blue component.

Returns:
  the blue component.

float openvrml::color_rgba::a | ( |  | ) | const throw ()`[inline]`

Get the alpha component.

Returns:
  the alpha component.

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

Set the red component.

Parameters:

  `[in]` | value | the new component value.

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

Set the green component.

Parameters:

  `[in]` | value | the new component value.

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

Set the blue component.

Parameters:

  `[in]` | value | the new component value.

void openvrml::color_rgba::a | ( | float | value | ) | throw ()`[inline]`

Set the alpha component.

Parameters:

  `[in]` | value | the new component value.

void openvrml::color_rgba::hsv | ( | float(&) | result[4] | ) | const throw ()

Get the color_rgba as hue, saturation, and value.

Parameters:

  `[out]` | result | the hue, saturation, and value.

void openvrml::color_rgba::hsv | ( | float | h,
|  | float | s,
|  | float | v,
|  | float | a = `1.0f` |
| ) |  |  | throw ()

Set the color_rgba from hue, saturation, and value.

Parameters:

  `[in]` | h | hue.
  `[in]` | s | saturation.
  `[in]` | v | value.
  `[in]` | a | alpha.

## Friends And Related Function Documentation

const openvrml::color_rgba make_color_rgba | ( |  | ) | throw()`[related]`

Create a zero-initialized `color_rgba`.

Returns:
  a zero-initialized `color_rgba`.

const openvrml::color_rgba make_color_rgba | ( | const float(&) | rgba[4] | ) | throw()`[related]`

Create a `color_rgba`.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

  `[in]` | rgba | an array comprising red, green, blue, and alpha components.

Returns:
  a `color_rgba`.

const openvrml::color_rgba make_color_rgba | ( | const float | r,
|  | const float | g,
|  | const float | b,
|  | const float | a |
| ) |  |  | throw()`[related]`

Create a `color_rgba`.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

  `[in]` | r | red component.
  `[in]` | g | green component.
  `[in]` | b | blue component.
  `[in]` | a | alpha component.

Returns:
  a `color_rgba`.

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

Compare for equality.

Parameters:

  `[in]` | lhs | left-hand operand.
  `[in]` | rhs | right-hand operand.

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

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

Compare for inequality.

Parameters:

  `[in]` | lhs | left-hand operand.
  `[in]` | rhs | right-hand operand.

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

std::istream & operator>> | ( | std::istream & | in,
|  | color_rgba & | c |
| ) |  |  | `[related]`

Stream input.

Consistent with the VRML97 convention, commas (“``,”) in the input are treated as whitespace.

If any of the color components is outside the the range [0.0, 1.0], the `failbit` will be set on `in` and `c` will be left in an arbitrary state.

Parameters:

  `[in,out]` | in | input stream.
  `[out]` | c | a `color_rgba`.

Returns:
  `in`.

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

Stream output.

Parameters:

  `[in,out]` | out | output stream.
  `[in]` | c | a color_rgba.

Returns:
  `out`.

## Member Data Documentation

float openvrml::color_rgba::rgba[4]

RGB triplet plus alpha.