Python API 2.0 Reference
OpenMaya.MColor Class Reference
+ Inheritance diagram for OpenMaya.MColor:

Public Member Functions

def __add__ ()
 
def __delitem__ ()
 
def __eq__ ()
 
def __ge__ ()
 
def __getitem__ ()
 
def __gt__ ()
 
def __iadd__ ()
 
def __imul__ ()
 
def __init__ ()
 
def __itruediv__ ()
 
def __le__ ()
 
def __len__ ()
 
def __lt__ ()
 
def __mul__ ()
 
def __ne__ ()
 
def __radd__ ()
 
def __repr__ ()
 
def __rmul__ ()
 
def __rtruediv__ ()
 
def __setitem__ ()
 
def __str__ ()
 
def __truediv__ ()
 
def getColor ()
 
def setColor ()
 

Static Public Member Functions

def __new__ ()
 

Static Public Attributes

tuple kOpaqueBlack = maya.api.OpenMaya.MColor((0, 0, 0, 1))
 
Component Types
int kByte = 1
 
int kFloat = 0
 
int kShort = 2
 
Color Models
int kCMY = 2
 
int kCMYK = 3
 
int kHSV = 1
 
int kRGB = 0
 

Properties

 a = property(...)
 
 b = property(...)
 
 g = property(...)
 
 r = property(...)
 

Detailed Description

Manipulate color data.

Constructors

SignatureParametersDescription
MColor()  

Default constructor. Returns a new MColor with red, blue and green set to 0.0 and alpha set to 1.0.

MColor(src) src - MColor

Copy constructor. Returns a new MColor with the same color components as src.

MColor(components, model=kRGB, dataType=kFloat) components - sequence of 3 or 4 numeric values
model - Color Model constant
dataType - Component Type constant

Returns a new MColor using the specified color components. The interpretation of the components depends upon the color model specified. For example, if model is kHSV then the values of components are interpreted as hue, saturation, value and alpha, respectively. The normal range of values for each component is determined by the specified component dataType, although values may exceed that range. If only 3 component values are provided then the fourth will be set to the maximum value of the range for dataType. The resulting color is converted to the kRGB model before being stored. If dataType was other than kFloat then the components will be converted to Float by dividing by the maximum value of dataType's range. For example, if the red component was given as a value of 100 and dataType was kByte then the stored red value will be approximately 0.39215 (100 divided by 255).

Sequence Support

len() always returns 4.

Indexing and iteration treat the MColor like a list of [r, g, b, a].

All other sequence operations - concatenation, slices, etc - are unsupported.

Number Support

OperationResult
float * MColor

Returns a new MColor with given MColor's RGB values multiplied by the float. The given MColor's alpha value is passed through unchanged.

MColor * float

Returns a new MColor with given MColor's RGB values multiplied by the float. The given MColor's alpha value is passed through unchanged.

MColor * MColor

Returns a new MColor with the first MColor's RGB values multiplied by the second MColor's RGB values. The first MColor's alpha is passed through unchanged.

MColor *= float

Multiplies the given MColor's RGB values in-place by the float and returns a new reference to the given MColor. Alpha is unchanged.

MColor *= MColor

Multiplies the first MColor's RGB values by the second MColor's RGB values and returns a new reference to the first MColor. Alpha is unchanged.

MColor / float

Returns a new MColor with given MColor's RGB values divided by the float. The given MColor's alpha value is passed through unchanged.

MColor /= float

Divides the given MColor's RGB values in-place by the float and returns a new reference to the given MColor. Alpha is unchanged.

MColor + MColor

Returns a new MColor with the first MColor's RGB values added to the second MColor's RGB values. The first MColor's alpha is passed through unchanged.

MColor += MColor

Adds the second MColor's RGB values to the first MColor's RGB values and returns a new reference to the first MColor. Alpha is unchanged.

Comparison Support

== Compare to another MColor. True if all component values match.
!= Compare to another MColor. True if any of the component values don't match.

 


Constructor & Destructor Documentation

def OpenMaya.MColor.__init__ ( )
Initialize self.  See help(type(self)) for accurate signature.

Member Function Documentation

def OpenMaya.MColor.__add__ ( )
Return self+value.
def OpenMaya.MColor.__delitem__ ( )
Delete self[key].
def OpenMaya.MColor.__eq__ ( )
Return self==value.
def OpenMaya.MColor.__ge__ ( )
Return self>=value.
def OpenMaya.MColor.__getitem__ ( )
Return self[key].
def OpenMaya.MColor.__gt__ ( )
Return self>value.
def OpenMaya.MColor.__iadd__ ( )
Return self+=value.
def OpenMaya.MColor.__imul__ ( )
Return self*=value.
def OpenMaya.MColor.__itruediv__ ( )
Return self/=value.
def OpenMaya.MColor.__le__ ( )
Return self<=value.
def OpenMaya.MColor.__len__ ( )
Return len(self).
def OpenMaya.MColor.__lt__ ( )
Return self<value.
def OpenMaya.MColor.__mul__ ( )
Return self*value.
def OpenMaya.MColor.__ne__ ( )
Return self!=value.
def OpenMaya.MColor.__new__ ( )
static
Create and return a new object.  See help(type) for accurate signature.
def OpenMaya.MColor.__radd__ ( )
Return value+self.
def OpenMaya.MColor.__repr__ ( )
Return repr(self).
def OpenMaya.MColor.__rmul__ ( )
Return value*self.
def OpenMaya.MColor.__rtruediv__ ( )
Return value/self.
def OpenMaya.MColor.__setitem__ ( )
Set self[key] to value.
def OpenMaya.MColor.__str__ ( )
Return str(self).
def OpenMaya.MColor.__truediv__ ( )
Return self/value.
OpenMaya.MColor.getColor ( )
Returns a list containing the color's components, in the specified color model.
Signature: getColor(model=kRGB)
Parameters: model - color model
Returns: [Float, Float, Float, Float]
Description: Returns a list containing the color's components, in the specified color model.
OpenMaya.MColor.setColor ( )
Sets the color's components and color model.
Signature: setColor(components, model=kRGB, dataType=kFloat)
Parameters: components - sequence of 3 or 4 numeric values
model - Color Model constant
dataType - Component Type constant
Returns: Returns a new reference to self.
Description: Sets the color. The interpretation of the parameters is the same as for the MColor(components,model,dataType) constructor.

Member Data Documentation

OpenMaya.MColor.kByte = 1
static
Name: kByte
Type: Int
Description: Component values range from 0 to 255.
OpenMaya.MColor.kCMY = 2
static
Name: kCMY
Type: Int
Description: Cyan, magenta, yellow, alpha.
OpenMaya.MColor.kCMYK = 3
static
Name: kCMYK
Type: Int
Description: Cyan, magenta, yellow, black.
OpenMaya.MColor.kFloat = 0
static
Name: kFloat
Type: Int
Description: Component values range from 0.0 to 1.0.
OpenMaya.MColor.kHSV = 1
static
Name: kHSV
Type: Int
Description: Hue, saturation, value, alpha.
OpenMaya.MColor.kOpaqueBlack = maya.api.OpenMaya.MColor((0, 0, 0, 1))
static
Name: kOpaqueBlack
Type: MColor
Description: Opaque black color.
OpenMaya.MColor.kRGB = 0
static
Name: kRGB
Type: Int
Description: Red, green, blue, alpha.
OpenMaya.MColor.kShort = 2
static
Name: kShort
Type: Int
Description: Component values range from 0 to 65535.

Property Documentation

OpenMaya.MColor.a = property(...)
static
 alpha component
Name: a
Type: Float
Access: RW
Description: Alpha component.
OpenMaya.MColor.b = property(...)
static
 blue component
Name: b
Type: Float
Access: RW
Description: Blue component.
OpenMaya.MColor.g = property(...)
static
 green component
Name: g
Type: Float
Access: RW
Description: Green component.
OpenMaya.MColor.r = property(...)
static
 red component
Name: r
Type: Float
Access: RW
Description: Red component.