3ds Max C++ API Reference
AColor Class Reference

#include <acolor.h>

+ Inheritance diagram for AColor:

Public Member Functions

 AColor ()=default
 
 AColor (const AColor &)=default
 
 AColor (AColor &&)=default
 
AColoroperator= (const AColor &)=default
 
AColoroperator= (AColor &&)=default
 
 AColor (float R, float G, float B, float A=1.0f)
 
 AColor (double R, double G, double B, double A=1.0)
 
 AColor (int R, int G, int B, int A=0)
 
 AColor (const Color &c, float alph=1.0f)
 
 AColor (DWORD rgb, float alph=1.0f)
 
 AColor (const Point4 &p)
 
 AColor (float af[4])
 
 AColor (const BMM_Color_24 &c)
 
 AColor (const BMM_Color_32 &c)
 
 AColor (const BMM_Color_48 &c)
 
 AColor (const BMM_Color_64 &c)
 
 AColor (const BMM_Color_fl &c)
 
void Black ()
 
void White ()
 
void ClampMax ()
 
void ClampMin ()
 
void ClampMinMax ()
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
 operator float * ()
 
 operator const float * () const
 
 operator BMM_Color_24 ()
 
 operator BMM_Color_32 ()
 
 operator BMM_Color_48 ()
 
 operator BMM_Color_64 ()
 
 operator BMM_Color_fl ()
 
DWORD toRGB ()
 
 operator Point4 ()
 
AColor operator- () const
 
AColor operator+ () const
 
AColoroperator-= (const AColor &)
 
AColoroperator+= (const AColor &)
 
AColoroperator*= (float)
 
AColoroperator/= (float)
 
AColoroperator*= (const AColor &)
 
int operator== (const AColor &p) const
 
int operator!= (const AColor &p) const
 
AColor operator- (const AColor &) const
 
AColor operator+ (const AColor &) const
 
AColor operator/ (const AColor &) const
 
AColor operator* (const AColor &) const
 
AColor operator^ (const AColor &) const
 

Public Attributes

float r = 0.f
 These values are in the range 0.0 to 1.0. More...
 
float g = 0.f
 
float b = 0.f
 
float a = 1.f
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class Color, Structure BMM_Color_24, Structure BMM_Color_32, Structure BMM_Color_48, Structure BMM_Color_64, Structure BMM_Color_fl, Structure RealPixel.

Description:
This class represents color as four floating point values: r, g, b, and an alpha channel a. Also note the following typedef: typedef AColor RGBA;

Constructor & Destructor Documentation

◆ AColor() [1/15]

AColor ( )
default
Remarks
Constructor. The resulting object should be initialized with one of the initialization methods.

◆ AColor() [2/15]

AColor ( const AColor )
default

◆ AColor() [3/15]

AColor ( AColor &&  )
default

◆ AColor() [4/15]

AColor ( float  R,
float  G,
float  B,
float  A = 1.0f 
)
inline
Remarks
Constructor. Initializes the AColor to the RGBA color values passed.
55  {
56  r = R;
57  g = G;
58  b = B;
59  a = A;
60  }
float r
These values are in the range 0.0 to 1.0.
Definition: acolor.h:37
float a
Definition: acolor.h:40
float b
Definition: acolor.h:39
float g
Definition: acolor.h:38

◆ AColor() [5/15]

AColor ( double  R,
double  G,
double  B,
double  A = 1.0 
)
inline
Remarks
Constructor. Initializes the AColor to the RGBA color values passed (cast to float).
64  {
65  r = (float)R;
66  g = (float)G;
67  b = (float)B;
68  a = (float)A;
69  }

◆ AColor() [6/15]

AColor ( int  R,
int  G,
int  B,
int  A = 0 
)
inline
Remarks
Constructor. Initializes the AColor to the RGBA color values passed (cast to float).
73  {
74  r = (float)R;
75  g = (float)G;
76  b = (float)B;
77  a = (float)A;
78  }

◆ AColor() [7/15]

AColor ( const Color c,
float  alph = 1.0f 
)
inline
Remarks
Constructor. Initializes the AColor to the Color passed, optionally specifying an alpha value.
82  {
83  r = c.r;
84  g = c.g;
85  b = c.b;
86  a = alph;
87  }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:79
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:83
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:81

◆ AColor() [8/15]

AColor ( DWORD  rgb,
float  alph = 1.0f 
)
explicit
Remarks
Constructor. Initializes the color to the Windows RGB value, optionally specifying an alpha value.

◆ AColor() [9/15]

AColor ( const Point4 p)
inline
92  {
93  r = p.x;
94  g = p.y;
95  b = p.z;
96  a = p.w;
97  }
float w
Definition: point4.h:50
float y
Definition: point4.h:48
float x
Definition: point4.h:47
float z
Definition: point4.h:49

◆ AColor() [10/15]

AColor ( float  af[4])
inlineexplicit
Remarks
Constructor. Initializes the color to the value passed.
Parameters:
float af[3]

Specifies the color. r=af[0], g=af[1], b=af[2], a=af[3].
103  {
104  r = af[0];
105  g = af[1];
106  b = af[2];
107  a = af[3];
108  }

◆ AColor() [11/15]

AColor ( const BMM_Color_24 c)
inline
Remarks
Constructor. Initializes this AColor from the 24 bit color value passed.
Parameters:
const BMM_Color_24& c

The 24 bit color to initialize from.
114  {
115  r = float(c.r) / 255.0f;
116  g = float(c.g) / 255.0f;
117  b = float(c.b) / 255.0f;
118  a = 1.0f;
119  }
uint8_t g
Definition: maxtypes.h:67
uint8_t b
Definition: maxtypes.h:67
uint8_t r
Definition: maxtypes.h:67

◆ AColor() [12/15]

AColor ( const BMM_Color_32 c)
inline
Remarks
Constructor. Initializes this AColor from the 32 bit color value passed.
Parameters:
const BMM_Color_32& c

The 32 bit color to initialize from.
125  {
126  r = float(c.r) / 255.0f;
127  g = float(c.g) / 255.0f;
128  b = float(c.b) / 255.0f;
129  a = float(c.a) / 255.0f;
130  }
uint8_t g
Definition: maxtypes.h:75
uint8_t b
Definition: maxtypes.h:75
uint8_t r
Definition: maxtypes.h:75
uint8_t a
Definition: maxtypes.h:75

◆ AColor() [13/15]

AColor ( const BMM_Color_48 c)
inline
Remarks
Constructor. Initializes this AColor from the 48 bit color value passed.
Parameters:
const BMM_Color_48& c

The 48 bit color to initialize from.
136  {
137  r = float(c.r) / 65535.0f;
138  g = float(c.g) / 65535.0f;
139  b = float(c.b) / 65535.0f;
140  a = 1.0f;
141  }
uint16_t b
Definition: maxtypes.h:83
uint16_t r
Definition: maxtypes.h:83
uint16_t g
Definition: maxtypes.h:83

◆ AColor() [14/15]

AColor ( const BMM_Color_64 c)
inline
Remarks
Constructor. Initializes this AColor from the 64 bit color value passed.
Parameters:
const BMM_Color_64& c

The 64 bit color to initialize from.
147  {
148  r = float(c.r) / 65535.0f;
149  g = float(c.g) / 65535.0f;
150  b = float(c.b) / 65535.0f;
151  a = float(c.a) / 65535.0f;
152  }
uint16_t b
Definition: maxtypes.h:91
uint16_t a
Definition: maxtypes.h:91
uint16_t r
Definition: maxtypes.h:91
uint16_t g
Definition: maxtypes.h:91

◆ AColor() [15/15]

AColor ( const BMM_Color_fl c)
inline
Remarks
Constructor. Initializes this AColor from the floating point color passed.
Parameters:
const BMM_Color_fl& c

The floating point color to initialize from. No conversion or scaling is done.
159  {
160  r = c.r;
161  g = c.g;
162  b = c.b;
163  a = c.a;
164  }
float r
Storage for the floating point color information.
Definition: maxtypes.h:101
float a
Definition: maxtypes.h:101
float b
Definition: maxtypes.h:101
float g
Definition: maxtypes.h:101

Member Function Documentation

◆ operator=() [1/2]

AColor& operator= ( const AColor )
default

◆ operator=() [2/2]

AColor& operator= ( AColor &&  )
default

◆ Black()

void Black ( )
inline
Remarks
Sets this AColor to black. r = g = b = 0.0f; a= 1.0f
168  {
169  r = g = b = 0.0f;
170  a = 1.0f;
171  }

◆ White()

void White ( )
inline
Remarks
Sets the AColor to white. r = g = b = a = 1.0f
174  {
175  r = g = b = 1.0f;
176  a = 1.0f;
177  }

◆ ClampMax()

void ClampMax ( )
Remarks
Makes all the components of the AColor <= 1.0

◆ ClampMin()

void ClampMin ( )
Remarks
Makes all the components of the AColor >= 0.0

◆ ClampMinMax()

void ClampMinMax ( )
Remarks
Makes all the components of the AColor fall in the range 0.0 to 1.0.

◆ operator[]() [1/2]

float& operator[] ( int  i)
inline
Remarks
Access operators.
Parameters:
int i

The index of the component to return.
Returns
0=r, 1=g, 2=b, 3=a.
193  {
194  return (&r)[i];
195  }

◆ operator[]() [2/2]

const float& operator[] ( int  i) const
inline
Remarks
Access operators.
Parameters:
int i

The index of the component to return.
Returns
0=r, 1=g, 2=b, 3=a.
203  {
204  return (&r)[i];
205  }

◆ operator float *()

operator float * ( )
inline
Remarks
Conversion function.

Returns a pointer to the AColor.
211  {
212  return (&r);
213  }

◆ operator const float *()

operator const float * ( ) const
inline
215  {
216  return (&r);
217  }

◆ operator BMM_Color_24()

operator BMM_Color_24 ( )
inline
Remarks
Converts this AColor to the BMM_Color_24 format.

223  {
224  BMM_Color_24 c;
225  c.r = (BYTE) int(r * 255.0f);
226  c.g = (BYTE) int(g * 255.0f);
227  c.b = (BYTE) int(b * 255.0f);
228  return c;
229  }
24 bit color: 8 bits each for Red, Green, and Blue.
Definition: maxtypes.h:65

◆ operator BMM_Color_32()

operator BMM_Color_32 ( )
inline
Remarks
Converts this AColor to the BMM_Color_32 format.
232  {
233  BMM_Color_32 c;
234  c.r = (BYTE) int(r * 255.0f);
235  c.g = (BYTE) int(g * 255.0f);
236  c.b = (BYTE) int(b * 255.0f);
237  c.a = (BYTE) int(a * 255.0f);
238  return c;
239  }
32 bit color: 8 bits each for Red, Green, Blue, and Alpha.
Definition: maxtypes.h:73

◆ operator BMM_Color_48()

operator BMM_Color_48 ( )
inline
Remarks
Converts this AColor to the BMM_Color_48 format.
242  {
243  BMM_Color_48 c;
244  c.r = (WORD) int(r * 65535.0f);
245  c.g = (WORD) int(g * 65535.0f);
246  c.b = (WORD) int(b * 65535.0f);
247  return c;
248  }
48 bit color: 16 bits each for Red, Green, and Blue.
Definition: maxtypes.h:81

◆ operator BMM_Color_64()

operator BMM_Color_64 ( )
inline
Remarks
Converts this AColor to the BMM_Color_64 format.
251  {
252  BMM_Color_64 c;
253  c.r = (WORD) int(r * 65535.0f);
254  c.g = (WORD) int(g * 65535.0f);
255  c.b = (WORD) int(b * 65535.0f);
256  c.a = (WORD) int(a * 65535.0f);
257  return c;
258  }
64 bit color: 16 bits each for Red, Green, Blue, and Alpha.
Definition: maxtypes.h:89

◆ operator BMM_Color_fl()

operator BMM_Color_fl ( )
inline
Remarks
Converts this AColor to the BMM_Color_fl format.
261  {
262  BMM_Color_fl c;
263  c.r = r;
264  c.g = g;
265  c.b = b;
266  c.a = a;
267  return c;
268  }
High Dynamic Range bitmaps make use of this class to store color information using floating point val...
Definition: maxtypes.h:97

◆ toRGB()

DWORD toRGB ( )
inline
Remarks
Convert the AColor to a Windows RGB color. See COLORREF.
Returns
A Windows RGB color.
276  {
277  return RGB(FLto255(r), FLto255(g), FLto255(b));
278  };
#define FLto255(x)
Definition: color.h:24

◆ operator Point4()

operator Point4 ( )
inline
Remarks
Convert the AColor to a Point4.
Returns
A Point4. x=r, y=g, z=b, w=a.
284  {
285  return Point4(r, g, b, a);
286  }
Definition: point4.h:43

◆ operator-() [1/2]

AColor operator- ( ) const
inline
Remarks
Unary - operator.
Returns
The Color with the components negated, i.e.

{ return(AColor(-r,-g,-b, -a)); }
293  {
294  return (AColor(-r, -g, -b, -a));
295  }
AColor()=default

◆ operator+() [1/2]

AColor operator+ ( ) const
inline
Remarks
Unary + operator.
Returns
The AColor itself.
299  {
300  return *this;
301  }

◆ operator-=()

AColor & operator-= ( const AColor c)
inline
Remarks
Subtracts an AColor from this AColor.
Returns
A Color that is the difference between two Colors.
376 {
377  r -= c.r;
378  g -= c.g;
379  b -= c.b;
380  a -= c.a;
381  return *this;
382 }

◆ operator+=()

AColor & operator+= ( const AColor c)
inline
Remarks
Adds an AColor to this AColor.
Returns
An AColor that is the sum of two AColors.
385 {
386  r += c.r;
387  g += c.g;
388  b += c.b;
389  a += c.a;
390  return *this;
391 }

◆ operator*=() [1/2]

AColor & operator*= ( float  f)
inline
Remarks
Multiplies the components of this AColor by a float.
Returns
An AColor multiplied by a float.
394 {
395  r *= f;
396  g *= f;
397  b *= f;
398  a *= f;
399  return *this;
400 }

◆ operator/=()

AColor & operator/= ( float  f)
inline
Remarks
Divides the components of this AColor by a float.
Returns
An AColor divided by a float.
403 {
404  r /= f;
405  g /= f;
406  b /= f;
407  a /= f;
408  return *this;
409 }

◆ operator*=() [2/2]

AColor & operator*= ( const AColor c)
inline
Remarks
Performs element-by-element multiplying between two AColors.
Returns
This AColor element-by-element multiplied by another AColor.
412 {
413  r *= c.r;
414  g *= c.g;
415  b *= c.b;
416  a *= c.a;
417  return *this;
418 }

◆ operator==()

int operator== ( const AColor p) const
inline
Remarks
Test for equality between two AColors.
Returns
Nonzero if the AColors are equal; otherwise 0.
324  {
325  return ((p.r == r) && (p.g == g) && (p.b == b) && (p.a == a));
326  }

◆ operator!=()

int operator!= ( const AColor p) const
inline
Remarks
Tests for inequality between two AColors.
Returns
Nonzero if the AColors are not equal; otherwise 0.
330  {
331  return ((p.r != r) || (p.g != g) || (p.b != b) || (p.a != a));
332  }

◆ operator-() [2/2]

AColor operator- ( const AColor c) const
inline
Remarks
Subtracts an AColor from an AColor.
Returns
An AColor that is the difference between two AColors.
421 {
422  return (AColor(r - c.r, g - c.g, b - c.b, a - c.a));
423 }

◆ operator+() [2/2]

AColor operator+ ( const AColor c) const
inline
Remarks
Adds an AColor to an AColor.
Returns
An AColor that is the difference between two AColors.
426 {
427  return (AColor(r + c.r, g + c.g, b + c.b, a + c.a));
428 }

◆ operator/()

AColor operator/ ( const AColor c) const
inline
Remarks
Divides an AColor by an AColor.
Returns
An AColor divided by an AColor. r/r, g/g, b/b, a/a.
431 {
432  return AColor(r / c.r, g / c.g, b / c.b, a / c.a);
433 }

◆ operator*()

AColor operator* ( const AColor c) const
inline
Remarks
Multiplies an AColor by an AColor.
Returns
An AColor multiplied by an AColor. r*r, g*g, b*b, a*a.
436 {
437  return AColor(r * c.r, g * c.g, b * c.b, a * c.a);
438 }

◆ operator^()

AColor operator^ ( const AColor c) const
inline
Remarks
Cross product of two AColors. The alpha component is not affected by the cross product.
Returns
An AColor that is the cross product of two AColors.
441 {
442  return AColor(g * c.b - b * c.g, b * c.r - r * c.b, r * c.g - g * c.r, c.a);
443 }

Member Data Documentation

◆ r

float r = 0.f

These values are in the range 0.0 to 1.0.

◆ g

float g = 0.f

◆ b

float b = 0.f

◆ a

float a = 1.f