Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

SFColor Class Reference

Encapsulates an SFColor value. More...

Inheritance diagram for SFColor:

FieldValue List of all members.

Public Types

typedef const float (&ConstArrayReference)[3]
typedef float(* ArrayPointer )[3]
typedef const float(* ConstArrayPointer )[3]

Public Methods

typedef float (&ArrayReference)[3]
 SFColor () throw ()
 Construct with the default value, (0, 0, 0).

 SFColor (ConstArrayReference rgb) throw ()
 Construct a SFColor.

 SFColor (float r, float g, float b) throw ()
 Construct a SFColor.

virtual ~SFColor () throw ()
 Destructor.

float operator[] (size_t index) const throw ()
 Array element dereference operator (const version).

float & operator[] (size_t index) throw ()
 Array element dereference operator (non-const version).

float getR () const throw ()
 Get the red component.

float getG () const throw ()
 Get the green component.

float getB () const throw ()
 Get the blue component.

ConstArrayReference get () const throw ()
 Get the value.

void set (ConstArrayReference rgb) throw ()
 Set the value.

void setHSV (float h, float s, float v) throw ()
 Set the value using HSV.

void getHSV (ArrayReference hsv) const throw ()
 Get the value expressed in HSV.

virtual std::auto_ptr< FieldValueclone () const throw (std::bad_alloc)
 Virtual copy constructor.

virtual FieldValueassign (const FieldValue &value) throw (std::bad_cast)
 Virtual assignment.

virtual Type type () const throw ()
 Get the FieldValue::Type associated with this class.


Static Public Methods

void HSVtoRGB (ConstArrayReference hsv, ArrayReference rgb) throw ()
 Convert a color from HSV to RGB.

void RGBtoHSV (ConstArrayReference rgb, ArrayReference hsv) throw ()
 Convert a color from RGB to HSV.


Private Methods

virtual void print (std::ostream &out) const
 Print to an output stream.


Private Attributes

float value [3]

Detailed Description

Encapsulates an SFColor value.


Constructor & Destructor Documentation

SFColor   throw ()
 

Construct with the default value, (0, 0, 0).

SFColor ConstArrayReference    rgb throw () [explicit]
 

Construct a SFColor.

Parameters:
rgb a 3-element array

SFColor float    r,
float    g,
float    b
throw ()
 

Construct a SFColor.

Parameters:
r red component
g green component
b blue component

~SFColor   throw () [virtual]
 

Destructor.


Member Function Documentation

FieldValue & assign const FieldValue   value throw (std::bad_cast) [virtual]
 

Virtual assignment.

Parameters:
value the new value to give the object.
Returns:
a reference to the object.
Exceptions:
std::bad_cast if value is not an SFColor.

Implements FieldValue.

std::auto_ptr< FieldValue > clone   const throw (std::bad_alloc) [virtual]
 

Virtual copy constructor.

Returns:
a pointer to a copy of the object.
Exceptions:
std::bad_alloc if memory allocation fails.

Implements FieldValue.

SFColor::ConstArrayReference get   const throw ()
 

Get the value.

Returns:
a reference to a 3-element array comprising the RGB value.

float getB   const throw ()
 

Get the blue component.

Returns:
the blue component value.

float getG   const throw ()
 

Get the green component.

Returns:
the green component value.

void getHSV ArrayReference    hsv const throw ()
 

Get the value expressed in HSV.

Return values:
hsv a 3-element array comprising the HSV value.

float getR   const throw ()
 

Get the red component.

Returns:
the red component value.

void HSVtoRGB ConstArrayReference    hsv,
ArrayReference    rgb
throw () [static]
 

Convert a color from HSV to RGB.

Convert from HSV (with(with h in [0,360), s, v in [0,1]) to RGB (with each component in [0,1]).

Parameters:
hsv a 3-element array comprising an HSV value
Return values:
rgb a 3-element array comprising an RGB value

float & operator[] size_t    index throw ()
 

Array element dereference operator (non-const version).

Parameters:
index an index from 0 - 2.

float operator[] size_t    index const throw ()
 

Array element dereference operator (const version).

Parameters:
index an index from 0 - 2.

void print std::ostream &    out const [private, virtual]
 

Print to an output stream.

Parameters:
out an output stream.

Implements FieldValue.

void RGBtoHSV ConstArrayReference    rgb,
ArrayReference    hsv
throw () [static]
 

Convert a color from RGB to HSV.

Convert from RGB (with each component in [0,1]) to HSV (with h in [0,360), s, v in [0,1]).

Parameters:
rgb a 3-element array comprising an RGB value.
Return values:
hsv a 3-element array comprising an HSV value.

void set ConstArrayReference    rgb throw ()
 

Set the value.

Parameters:
rgb a 3-element vector comprising a RGB value.

void setHSV float    h,
float    s,
float    v
throw ()
 

Set the value using HSV.

Parameters:
h the hue component
s the saturation component
v the value component

FieldValue::Type type   const throw () [virtual]
 

Get the FieldValue::Type associated with this class.

Returns:
FieldValue::sfcolor.

Implements FieldValue.