OpenMaya.MColor Class Reference
Manipulate color data.
Constructors
Signature Parameters Description
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
Operation Result
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.
OpenMaya.MColor.__init__
(
)
x.__init__(...) initializes x; see help(type(x)) for signature
OpenMaya.MColor.__add__
(
)
OpenMaya.MColor.__delitem__
(
)
x.__delitem__(y) <==> del x[y]
OpenMaya.MColor.__div__
(
)
OpenMaya.MColor.__eq__
(
)
OpenMaya.MColor.__ge__
(
)
OpenMaya.MColor.__getitem__
(
)
x.__getitem__(y) <==> x[y]
OpenMaya.MColor.__gt__
(
)
OpenMaya.MColor.__iadd__
(
)
OpenMaya.MColor.__idiv__
(
)
OpenMaya.MColor.__imul__
(
)
OpenMaya.MColor.__le__
(
)
OpenMaya.MColor.__len__
(
)
OpenMaya.MColor.__lt__
(
)
OpenMaya.MColor.__mul__
(
)
OpenMaya.MColor.__ne__
(
)
OpenMaya.MColor.__radd__
(
)
OpenMaya.MColor.__rdiv__
(
)
OpenMaya.MColor.__repr__
(
)
x.__repr__() <==> repr(x)
OpenMaya.MColor.__rmul__
(
)
OpenMaya.MColor.__setitem__
(
)
x.__setitem__(i, y) <==> x[i]=y
OpenMaya.MColor.__str__
(
)
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.
OpenMaya.MColor.kByte = 1
static
Name: kByte
Type: Int
Description: Component values range from 0 to 255.
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.
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.
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.
alpha component
Name: a
Type: Float
Access: RW
Description: Alpha component.
blue component
Name: b
Type: Float
Access: RW
Description: Blue component.
green component
Name: g
Type: Float
Access: RW
Description: Green component.
red component
Name: r
Type: Float
Access: RW
Description: Red component.