mx::Color Class Reference

List of all members.

Public Member Functions

 Color ()
 Color (unsigned char r, unsigned char g, unsigned char b)
 Color (const unsigned int value)
 Color (const Color &c)
 Color (const __Color &c)
 Color (const SDL_Color &c)
Coloroperator= (const Color &c)
Coloroperator= (const unsigned int long_x)
Coloroperator= (const SDL_Color &c)
const unsigned int toInteger () const
const SDL_Color toSDL_Color () const

Static Public Member Functions

static unsigned int mapRGB (mx::mxSurface &surface, unsigned char r, unsigned char g, unsigned char b)
static unsigned int mapRGB (mx::mxSurface &surface, const __Color &c)
static unsigned int mapRGB (mx::mxSurface &surface, const Color &c)
static unsigned int mapRGB (SDL_Surface *surface, const Color &c)

Public Attributes

__Color color


Detailed Description

, encapsulate RGB colors into a easy to use Object

Definition at line 63 of file mx_types.h.


Constructor & Destructor Documentation

mx::Color::Color (  ) 

Default Constructor

Definition at line 26 of file mx_types.cpp.

References color, and mx::__Color::value.

00027         {
00028 
00029                 color.value = 0;
00030         }

mx::Color::Color ( unsigned char  r,
unsigned char  g,
unsigned char  b 
)

Constructor to init Color object

Parameters:
r Red Value
g Green Value
b Blue Value

Definition at line 37 of file mx_types.cpp.

References color, and mx::__Color::colors.

00038         {
00039 
00040                 color.colors[0] = r, color.colors[1] = g, color.colors[2] = b;
00041         }

mx::Color::Color ( const unsigned int  value  ) 

Constructor to init Color object

Parameters:
value 32bit unsigned integer value

Definition at line 44 of file mx_types.cpp.

References color, and mx::__Color::value.

00045         {
00046                 color.value = value;
00047         }

mx::Color::Color ( const Color c  ) 

Copy Constructor

Parameters:
c Color value to set this object to

Definition at line 50 of file mx_types.cpp.

References color.

00051         {
00052                 color = c.color;
00053         }

mx::Color::Color ( const __Color c  ) 

Constructor

Parameters:
c of type __Color sets this color to

Definition at line 32 of file mx_types.cpp.

References color.

00033         {
00034                 color = c;
00035         }

mx::Color::Color ( const SDL_Color &  c  ) 

Construct to take type SDL_Color

Parameters:
c of type SDL_Color

Definition at line 55 of file mx_types.cpp.

References color, and mx::__Color::colors.

00056         {
00057 
00058                 color.colors[0] = c.r;
00059                 color.colors[1] = c.g;
00060                 color.colors[2] = c.b;
00061 
00062         }


Member Function Documentation

static unsigned int mx::Color::mapRGB ( SDL_Surface *  surface,
const Color c 
) [inline, static]

mapRGB map a color from a Color object by a SDL_Surface's pixel format

Parameters:
surface a SDL_Surface from which to obtain the SDL_Surface 's pixel format
c the color from which to obtain the RGB values from
Returns:
the mapped 32bit rgb value

Definition at line 154 of file mx_types.h.

References color, and mx::__Color::colors.

00154                                                                                   {
00155                         return SDL_MapRGB(surface->format, c.color.colors[0],  c.color.colors[1],    c.color.colors[2]);
00156                 }

static unsigned int mx::Color::mapRGB ( mx::mxSurface surface,
const Color c 
) [inline, static]

mapRGB map a color from a Color object by a mxSurface's pixel format

Parameters:
surface surface from whiich to obtain the pixel format
c color object from which to map the return value
Returns:
32bit unsigned integer mapped by the surface's pixel format.

Definition at line 144 of file mx_types.h.

References color, and mapRGB().

00145                 {
00146                         return mapRGB(surface, c.color);
00147                 }

static unsigned int mx::Color::mapRGB ( mx::mxSurface surface,
const __Color c 
) [inline, static]

mapRGB map a color value from a __Color union by a mxSurface's pixel format

Parameters:
surface surface from which to obtain the pixelformat
c __Color value to map
Returns:
mapped unsigned integer

Definition at line 135 of file mx_types.h.

References mx::__Color::colors, and mx::mxSurface::getSurface().

00136                 {
00137                         return SDL_MapRGB(surface.getSurface()->format, c.colors[0], c.colors[1], c.colors[2]);
00138                 }

static unsigned int mx::Color::mapRGB ( mx::mxSurface surface,
unsigned char  r,
unsigned char  g,
unsigned char  b 
) [inline, static]

mapRGB map a color value to a format of a specific surface

Parameters:
surface surface for pixel format
r for red value
g for green value
b for blue value
Returns:
unsigned integer for the value mapped

Definition at line 126 of file mx_types.h.

References mx::mxSurface::getSurface().

Referenced by mapRGB(), and mx::mxRegularFont::printText().

00127                 {
00128                         return SDL_MapRGB(surface.getSurface()->format, r, g, b);
00129                 }

Color & mx::Color::operator= ( const SDL_Color &  c  ) 

overloaded assignment operator to this this object's Color value to

Parameters:
c SDL_Color value to set this Color objects value to
Returns:
this object

Definition at line 77 of file mx_types.cpp.

References color, and mx::__Color::colors.

00078         {
00079 
00080                 color.colors[0] = c.r;
00081                 color.colors[1] = c.g;
00082                 color.colors[2] = c.b;
00083                 return *this;
00084         }

Color & mx::Color::operator= ( const unsigned int  long_x  ) 

overloaded assignment operator set this object's Color value to

Parameters:
long_x value to set color to
Returns:
this object

Definition at line 70 of file mx_types.cpp.

References color, and mx::__Color::value.

00071         {
00072 
00073                 color.value = long_x;
00074                 return *this;
00075 
00076         }

Color & mx::Color::operator= ( const Color c  ) 

overloaded assignment operator set this object to Color type

Parameters:
c set this to object of type Color
Returns:
this object

Definition at line 64 of file mx_types.cpp.

References color.

00065         {
00066                 color = c.color;
00067                 return *this;
00068         }

const unsigned int mx::Color::toInteger (  )  const

turns the value of the internal color union to a unsigned integer

Returns:
32bit RGBA value

Definition at line 94 of file mx_types.cpp.

References color, and mx::__Color::value.

00095         {
00096                 return color.value;
00097         }

const SDL_Color mx::Color::toSDL_Color (  )  const

turns the value of the internal color union to a SDL_Color

Returns:
SDL_Color structure

Definition at line 86 of file mx_types.cpp.

References color, and mx::__Color::colors.

00087         {
00088 
00089                 SDL_Color col = { color.colors[0], color.colors[1], color.colors[2], 0 };
00090                 return col;
00091 
00092         }


Member Data Documentation

Color union

Definition at line 118 of file mx_types.h.

Referenced by Color(), mapRGB(), operator=(), toInteger(), and toSDL_Color().


The documentation for this class was generated from the following files:

Generated on Wed Jun 10 14:52:02 2009 for libmx by  doxygen 1.5.8