| 1 |
#ifndef _CCOLOR_ |
| 2 |
#define _CCOLOR_ |
| 3 |
|
| 4 |
#include "SDL.h" |
| 5 |
|
| 6 |
typedef unsigned char Uint8; |
| 7 |
|
| 8 |
class CColor |
| 9 |
{ |
| 10 |
public: |
| 11 |
CColor(Uint8 r = 0, Uint8 g = 0, Uint8 b = 0, Uint8 a = 0) |
| 12 |
: r(r), g(g), b(b), a(a) |
| 13 |
{ sdlcolor = ((SDL_GetVideoSurface() != NULL) ? (SDL_MapRGB(SDL_GetVideoSurface()->format, r, g, b)) : 0); } |
| 14 |
// CColor(const CColor &c) : r(c.r), g(c.g), b(c.b) {}; unnecessary |
| 15 |
|
| 16 |
Uint8 getR() const { return r; } |
| 17 |
Uint8 getG() const { return g; } |
| 18 |
Uint8 getB() const { return b; } |
| 19 |
Uint8 getA() const { return a; } |
| 20 |
SDL_Color getSDLColor(); |
| 21 |
Uint32 getDispFormatColor(); |
| 22 |
|
| 23 |
void setR(Uint8 r); |
| 24 |
void setG(Uint8 g); |
| 25 |
void setB(Uint8 b); |
| 26 |
void setA(Uint8 a); |
| 27 |
|
| 28 |
/*const CColor &operator=(const CColor &c) |
| 29 |
{ |
| 30 |
r = c.r; |
| 31 |
g = c.g; |
| 32 |
b = c.b; |
| 33 |
|
| 34 |
return *this; |
| 35 |
}*/ |
| 36 |
|
| 37 |
private: |
| 38 |
Uint8 r; |
| 39 |
Uint8 g; |
| 40 |
Uint8 b; |
| 41 |
Uint8 a; |
| 42 |
Uint32 sdlcolor; |
| 43 |
}; |
| 44 |
|
| 45 |
extern CColor COLOR_BLACK; |
| 46 |
extern CColor COLOR_WHITE; |
| 47 |
extern CColor COLOR_TRANS; |
| 48 |
extern CColor COLOR_RED; |
| 49 |
extern CColor COLOR_GREEN; |
| 50 |
extern CColor COLOR_BLUE; |
| 51 |
|
| 52 |
#endif |