#include <Color.h>
A color may have any number of components that can be stored as any data types. It is advisable not to use class types as color components because color copies are implemented as raw memory transfers. Constructors are thus not called.
Public Methods | |
| Color () | |
| The default constructor. | |
| Color (T value) | |
| Construct a new color whose components are reset to the given value. | |
| Color (const Color &other) | |
| The copy constructor. | |
| template<class U> | Color (const Color< U, comps > &other) |
| Create a typecasted copy of another color. | |
| T | getComponent (int index) |
| Get a color component. | |
| void | setComponent (int index, T value) |
| Set the value of a color channel. | |
| T * | getComponents (void) |
| Get the color components as an array. | |
| void | setComponents (T *array) |
| Set the color components all at once. | |
| Color & | operator= (const Color &other) |
| Copy a color. | |
| Color & | operator= (T value) |
| Set all color channels to the same value. | |
| T & | operator[] (int index) |
| Get a given color channel. | |
| T | operator[] (int index) const |
| Get a given color channel. | |
| void | operator+= (Color other) |
| Add the corresponding color channels together. | |
| void | operator-= (Color other) |
| Subract the corresponding color channels from each other. | |
| void | operator *= (Color other) |
| Multiply corresponding color channels by each other. | |
| void | operator/= (Color other) |
| Divide corresponding color channels by each other. | |
| void | operator *= (double value) |
| Multiply all channels by a value. | |
| void | operator/= (double value) |
| Divide all channels by a value. | |
| void | operator+= (double value) |
| Add a value to all color channels. | |
| void | operator-= (double value) |
| Subtract a value from all color channels. | |
| template<class U> | operator Color () |
| Cast a color to a different type of color. | |
| template<class U> Color & | operator= (const Color< U, comps > &other) |
| Make a typecasted copy of a color. | |
Protected Attributes | |
| T | _aComponents [comps] |
| The component array. | |
Friends | |
| class | ColorTransform |
| template<class U, int nc> bool | operator== (const Color< U, nc > &clr1, const Color< U, nc > &clr2) |
| Compare two colors. | |
| template<class U, int nc> bool | operator!= (const Color< U, nc > &clr1, const Color< U, nc > &clr2) |
| Compare two colors. | |
| template<class U, int nc> Color< U, nc > | operator * (const Color< U, nc > &clr, double value) |
| Multiply all channes by a value. | |
| template<class U, int nc> Color< U, nc > | operator/ (const Color< U, nc > &clr, double value) |
| Divide all channes by a value. | |
| template<class U, int nc> Color< U, nc > | operator+ (const Color< U, nc > &clr, double value) |
| Add a value to all channes. | |
| template<class U, int nc> Color< U, nc > | operator- (const Color< U, nc > &clr, double value) |
| Subtract a value from all channes. | |
| template<class U, int nc> Color< U, nc > | operator+ (const Color< U, nc > &clr1, const Color< U, nc > &clr2) |
| Sum corresponding channels together. | |
| template<class U, int nc> Color< U, nc > | operator- (const Color< U, nc > &clr1, const Color< U, nc > &clr2) |
| Subtract corresponding channels from each other. | |
| template<class U, int nc> Color< U, nc > | operator * (const Color< U, nc > &clr1, const Color< U, nc > &clr2) |
| Multiply corresponding channels by each other. | |
| template<class U, int nc> Color< U, nc > | operator/ (const Color< U, nc > &clr1, const Color< U, nc > &clr2) |
| Divide corresponding channels by each other. | |
| template<class U, int nc> std::ostream & | operator<< (std::ostream &sout, const Color< U, nc > &c) |
| Write to a stream. | |
| template<class U, int nc> std::istream & | operator>> (std::istream &sin, Color< U, nc > &c) |
| Read from a stream. | |
| template<class U, class V, int nc> Color< double, nc > | operator * (const util::Matrix< V > &mat, const Color< U, nc > &clr) throw (util::MatrixException&) |
| Transform this a color by a comps-by-comps transformation matrix. | |
|
|||||||||
|
The default constructor. Initializes the component array by filling it with zero bytes. Using floating point component values may result in weird initial values and you may want to use the Color(value) constructor instead. |
|
||||||||||
|
Construct a new color whose components are reset to the given value.
|
|
||||||||||
|
Get a color component. For example, in an RGB color, index 0 represents the green channel and index 2 represents the blue channel.
|
|
||||||||||
|
Get the color components as an array.
|
|
||||||||||
|
Get a given color channel.
|
|
||||||||||
|
Get a given color channel.
|
|
||||||||||||||||
|
Set the value of a color channel.
|
|
||||||||||
|
Set the color components all at once.
|
|
||||||||||||||||||||
|
Compare two colors. Colors are different if any of their corresponding components are different. |
|
||||||||||||||||||||
|
Compare two colors. Colors are equal if all of their corresponding components are equal. |