C++ API Reference
|
A color math class. More...
#include <MColor.h>
Public Types | |
enum | MColorType { kRGB, kHSV, kCMY, kCMYK } |
Defines color space. More... | |
Public Member Functions | |
MColor () | |
Default class contructor. More... | |
MColor (const MColor &src) | |
Copy contructor. More... | |
MColor (float rr, float gg, float bb=0.0, float aa=1.0) | |
RGB contructor. More... | |
MColor (const float d[3]) | |
RGB contructor. More... | |
MColor (float alpha) | |
Alpha contructor. More... | |
MColor (MColorType colorModel, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char alpha=255U) | |
Color space contructor. More... | |
MColor (MColorType colorModel, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short alpha=65535U) | |
Color space contructor. More... | |
MColor (MColorType colorModel, float c1, float c2, float c3, float alpha=1.0) | |
Color space contructor. More... | |
MColor (MColorType colorModel, double c1, double c2, double c3, double alpha=1.0) | |
Color space contructor. More... | |
~MColor () | |
Class destructor. More... | |
MColor & | operator= (const MColor &src) |
Assignment operator. More... | |
float | operator() (unsigned int i) const |
Index operator. More... | |
float | operator[] (unsigned int i) const |
Index operator. More... | |
MColor & | operator*= (float scalar) |
In place multiply operator. More... | |
MColor | operator* (float scalar) const |
Multiply operator. More... | |
MColor & | operator*= (const MColor &other) |
In place multiply operator. More... | |
MColor | operator* (const MColor &other) const |
Multiply operator. More... | |
MColor & | operator/= (float scalar) |
In place divide operator. More... | |
MColor | operator/ (float scalar) const |
Divide operator. More... | |
MColor & | operator+= (const MColor &other) |
In place add operator. More... | |
MColor | operator+ (const MColor &other) const |
Add operator. More... | |
MColor | operator- () const |
Unary minus operator. More... | |
MColor | operator- (const MColor &other) const |
Substraction operator. More... | |
bool | operator== (const MColor &other) const |
Equality operator. More... | |
bool | operator!= (const MColor &other) const |
Inequality operator. More... | |
bool | get (float d[3]) const |
Color component accessor. More... | |
bool | get (MColorType colorModel, float &, float &, float &) const |
Color component accessor. More... | |
bool | get (MColorType colorModel, float &, float &, float &, float &alpha) const |
Color component accessor. More... | |
bool | set (MColorType colorModel, float, float, float, float alpha=1.0) |
Color component assigment. More... | |
float & | operator() (unsigned int i) |
Index operator. NO SCRIPT SUPPORT. More... | |
float & | operator[] (unsigned int i) |
Index operator. NO SCRIPT SUPPORT. More... | |
Public Attributes | |
float | r |
The red component of the color. | |
float | g |
The green component of the color. | |
float | b |
The blue component of the color. | |
float | a |
The alpha component of the color. | |
Static Public Attributes | |
static const MColor | kOpaqueBlack |
Opaque black color. | |
Friends | |
OPENMAYA_EXPORT MColor | operator* (float scalar, const MColor &other) |
Multiply operator. NO SCRIPT SUPPORT. More... | |
OPENMAYA_EXPORT std::ostream & | operator<< (std::ostream &os, const MColor &c) |
Print operator. NO SCRIPT SUPPORT. More... | |
A color math class.
This class is used to store values of color attributes. Right now, this class provides no more functionality than the MFltVector class, but it is used because Rendering plans to employ more advanced color models in the future. In these models, colors cannot necessarily be represented as an RGB triple.
enum MColorType |
|
inline |
Default class contructor.
Initializes the object to a black opaque color.
Copy contructor.
Create a new color and initialize it to the same values as the given color.
[in] | src | The color object to copy. |
|
inline |
RGB contructor.
Initializes the color with the explicit r, g, b, and a values provided as arguments.
[in] | rr | The r component of the color. |
[in] | gg | The g component of the color. |
[in] | bb | The b component of the color. Defaults to 0.0. |
[in] | aa | The a component of the color. Defaults to 1.0. |
|
inline |
RGB contructor.
Initializes the color with the explicit red, green and blue values provided in the given float array.
The alpha value will be 1.0: The color is opaque.
[in] | d | The 3 element array containing the initial red, green, and blue values. |
|
inline |
Alpha contructor.
Initializes a black color with transparency.
The r, g, b components are set to 0.
[in] | alpha | The transparency component of the color. |
MColor | ( | MColor::MColorType | colorModel, |
unsigned char | c1, | ||
unsigned char | c2, | ||
unsigned char | c3, | ||
unsigned char | alpha = 255U |
||
) |
Color space contructor.
Initializes the color with the given color model using unsigned int data in range [0-255].
[in] | colorModel | The color model. |
[in] | c1 | First component of color. |
[in] | c2 | Second component of color. |
[in] | c3 | Third component of color. |
[in] | alpha | Transparency. Defaults to opaque (255). |
MColor | ( | MColor::MColorType | colorModel, |
unsigned short | c1, | ||
unsigned short | c2, | ||
unsigned short | c3, | ||
unsigned short | alpha = 65535U |
||
) |
Color space contructor.
Initializes the color with the given color model using unsigned int data in range [0-65535].
[in] | colorModel | The color model. |
[in] | c1 | First component of color. |
[in] | c2 | Second component of color. |
[in] | c3 | Third component of color. |
[in] | alpha | Transparency. Defaults to opaque (65535). |
MColor | ( | MColor::MColorType | colorModel, |
float | c1, | ||
float | c2, | ||
float | c3, | ||
float | alpha = 1.0 |
||
) |
Color space contructor.
Initializes the color with the given color model using float data in range [0-1.0].
[in] | colorModel | The color model. |
[in] | c1 | First component of color. |
[in] | c2 | Second component of color. |
[in] | c3 | Third component of color. |
[in] | alpha | Transparency. Defaults to opaque (1.0). |
MColor | ( | MColor::MColorType | colorModel, |
double | c1, | ||
double | c2, | ||
double | c3, | ||
double | alpha = 1.0 |
||
) |
Color space contructor.
Class constructor.
Initializes the color with the given color model using double precision data in range [0-1.0].
[in] | colorModel | The color model. |
[in] | c1 | First component of color. |
[in] | c2 | Second component of color. |
[in] | c3 | Third component of color. |
[in] | alpha | Transparency. Defaults to opaque (1.0). |
~MColor | ( | ) |
Class destructor.
Deallocates the memory.
Assignment operator.
Copies a color.
[in] | src | The color object to copy. |
|
inline |
Index operator.
Accessor to one component of the color.
[in] | i | Value indicating which component to return. |
|
inline |
Index operator.
Accessor to one component of the color.
[in] | i | Value indicating which component to return. |
MColor & operator*= | ( | float | scalar | ) |
In place multiply operator.
[in] | scalar | Color multiplication factor. |
MColor operator* | ( | float | scalar | ) | const |
In place multiply operator.
Performs a componentwise multiplication of two colors.
[in] | other | Color to be multiplied with this color. |
Multiply operator.
Performs a componentwise multiplication of two colors.
[in] | other | Color to be multiplied with this color. |
MColor & operator/= | ( | float | scalar | ) |
In place divide operator.
[in] | scalar | Color division factor. |
MColor operator/ | ( | float | scalar | ) | const |
Divide operator.
[in] | scalar | Color division factor. |
In place add operator.
[in] | other | Color to be added to this color. |
Add operator.
[in] | other | Color to be added to this color. |
MColor operator- | ( | ) | const |
Unary minus operator.
Negates the value of each of the red, green and blue components of the color.
Transparency is set to opaque.
Substraction operator.
[in] | other | Color to be subtracted from this color. |
bool operator== | ( | const MColor & | other | ) | const |
Equality operator.
Compares the r, g, and b components of two color.
[in] | other | Color to which this color will be compared. |
bool operator!= | ( | const MColor & | other | ) | const |
Inequality operator.
Compares the r, g, and b components of two color.
[in] | other | Color to which this color will be compared. |
|
inline |
Color component accessor.
Extracts the r, g, and b components of the color and places them in elements 0, 1, and 2 of the float array passed.
[out] | d | The array of 3 floats into which the results are placed. |
bool get | ( | MColor::MColorType | colorModel, |
float & | c1, | ||
float & | c2, | ||
float & | c3 | ||
) | const |
Color component accessor.
Retrieves the values of 3 components of the color using the specified color model.
[in] | colorModel | The color model. |
[out] | c1 | Storage for the first component of color. |
[out] | c2 | Storage for the second component of color. |
[out] | c3 | Storage for the third component of color. |
bool get | ( | MColor::MColorType | colorModel, |
float & | c1, | ||
float & | c2, | ||
float & | c3, | ||
float & | alpha | ||
) | const |
Color component accessor.
Retrieves the values of 4 components of the color using the specified color model.
[in] | colorModel | The color model. |
[out] | c1 | Storage for the first component of color. |
[out] | c2 | Storage for the second component of color. |
[out] | c3 | Storage for the third component of color. |
[out] | alpha | Storage for the alpha component of color. |
bool set | ( | MColor::MColorType | colorModel, |
float | c1, | ||
float | c2, | ||
float | c3, | ||
float | alpha = 1.0 |
||
) |
Color component assigment.
Sets the values of the color components using the specified color model.
[in] | colorModel | The color model. |
[in] | c1 | First component of color. |
[in] | c2 | Second component of color. |
[in] | c3 | Third component of color. |
[in] | alpha | Alpha component of color. |
|
inline |
Index operator. NO SCRIPT SUPPORT.
Accessor to one component of the color.
[in] | i | Value indicating which component to return. |
|
inline |
Index operator. NO SCRIPT SUPPORT.
Accessor to one component of the color.
[in] | i | Value indicating which component to return. |
Multiply operator. NO SCRIPT SUPPORT.
[in] | scalar | Color multiplication factor. |
[in] | other | Color object to be multiplied. |
|
friend |
Print operator. NO SCRIPT SUPPORT.
The format used is [r, g, b, a].
[in] | os | The ostream to print to. |
[in] | c | The MColor whose value is to be printed. |