Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
om::images::base::Color4D< T > Class Template Reference

A template class representing a 4-component color. More...

#include <omColor4D.h>

Public Member Functions

 Color4D ()
 Create a new 4D color with all elements equal to zero. More...
 
 Color4D (T value)
 Create a new 4D color with all elements equal to a single value. More...
 
 Color4D (const T array[4])
 Create a new 4D color from a pointer to a 4-element array. More...
 
 Color4D (T newR, T newG, T newB, T newA)
 Create a new 4D color by specifying it's R, G, B, and A values. More...
 
 Color4D (const Color4D &color)
 Create a new 4D color from an existing color (copy it). More...
 
template<typename U >
 Color4D (const Color4D< U > &color)
 Create a new 4D color from an existing color (copy it), templatized version. More...
 
 Color4D (const Color3D< T > &color, T newA)
 Create a new 4D color from a 3D color and a value for the alpha component. More...
 
 Color4D (const math::VectorND< T, 4 > &vector)
 Create a new 4D color from an existing vector (copy it). More...
 
T * toArray ()
 Get a shallow array representation of this color. More...
 
const T * toArray () const
 Get a shallow array representation of this color. More...
 
getRed () const
 Get the red component of this color. More...
 
getGreen () const
 Get the green component of this color. More...
 
getBlue () const
 Get the blue component of this color. More...
 
getAlpha () const
 Get the W component of this color. More...
 
Color3D< T > getRGB () const
 Get a 3D color containing the red, green and blue elements of this 4D color. More...
 
void setRed (T newRed)
 Set the red component of the color to the specified value. More...
 
void setGreen (T newGreen)
 Set the green component of the color to the specified value. More...
 
void setBlue (T newBlue)
 Set the blue component of the color to the specified value. More...
 
void setAlpha (T newAlpha)
 Set the W component of the color to the specified value. More...
 
void set (T newRed, T newGreen, T newBlue, T newAlpha)
 Set the R, G, blue, and W components of the color to the specified values. More...
 
T & operator[] (Index index)
 Return a reference to the color component at the specified index. More...
 
const T & operator[] (Index index) const
 Return a const reference to the color component at the specified index. More...
 
template<typename U >
 operator Color4D< U > ()
 This operator casts this color to another with different template paramter. More...
 
template<typename U >
 operator Color4D< U > () const
 This operator casts this color to another with different template paramter. More...
 
template<typename U >
 operator math::VectorND< U, 4 > () const
 This operator casts this color to another with different template paramter. More...
 
bool operator== (const Color4D< T > &v) const
 Compare two colors component-wise for equality. More...
 
bool operator!= (const Color4D< T > &v) const
 Compare two colors component-wise for inequality. More...
 
Color4D< T > operator+ (const Color4D< T > &color) const
 Add this color to another and return the result. More...
 
Color4D< T > operator+ (const T &value) const
 Add a value to every component of this color. More...
 
Color4D< T > operator- (const Color4D< T > &color) const
 Subtract a color from this color component-wise and return the result. More...
 
Color4D< T > operator- (const T &value) const
 Subtract a value from every component of this color. More...
 
Color4D< T > operator* (const Color4D< T > &color) const
 Multiply component-wise this color and another color. More...
 
Color4D< T > operator* (const T &value) const
 Multiply every component of this color by a value and return the result. More...
 
Color4D< T > operator/ (const T &value) const
 Divide every component of this color by a value and return the result. More...
 
Color4D< T > & operator+= (const Color4D< T > &color)
 Add a color to this color, modifying this original color. More...
 
Color4D< T > & operator-= (const Color4D< T > &color)
 Subtract a color from this color, modifying this original color. More...
 
Color4D< T > & operator*= (const Color4D< T > &color)
 Multiply component-wise this color and another color and modify this color. More...
 
Color4D< T > & operator+= (const T &value)
 Add a value to each component of this color, modifying it. More...
 
Color4D< T > & operator-= (const T &value)
 Subtract a value from each component of this color, modifying it. More...
 
Color4D< T > & operator*= (const T &value)
 Multiply a value with each component of this color, modifying it. More...
 
Color4D< T > & operator/= (const T &value)
 Divide each component of this color by a value, modifying it. More...
 
data::String toString () const
 Convert this color into a human-readable string representation. More...
 
 operator data::String () const
 Convert this color into a human-readable string representation. More...
 

Public Attributes

r
 The red component of a 3D color. More...
 
g
 The green component of a 3D color. More...
 
b
 The blue component of a 3D color. More...
 
a
 The W component of a 3D color. More...
 

Static Public Attributes

static const Color4D< T > ZERO
 A constant color with all elements equal to zero. More...
 
static const Color4D< T > BLACK
 A constant color with R, G, and B equal to zero, and A equal to 1. More...
 
static const Color4D< T > WHITE
 A constant color with all elements equal to one. More...
 

Detailed Description

template<typename T>
class om::images::base::Color4D< T >

A template class representing a 4-component color.

Constructor & Destructor Documentation

template<typename T >
om::images::base::Color4D< T >::Color4D ( )
inline

Create a new 4D color with all elements equal to zero.

template<typename T >
om::images::base::Color4D< T >::Color4D ( value)
inlineexplicit

Create a new 4D color with all elements equal to a single value.

This constructor creates a uniform 4D color with all elements equal to each other and equal to the single constructor parameter value.

Parameters
value- The value to set all elements of the color to.
template<typename T >
om::images::base::Color4D< T >::Color4D ( const T  array[4])
inlineexplicit

Create a new 4D color from a pointer to a 4-element array.

template<typename T >
om::images::base::Color4D< T >::Color4D ( newR,
newG,
newB,
newA 
)
inline

Create a new 4D color by specifying it's R, G, B, and A values.

template<typename T >
om::images::base::Color4D< T >::Color4D ( const Color4D< T > &  color)
inline

Create a new 4D color from an existing color (copy it).

template<typename T >
template<typename U >
om::images::base::Color4D< T >::Color4D ( const Color4D< U > &  color)
inline

Create a new 4D color from an existing color (copy it), templatized version.

This constructor takes the x, y, z, and w values of the color parameter and sets the components of this color to be the same.

template<typename T >
om::images::base::Color4D< T >::Color4D ( const Color3D< T > &  color,
newA 
)
inline

Create a new 4D color from a 3D color and a value for the alpha component.

This constructor takes the red, green, and blue components of the first parameter, a 2D color, and sets the red, green, and blue components of this color to be the same. It then takes the 4nd parameter and sets the W component of this color to be that value.

Parameters
color- A 3D color for the red, green, and blue components of this color.
newA- The value for the alpha component of this color.
template<typename T >
om::images::base::Color4D< T >::Color4D ( const math::VectorND< T, 4 > &  vector)
inline

Create a new 4D color from an existing vector (copy it).

This constructor takes the x, y, z, and w values of the vector parameter and sets the components of this color to be the same.

Member Function Documentation

template<typename T >
T* om::images::base::Color4D< T >::toArray ( )
inline

Get a shallow array representation of this color.

This method returns a pointer to the address of the red component of the color and does not do any copying of the elements. Therefore, this method should only be used where one needs an array representation of a color without having to allocate more memory and copy the color.

Returns
A pointer to a shallow array copy of this color.
template<typename T >
const T* om::images::base::Color4D< T >::toArray ( ) const
inline

Get a shallow array representation of this color.

This method returns a pointer to the address of the red component of the color and does not do any copying of the elements. Therefore, this method should only be used where one needs an array representation of a color without having to allocate more memory and copy the color.

Returns
A pointer to a shallow array copy of this color.
template<typename T >
T om::images::base::Color4D< T >::getRed ( ) const
inline

Get the red component of this color.

template<typename T >
T om::images::base::Color4D< T >::getGreen ( ) const
inline

Get the green component of this color.

template<typename T >
T om::images::base::Color4D< T >::getBlue ( ) const
inline

Get the blue component of this color.

template<typename T >
T om::images::base::Color4D< T >::getAlpha ( ) const
inline

Get the W component of this color.

template<typename T >
Color3D<T> om::images::base::Color4D< T >::getRGB ( ) const
inline

Get a 3D color containing the red, green and blue elements of this 4D color.

template<typename T >
void om::images::base::Color4D< T >::setRed ( newRed)
inline

Set the red component of the color to the specified value.

template<typename T >
void om::images::base::Color4D< T >::setGreen ( newGreen)
inline

Set the green component of the color to the specified value.

template<typename T >
void om::images::base::Color4D< T >::setBlue ( newBlue)
inline

Set the blue component of the color to the specified value.

template<typename T >
void om::images::base::Color4D< T >::setAlpha ( newAlpha)
inline

Set the W component of the color to the specified value.

template<typename T >
void om::images::base::Color4D< T >::set ( newRed,
newGreen,
newBlue,
newAlpha 
)
inline

Set the R, G, blue, and W components of the color to the specified values.

This method takes 4 parameter representing the 4 components of this color and sets this color's components to have those values.

Parameters
newRed- The new red component of the color.
newGreen- The new green component of the color.
newBlue- The new blue component of the color.
newAlpha- The new alpha component of the color.
template<typename T >
T& om::images::base::Color4D< T >::operator[] ( Index  index)
inline

Return a reference to the color component at the specified index.

template<typename T >
const T& om::images::base::Color4D< T >::operator[] ( Index  index) const
inline

Return a const reference to the color component at the specified index.

template<typename T >
template<typename U >
om::images::base::Color4D< T >::operator Color4D< U > ( )
inline

This operator casts this color to another with different template paramter.

This method provides an operator for the casting of this color to another color with a potentially different template paramter.

Returns
the cast version of this color.
template<typename T >
template<typename U >
om::images::base::Color4D< T >::operator Color4D< U > ( ) const
inline

This operator casts this color to another with different template paramter.

This method provides an operator for the casting of this color to another color with a potentially different template paramter. This is the const version of this operator.

Returns
the cast version of this color.
template<typename T >
template<typename U >
om::images::base::Color4D< T >::operator math::VectorND< U, 4 > ( ) const
inline

This operator casts this color to another with different template paramter.

This method provides an operator for the casting of this color to another color with a potentially different template paramter. This is the const version of this operator.

Returns
the cast version of this color.
template<typename T >
bool om::images::base::Color4D< T >::operator== ( const Color4D< T > &  v) const
inline

Compare two colors component-wise for equality.

template<typename T >
bool om::images::base::Color4D< T >::operator!= ( const Color4D< T > &  v) const
inline

Compare two colors component-wise for inequality.

template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator+ ( const Color4D< T > &  color) const
inline

Add this color to another and return the result.

This method adds another color to this one, component-wise, and returns this addition. It does not modify either of the original colors.

Parameters
color- The color to add to this one.
Returns
The addition of this color and the parameter.
template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator+ ( const T &  value) const
inline

Add a value to every component of this color.

This method adds the value parameter to every component of the color, and returns a color representing this result. It does not modifiy the original color.

Parameters
value- The value to add to all components of this color.
Returns
The resulting color of this addition.
template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator- ( const Color4D< T > &  color) const
inline

Subtract a color from this color component-wise and return the result.

This method subtracts another color from this one, component-wise, and returns this subtraction. It does not modify either of the original colors.

Parameters
color- The color to subtract from this one.
Returns
The subtraction of the the parameter from this color.
template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator- ( const T &  value) const
inline

Subtract a value from every component of this color.

This method subtracts the value parameter from every component of the color, and returns a color representing this result. It does not modifiy the original color.

Parameters
value- The value to subtract from all components of this color.
Returns
The resulting color of this subtraction.
template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator* ( const Color4D< T > &  color) const
inline

Multiply component-wise this color and another color.

This operator multiplies each component of this color by the corresponding component of the other color and returns a color representing this result. It does not modify either original color.

Parameters
color- The color to multiply this color by.
Returns
The result of the multiplication.
template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator* ( const T &  value) const
inline

Multiply every component of this color by a value and return the result.

This method multiplies the value parameter with every component of the color, and returns a color representing this result. It does not modifiy the original color.

Parameters
value- The value to multiplly with all components of this color.
Returns
The resulting color of this multiplication.
template<typename T >
Color4D<T> om::images::base::Color4D< T >::operator/ ( const T &  value) const
inline

Divide every component of this color by a value and return the result.

This method Divides every component of the color by the value parameter, and returns a color representing this result. It does not modifiy the original color.

Parameters
value- The value to divide all components of this color by.
Returns
The resulting color of this division.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator+= ( const Color4D< T > &  color)
inline

Add a color to this color, modifying this original color.

This method adds another color to this color, component-wise, and sets this color to have the result of this addition.

Parameters
color- The color to add to this color.
Returns
A reference to this modified color.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator-= ( const Color4D< T > &  color)
inline

Subtract a color from this color, modifying this original color.

This method subtracts another color from this color, component-wise, and sets this color to have the result of this subtraction.

Parameters
color- The color to subtract from this color.
Returns
A reference to this modified color.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator*= ( const Color4D< T > &  color)
inline

Multiply component-wise this color and another color and modify this color.

This operator multiplies each component of this color by the corresponding component of the other color and modifies this color to contain the result.

Parameters
color- The color to multiply this color by.
Returns
A reference to this modified color.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator+= ( const T &  value)
inline

Add a value to each component of this color, modifying it.

This operator adds a value to each component of this color and modifies this color to store the result.

Parameters
value- The value to add to every component of this color.
Returns
A reference to this modified color.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator-= ( const T &  value)
inline

Subtract a value from each component of this color, modifying it.

This operator subtracts a value from each component of this color and modifies this color to store the result.

Parameters
value- The value to subtract from every component of this color.
Returns
A reference to this modified color.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator*= ( const T &  value)
inline

Multiply a value with each component of this color, modifying it.

This operator multiplies a value with each component of this color and modifies this color to store the result.

Parameters
value- The value to multiply with every component of this color.
Returns
A reference to this modified color.
template<typename T >
Color4D<T>& om::images::base::Color4D< T >::operator/= ( const T &  value)
inline

Divide each component of this color by a value, modifying it.

This operator Divides each component of this color by value and modifies this color to store the result.

Parameters
value- The value to multiply with every component of this color.
Returns
A reference to this modified color.
template<typename T >
data::String om::images::base::Color4D< T >::toString ( ) const
inline

Convert this color into a human-readable string representation.

template<typename T >
om::images::base::Color4D< T >::operator data::String ( ) const
inline

Convert this color into a human-readable string representation.

Member Data Documentation

template<typename T >
T om::images::base::Color4D< T >::r

The red component of a 3D color.

template<typename T >
T om::images::base::Color4D< T >::g

The green component of a 3D color.

template<typename T >
T om::images::base::Color4D< T >::b

The blue component of a 3D color.

template<typename T >
T om::images::base::Color4D< T >::a

The W component of a 3D color.

template<typename T >
const Color4D< T > om::images::base::Color4D< T >::ZERO
static

A constant color with all elements equal to zero.

template<typename T >
const Color4D< T > om::images::base::Color4D< T >::BLACK
static

A constant color with R, G, and B equal to zero, and A equal to 1.

template<typename T >
const Color4D< T > om::images::base::Color4D< T >::WHITE
static

A constant color with all elements equal to one.


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