class MColor

Jump to documentation

A color math class. (OpenMaya) (OpenMaya.py)

public members:

enum MColorType
kRGB
kHSV
kCMY
kCMYK
MColor ()
MColor ( const MColor & src)
MColor ( float rr, float gg, float bb=0.0, float aa=1.0 )
MColor ( const float d[3] )
MColor ( float alpha )
MColor ( MColorType colorModel, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char alpha=255U )
MColor ( MColorType colorModel, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short alpha=65535U )
MColor ( MColorType colorModel, float c1, float c2, float c3, float alpha=1.0 )
MColor ( MColorType colorModel, double c1, double c2, double c3, double alpha=1.0 )
~MColor ()
MColor & operator= ( const MColor & src )
float operator() ( unsigned int i ) const
float operator[] ( unsigned int i )const
MColor & operator/= ( float scalar )
MColor operator/ ( float scalar ) const
MColor & operator*= ( float scalar )
MColor operator* ( float scalar ) const
MColor operator+ ( const MColor & other) const
MColor & operator+= ( const MColor & other )
MColor operator- () const
MColor operator- ( const MColor & other ) const
MColor operator* ( const MColor & other ) const
MColor & operator*= ( const MColor & other )
bool operator!= ( const MColor & other ) const
bool operator== ( const MColor & other ) const
bool get ( float d[3] ) const
bool get ( MColorType colorModel, float&, float&, float& ) const
bool get ( MColorType colorModel, float&, float&, float&, float& alpha ) const
bool set ( MColorType colorModel, float, float, float, float alpha = 1.0)
float& operator() ( unsigned int i )
NO SCRIPT SUPPORT
float& operator[] ( unsigned int i )
NO SCRIPT SUPPORT
friend MColor operator* ( float scalar, const MColor & other)
NO SCRIPT SUPPORT
friend std::ostream& operator<< (std::ostream& os, const MColor & c)
NO SCRIPT SUPPORT
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

Documentation

This class is used to store values of color-related dependency graph node attributes.
Description

This class is used to store values of color attributes. Its structure is compatible with that of the internal T4dFltVector class. 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.

Functions

MColor:: MColor ()

Description

The default class constructor. Creates a black color.

MColor:: MColor (const MColor & src)

Description

The copy constructor. Create a new color and initialize it to the same values as the given color.

Arguments

  • src the color object to copy

MColor:: MColor (float rr, float gg, float bb, float aa )

Description

Class constructor. Initializes the color with the explicit r, g,, b, and a values provided as arguments.

Arguments

  • rr the r component of the color
  • gg the g component of the color
  • bb the b component of the color. Defaults to 0.0.
  • aa the a component of the color. Defaults to 1.0.

MColor:: MColor ( const float d[3] )

Description

Class constructor. Initializes the color with the explicit r, g and b values provided in the given float array. The alpha value will be 1.0.

Arguments

  • d the 3 element array containing the initial r, g, and b values

MColor:: MColor (float alpha )

Description

Class constructor. Initializes the color with the explicit alpha. r,g, b will have default 0.

Arguments

  • alpha the a component of the color.

MColor:: MColor ( MColor::MColorType colorModel, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char alpha )

Description

Class constructor. Initializes the color with the given color model using unsigned int data in range [0-255].

Arguments

  • colorModel the color model
  • c1 first component of color
  • c2 second component of color
  • c3 third component of color
  • alpha

MColor:: MColor ( MColor::MColorType colorModel, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short alpha )

Description

Class constructor. Initializes the color with the given color model using unsigned int data in range [0-65535].

Arguments

  • colorModel the color model
  • c1 first component of color
  • c2 second component of color
  • c3 third component of color
  • alpha

MColor:: MColor ( MColor::MColorType colorModel, float c1, float c2, float c3, float alpha )

Description

Class constructor. Initializes the color with the given color model using float data in range [0-1.0].

Arguments

  • colorModel the color model
  • c1 first component of color
  • c2 second component of color
  • c3 third component of color
  • alpha

MColor:: MColor ( MColor::MColorType colorModel, double c1, double c2, double c3, double alpha )

Description

Class constructor. Initializes the color with the given color model using double precision data in range [0-1.0].

Arguments

  • colorModel the color model
  • c1 first component of color
  • c2 second component of color
  • c3 third component of color
  • alpha

MColor:: ~MColor ()

Description

Class destructor.

MColor & MColor:: operator= (const MColor & src)

Description

The assignment operator. Allows assignment between MColors.

Arguments

  • src the color object to copy

Return Value

  • A reference to the object whose value was set.

float& MColor:: operator() ( unsigned int i )

Description

The index operator. If its argument is 0 it will return the r component of the color. If its argument is 1 it will return the g component of the color, if its argument is 2 it will return the b component of the color. Otherwise it will return the a component of the color.

Arguments

  • i value indicating which component to return

Return Value

  • A reference to the appropriate component of the color

float MColor:: operator() ( unsigned int i ) const

Description

The index operator. If its argument is 0 it will return the r component of the color. If its argument is 1 it will return the g component of the color, if its argument is 2 it will return the b component of the color. Otherwise it will return the a component of the color.

Arguments

  • i value indicating which component to return

Return Value

  • The value of the appropriate component of the color.

float& MColor:: operator[] ( unsigned int i )

Description

The index operator. If its argument is 0 it will return the r component of the color. If its argument is 1 it will return the g component of the color, if its argument is 2 it will return the b component of the color. Otherwise it will return the a component of the color.

Arguments

  • i value indicating which component to return

Return Value

  • A reference to the appropriate component of the color.

float MColor:: operator[] ( unsigned int i ) const

Description

The index operator. If its argument is 0 it will return the r component of the color. If its argument is 1 it will return the g component of the color, if its argument is 2 it will return the b component of the color. Otherwise it will return the a component of the color.

Arguments

  • i value indicating which component to return

Return Value

  • The value of the appropriate component of the color.

MColor & MColor:: operator*= (float scalar)

Description

The in place scalar multiplication operator.

Arguments

  • scalar value by which all components of the color will be multiplied.

Return Value

  • A reference to the color whose value was modified.

MColor MColor:: operator* ( float scalar ) const

Description

The scalar multiplication operator.

Arguments

  • scalar value by which all components of the color will be multiplied.

Return Value

  • A new MColor object representing the product of the original MColor with the scalar value.

MColor operator * (float scalar, const MColor & other)

Description

The scalar multiplication operator that allows the scalar value to preceed the color.

Arguments

  • scalar value by which all components of the color will be multiplied.
  • other color to be multiplied.

Return Value

  • A new MColor object representing the product of the specified scalar and color.

MColor & MColor:: operator/= (float scalar)

Description

The in place scalar division operator.

Arguments

  • scalar value by which all components of the color will be divided

Return Value

  • A reference to the color whose value was modified.

MColor MColor:: operator/ ( float scalar ) const

Description

The scalar division operator.

Arguments

  • scalar value by which all components of the color will be divided.

Return Value

  • A new MColor object representing the color divided by the scalar.

MColor MColor:: operator- (const MColor & other) const

Description

The color subtraction operator.

Arguments

  • other color to be subtracted from this color.

Return Value

  • A new MColor object representing this color minus the specified other color..

MColor MColor:: operator+ (const MColor & other) const

Description

The color addition operator.

Arguments

  • other color to be added to this color.

Return Value

  • A new MColor object representing the sum of this color and the specified color.

MColor & MColor:: operator+= (const MColor & other)

Description

The in place color addition operator.

Arguments

  • other color to be added to this color.

Return Value

  • A reference to the color whose value was modified.

MColor MColor:: operator- () const

Description

The unary minus operator. Negates the value of each of the x, y, and z components of the color.

Return Value

  • A reference to the color whose value was negated.

MColor & MColor:: operator*= (const MColor & other)

Description

The in-place color multiplication operator. Performs a componentwise multiplication of two colors.

Arguments

  • other color by which this color will be multiplied.

Return Value

  • A reference to the color whose value was modified.

MColor MColor:: operator* (const MColor & other) const
Description

The color multiplication operator. Performs a componentwise multiplication of two colors.

Arguments

  • other color by which this color will be multiplied.

Return Value

  • A new MColor object representing the product of the two colors.

bool MColor:: operator== (const MColor & other) const

Description

The color equality operator. This returns true if all three of the r, g, and b components are identical.

Arguments

  • other color to which this color will be compared.

Return Value

  • bool true if the colors are identical and false otherwise

bool MColor:: operator!= (const MColor & other) const

Description

The color inequality operator. This returns false if all three of the r, g, and b components are identical.

Arguments

  • other color to which this color will be compared.

Return Value

  • bool false if the colors are identical and true otherwise

bool MColor:: get ( float d[3] ) const

Description

Extracts the r, g, and b components of the color and places them in elements 0, 1, and 2 of the float array passed.

Arguments

  • d the array of 3 floats into which the results are placed.

Return Value

  • always returns bool true

bool MColor:: get ( MColor::MColorType colorModel, float& c1, float& c2, float& c3 ) const

Description

Retrieves the values of 3 components of the color using the specified color model.

Arguments

  • colorModel the color model
  • c1 storage for the first component of color
  • c2 storage for the second component of color
  • c3 storage for the third component of color

Return Value

  • always returns bool true

bool MColor:: get ( MColor::MColorType colorModel, float& c1, float& c2, float& c3, float& alpha) const

Description

Retrieves the values of 4 components of the color using the specified color model.

Arguments

  • colorModel the color model
  • c1 storage for the first component of color
  • c2 storage for the second component of color
  • c3 storage for the third component of color
  • alpha storage for the alpha component of color

Return Value

  • always returns bool true

bool MColor:: set ( MColor::MColorType colorModel, float c1, float c2, float c3, float alpha )

Description

Sets the values of the color components using the specified color model.

Arguments

  • colorModel the color model
  • c1 first component of color
  • c2 second component of color
  • c3 third component of color
  • alpha alpha component of color

Return Value

  • always returns bool true

std::ostream& operator<< ( std::ostream& os, const MColor & c )

Description

Print the contents of the given MColor on the given ostream. The format used is [r, g, b, a].

Arguments

  • s the ostream to print to
  • str the MColor whose value is to be printed

Return Value

  • the ostream reference, s, provided as the first parameter.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright