Helper class for exchanging RGBA colors of three float components. More...
#include <InstantIO/ColorRGBA.h>
Public Member Functions | |
ColorRGBA () | |
Constructor that initializes all components of the color with 0. | |
ColorRGBA (float r, float g, float b, float a) | |
Constructor that initializes the components of the color with the given float values. | |
ColorRGBA (const float *color) | |
Constructor that initializes the components of the color with the values of a given float array. | |
ColorRGBA (const ColorRGBA &color) | |
Constructor that initializes the components of the color with the components taken from another color. | |
const ColorRGBA & | operator= (const ColorRGBA &color) |
Assigns the components of another ColorRGBA object to this object's components. | |
const float * | operator= (const float *color) |
Assigns an array of floats to this object's components. | |
void | setR (float r) |
Sets the value of the r component. | |
float | getR () const |
Returns the value of the r component. | |
void | setG (float g) |
Sets the value of the g component. | |
float | getG () const |
Returns the value of the g component. | |
void | setB (float b) |
Sets the value of the b component. | |
float | getB () const |
Returns the value of the b component. | |
void | setA (float a) |
Sets the value of the a component. | |
float | getA () const |
Returns the value of the a component. | |
void | set (float r, float g, float b, float a) |
Sets the values of the r, g and b components. | |
void | set (const float *color) |
Sets the values of the r, g and b components. | |
void | set (const ColorRGBA &color) |
Sets the values of the r, g and b components. | |
void | get (float &r, float &g, float &b, float &a) const |
Returns the values of the r, b and g components. | |
void | get (float *color) const |
Returns the values of the r, g and b components. | |
void | get (ColorRGBA &color) const |
Returns the values of the r, g and b components. | |
const float * | get () const |
Returns the values of the r, g and b components. | |
float * | get () |
Returns the values of the r, g and b components. | |
float | operator[] (int i) const |
Returns a component of the color specified by an index. | |
float & | operator[] (int i) |
Returns a component of the color specified by an index. | |
operator float * () | |
Converts the ColorRGBA object to an array of floats. | |
operator const float * () const | |
Converts the ColorRGBA object to an array of floats. | |
Friends | |
bool | operator== (const ColorRGBA &a, const ColorRGBA &b) |
Checks if all components of two colors are the same. | |
bool | operator!= (const ColorRGBA &a, const ColorRGBA &b) |
Checks if two colors differ at least in one component. |
Helper class for exchanging RGBA colors of three float components.
ColorRGBA is a basic helper class for exchanging colors of three float components between different software components. It does not contain any means for color arithmetics, only methods for setting and getting the components. It is not meant to be used directly by software components for color representation. Instead, software components should use their own, appropriate classes for handling colors. Only when sending colors to an OutSlot, or when receiving colors from an InSlot, the internal representation of colors should be converted to ColorRGBA's. This ensures the interoperability between different software components that use different internal representations for colors.
InstantIO::ColorRGBA::ColorRGBA | ( | float | r, | |
float | g, | |||
float | b, | |||
float | a | |||
) | [inline] |
Constructor that initializes the components of the color with the given float values.
r | Value of the r component of the new color. | |
g | Value of the g component of the new color. | |
b | Value of the b component of the new color. | |
a | Value of the a component of the new color. |
InstantIO::ColorRGBA::ColorRGBA | ( | const float * | color | ) | [inline] |
Constructor that initializes the components of the color with the values of a given float array.
vec | An array of at least three float values. The r component of the color is set to the value of the first element of the array, the g component is set to the value of the second element of the array, the b component is set to the value of the third element of the array and the a component is set to the value of the fourth element of the array. |
InstantIO::ColorRGBA::ColorRGBA | ( | const ColorRGBA & | color | ) | [inline] |
Constructor that initializes the components of the color with the components taken from another color.
vec | The other color used to initialize the new color. |
Assigns the components of another ColorRGBA object to this object's components.
vec | The other ColorRGBA object |
const float* InstantIO::ColorRGBA::operator= | ( | const float * | color | ) | [inline] |
Assigns an array of floats to this object's components.
vec | An array of at least three float values. The r component of the color is set to the value of the first element of the array, the g component is set to the value of the second element of the array, the g component is set to the value of the third element of the array, and the a component is set to the value of the fourth element of the array. |
void InstantIO::ColorRGBA::setR | ( | float | r | ) | [inline] |
Sets the value of the r component.
r | The new value of the r component |
float InstantIO::ColorRGBA::getR | ( | ) | const [inline] |
Returns the value of the r component.
void InstantIO::ColorRGBA::setG | ( | float | g | ) | [inline] |
Sets the value of the g component.
g | The new value of the g component |
float InstantIO::ColorRGBA::getG | ( | ) | const [inline] |
Returns the value of the g component.
void InstantIO::ColorRGBA::setB | ( | float | b | ) | [inline] |
Sets the value of the b component.
b | The new value of the b component |
float InstantIO::ColorRGBA::getB | ( | ) | const [inline] |
Returns the value of the b component.
void InstantIO::ColorRGBA::setA | ( | float | a | ) | [inline] |
Sets the value of the a component.
a | The new value of the a component |
float InstantIO::ColorRGBA::getA | ( | ) | const [inline] |
Returns the value of the a component.
void InstantIO::ColorRGBA::set | ( | float | r, | |
float | g, | |||
float | b, | |||
float | a | |||
) | [inline] |
Sets the values of the r, g and b components.
r | The new value of the r component | |
g | The new value of the g component | |
b | The new value of the b component | |
a | The new value of the a component |
void InstantIO::ColorRGBA::set | ( | const float * | color | ) | [inline] |
Sets the values of the r, g and b components.
vec | An array of at least three float values. The r component of the color is set to the value of the first element of the array, the g component is set to the value of the second element of the array, and the b component is set to the value of the third element of the array. |
void InstantIO::ColorRGBA::set | ( | const ColorRGBA & | color | ) | [inline] |
Sets the values of the r, g and b components.
vec | The other color used to set the components of this color. |
void InstantIO::ColorRGBA::get | ( | float & | r, | |
float & | g, | |||
float & | b, | |||
float & | a | |||
) | const [inline] |
Returns the values of the r, b and g components.
x | Returns the r component of the color | |
y | Returns the g component of the color | |
z | Returns the b component of the color |
void InstantIO::ColorRGBA::get | ( | float * | color | ) | const [inline] |
Returns the values of the r, g and b components.
vec | A float array that gets filled with the components of the color. This array must have at least three elements. The first element of the array is set to the r component of the color, the second element of the array is set to the g component of the color, and the third element of the array is set to the b component of the color. |
void InstantIO::ColorRGBA::get | ( | ColorRGBA & | color | ) | const [inline] |
Returns the values of the r, g and b components.
vec | The other color whose components are set to components of this color. |
const float* InstantIO::ColorRGBA::get | ( | ) | const [inline] |
Returns the values of the r, g and b components.
float* InstantIO::ColorRGBA::get | ( | ) | [inline] |
Returns the values of the r, g and b components.
float InstantIO::ColorRGBA::operator[] | ( | int | i | ) | const [inline] |
Returns a component of the color specified by an index.
i | The index of the component (must be 0, 1 or 2) |
float& InstantIO::ColorRGBA::operator[] | ( | int | i | ) | [inline] |
Returns a component of the color specified by an index.
i | The index of the component (must be 0, 1 or 2) |
InstantIO::ColorRGBA::operator float * | ( | ) | [inline] |
Converts the ColorRGBA object to an array of floats.
InstantIO::ColorRGBA::operator const float * | ( | ) | const [inline] |
Converts the ColorRGBA object to an array of floats.
Checks if all components of two colors are the same.
a | The first color | |
b | The second color |
Checks if two colors differ at least in one component.
a | The first color | |
b | The second color |