3ds Max C++ API Reference
Loading...
Searching...
No Matches
AColor Class Reference

#include <acolor.h>

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 (uint32_t 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 ()
 
uint32_t 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.
 
float g = 0.f
 
float b = 0.f
 
float a = 1.f
 

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.
54 {
55 r = R;
56 g = G;
57 b = B;
58 a = A;
59 }
float r
These values are in the range 0.0 to 1.0.
Definition: acolor.h:36
float a
Definition: acolor.h:39
float b
Definition: acolor.h:38
float g
Definition: acolor.h:37

◆ 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).
63 {
64 r = (float)R;
65 g = (float)G;
66 b = (float)B;
67 a = (float)A;
68 }

◆ 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).
72 {
73 r = (float)R;
74 g = (float)G;
75 b = (float)B;
76 a = (float)A;
77 }

◆ 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.
81 {
82 r = c.r;
83 g = c.g;
84 b = c.b;
85 a = alph;
86 }
float r
These values are in the range 0.0 to 1.0.
Definition: color.h:78
float b
These values are in the range 0.0 to 1.0.
Definition: color.h:82
float g
These values are in the range 0.0 to 1.0.
Definition: color.h:80

◆ AColor() [8/15]

AColor ( uint32_t  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
91 {
92 r = p.x;
93 g = p.y;
94 b = p.z;
95 a = p.w;
96 }
float w
Definition: point4.h:46
float y
Definition: point4.h:44
float x
Definition: point4.h:43
float z
Definition: point4.h:45

◆ 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].
102 {
103 r = af[0];
104 g = af[1];
105 b = af[2];
106 a = af[3];
107 }

◆ 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.
113 {
114 r = float(c.r) / 255.0f;
115 g = float(c.g) / 255.0f;
116 b = float(c.b) / 255.0f;
117 a = 1.0f;
118 }
uint8_t g
Definition: maxcolors.h:71
uint8_t b
Definition: maxcolors.h:71
uint8_t r
Definition: maxcolors.h:71

◆ 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.
124 {
125 r = float(c.r) / 255.0f;
126 g = float(c.g) / 255.0f;
127 b = float(c.b) / 255.0f;
128 a = float(c.a) / 255.0f;
129 }
uint8_t g
Definition: maxcolors.h:85
uint8_t b
Definition: maxcolors.h:85
uint8_t r
Definition: maxcolors.h:85
uint8_t a
Definition: maxcolors.h:85

◆ 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.
135 {
136 r = float(c.r) / 65535.0f;
137 g = float(c.g) / 65535.0f;
138 b = float(c.b) / 65535.0f;
139 a = 1.0f;
140 }
uint16_t b
Definition: maxcolors.h:98
uint16_t r
Definition: maxcolors.h:98
uint16_t g
Definition: maxcolors.h:98

◆ 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.
146 {
147 r = float(c.r) / 65535.0f;
148 g = float(c.g) / 65535.0f;
149 b = float(c.b) / 65535.0f;
150 a = float(c.a) / 65535.0f;
151 }
uint16_t b
Definition: maxcolors.h:112
uint16_t a
Definition: maxcolors.h:112
uint16_t r
Definition: maxcolors.h:112
uint16_t g
Definition: maxcolors.h:112

◆ 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.
158 {
159 r = c.r;
160 g = c.g;
161 b = c.b;
162 a = c.a;
163 }
float r
Storage for the floating point color information.
Definition: maxcolors.h:128
float a
Definition: maxcolors.h:128
float b
Definition: maxcolors.h:128
float g
Definition: maxcolors.h:128

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
167 {
168 r = g = b = 0.0f;
169 a = 1.0f;
170 }

◆ White()

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

◆ 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.
192 {
193 return (&r)[i];
194 }

◆ 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.
202 {
203 return (&r)[i];
204 }

◆ operator float *()

operator float * ( )
inline
Remarks
Conversion function.

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

◆ operator const float *()

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

◆ operator BMM_Color_24()

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

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

◆ operator BMM_Color_32()

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

◆ operator BMM_Color_48()

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

◆ operator BMM_Color_64()

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

◆ operator BMM_Color_fl()

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

◆ toRGB()

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

◆ operator Point4()

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

◆ 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)); }
292 {
293 return (AColor(-r, -g, -b, -a));
294 }
AColor()=default

◆ operator+() [1/2]

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

◆ operator-=()

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

◆ operator+=()

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

◆ 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.
393{
394 r *= f;
395 g *= f;
396 b *= f;
397 a *= f;
398 return *this;
399}

◆ operator/=()

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

◆ 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.
411{
412 r *= c.r;
413 g *= c.g;
414 b *= c.b;
415 a *= c.a;
416 return *this;
417}

◆ operator==()

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

◆ 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.
329 {
330 return ((p.r != r) || (p.g != g) || (p.b != b) || (p.a != a));
331 }

◆ 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.
420{
421 return (AColor(r - c.r, g - c.g, b - c.b, a - c.a));
422}

◆ 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.
425{
426 return (AColor(r + c.r, g + c.g, b + c.b, a + c.a));
427}

◆ 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.
430{
431 return AColor(r / c.r, g / c.g, b / c.b, a / c.a);
432}

◆ 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.
435{
436 return AColor(r * c.r, g * c.g, b * c.b, a * c.a);
437}

◆ 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.
440{
441 return AColor(g * c.b - b * c.g, b * c.r - r * c.b, r * c.g - g * c.r, c.a);
442}

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