All the places that colors turn up in MAXScript (such as wireColor, light color, etc.) are represented by instances of the Color class. You can also use Point3 values as color specifiers.
Literals
red
green
blue
white
black
orange
yellow
brown
gray
predefined MAXScript globals
Constructors
color <r> <g> <b> [ <a> ]
r,g,b and optional alpha are float values in the range 0 to 255
<point3> as color
interprets x as r, y as g, z as b
Properties
<color>.red or .r : Float
<color>.green or .g : Float
<color>.blue or .b : Float
<color>.alpha or .a : Float
color component properties
<color>.hue or .h : Float
<color>.saturation or .s : Float
<color>.value or .v : Float
derived properties
Operators
<color> == <color>
<color> != <color>
<color> + <color_or_number>
<color> - <color_or_number>
<color> * <color_or_number>
<color> / <color_or_number>
Channel-by-channel math operations. Numbers operate on r,g,b,a channels equally.
- <color>
unary minus
Methods
Creates a new copy of the color value. For example:
newClr = copy oldClr
The new value contains a copy of the input color value, and is independent of the input color value.
random <from_color> <to_color>
Returns a random color between the given colors. The alpha component of the result will always be 255.
Composites color1 over color2 through color1's alpha. This function is equivalent to:
color1 + color2*((255. - color1.alpha)/255.)
-- 3D Noise Functions
turbulence <color> <frequency_float>
fractalNoise <color> <H_float> <lacunarity_float> <octaves_float>
See Point3 Values for a description of the noise functions.
Notes
The component values of a Color value (r, g, b, and a) are normally in the range 0.0 to 255.0. However values outside this range are permissible. When color values outside the normal range are used in 3ds max, 3ds max clamps the values to the range of 0.0 to 255.0.
Examples
The following script shows the use of various literals, constructors, properties, operators, and methods of the Color class.
Script:
-- color test bed
magenta=color 255 255 0 255 -- create colors using constructors
aqua = [0, 255, 255] as color
aqua.v /= 2. -- reduce "strength" of aqua color
aqua
aqua.alpha=128 -- set aqua to 50% opacity
aqua
lightGray=white/4 -- create light gray color by dividing
-- each component of white by 4
composite aqua lightGray -- composite light gray over aqua
random black white -- generate a random color
Output:
(color 255 255 0) -- result of line 2. Note that if
-- alpha=255 it is not displayed
(color 0 255 255) -- result of line 3
127.5 -- result of line 4 - value property of aqua
(color 0 127.5 127.5) -- result of line 5 - color of aqua
128 -- result of line 6 - alpha property of aqua
(color 0 127.5 127.5,128) -- result of line 7 - color of aqua
(color 63.75 63.75 63.75) -- result of line 8 - each component divided by 4
(color 31.75 159.25 159.25 159.75) -- result of line 10
(color 170.944 109.543 74.1957) -- result of line 11