MColor

Constants

NameTypeDescription
kOpaqueBlack MColor Opaque black color.
Color Models
kRGB Int Red, green, blue, alpha.
kHSV Int Hue, saturation, value, alpha.
kCMY Int Cyan, magenta, yellow, alpha.
kCMYK Int Cyan, magenta, yellow, black.
Component Types
kFloat Int Component values range from 0.0 to 1.0.
kByte Int Component values range from 0 to 255.
kShort Int Component values range from 0 to 65535.

Static Methods

None.

Static Attributes

None.

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).

Object Methods

SignatureParametersReturnsDescription
getColor(model=kRGB) model - color model [Float, Float, Float, Float] Returns a list containing the color's components, in the specified color model.
setColor(components, model=kRGB, dataType=kFloat) components - sequence of 3 or 4 numeric values
model - Color Model constant
dataType - Component Type constant
Returns a new reference to self. Sets the color. The interpretation of the parameters is the same as for the MColor(components,model,dataType) constructor.

Object Attributes

NameTypeAccessDescription
r Float RW Red component.
g Float RW Green component.
b Float RW Blue component.
a Float RW Alpha component.

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.

© 2011 Autodesk, Inc. All rights reserved.