e2d::graphics::Color Class Reference
List of all members.
Detailed Description
A wrapper around SDL_Color, provides a representation of a color along with utility methods. Also, there are some handy color constants
|
Public Member Functions |
| Color (const char *color) |
| String constructor.
|
| Color (int red, int green, int blue) |
| Integer constructor.
|
int | GetBlueComponent () |
| Gets the blue component of this color.
|
unsigned int | GetColorAsInt () |
| Gets the color value as an integer.
|
char * | GetColorAsString () |
| Gets the color value as an hexadecimal string.
|
int | GetGreenComponent () |
| Gets the green component of this color.
|
int | GetRedComponent () |
| Gets the red component of this color.
|
SDL_Color | GetSDLColor () |
| Returns an SDL_Color struct.
|
void | SetBlueComponent (int intensity) |
| Sets the blue component of this color.
|
void | SetColor (const char *color) |
| Sets the color value.
|
void | SetColor (int red, int green, int blue) |
| Sets the color value.
|
void | SetGreenComponent (int intensity) |
| Sets the green component of this color.
|
void | SetRedComponent (int intensity) |
| Sets the red component of this color.
|
Static Public Attributes |
static Color | WHITE = Color(255, 255, 255) |
| Constant for white color.
|
static Color | BLACK = Color(0,0,0) |
| Constant for black color.
|
static Color | RED = Color(255, 0, 0) |
| Constant for red color.
|
static Color | GREEN = Color(0, 255, 0) |
| Constant for green color.
|
static Color | BLUE = Color(0, 0, 255) |
| Constant for blue color.
|
static Color | MAGENTA = Color(255, 0, 255) |
| Constant for magenta color.
|
Constructor & Destructor Documentation
e2d::graphics::Color::Color |
( |
const char * |
color |
) |
|
Constructs a color from a string RGB value.
- Parameters:
-
| color | String in the format "FFFFFF" |
e2d::graphics::Color::Color |
( |
int |
red, |
|
|
int |
green, |
|
|
int |
blue | |
|
) |
| | |
- Parameters:
-
| red | Red component of the color, must be between 0 and 255 |
| green | Green component of the color, must be between 0 and 255 |
| blue | Blue component of the color, must be between 0 and 255 |
- Exceptions:
-
Member Function Documentation
int e2d::graphics::Color::GetBlueComponent |
( |
|
) |
|
- Returns:
- an integer between 0 and 255 representing the blue component of this color
unsigned int e2d::graphics::Color::GetColorAsInt |
( |
|
) |
|
As a matter of fact, this method calls SDL_MapRGB using the framebuffer pixelformat. If video has not yet been initialized, it returns zero.
- Returns:
- an integer value for this color
char * e2d::graphics::Color::GetColorAsString |
( |
|
) |
|
Returns a string in the format "FFFFFF" containing the hexadecimal value for this color. The pointer to char it returns is allocated internally, so you must free it yourself when it is not being used anymore.
- Returns:
- a string in the format "FFFFFF"
int e2d::graphics::Color::GetGreenComponent |
( |
|
) |
|
- Returns:
- an integer between 0 and 255 representing the green component of this color
int e2d::graphics::Color::GetRedComponent |
( |
|
) |
|
- Returns:
- an integer between 0 and 255 representing the red component of this color
SDL_Color e2d::graphics::Color::GetSDLColor |
( |
|
) |
|
- Returns:
- SDL_Color representing this color (SDL_Color is part of SDL)
void e2d::graphics::Color::SetBlueComponent |
( |
int |
intensity |
) |
|
- Parameters:
-
| intensity | Blue component of the color, must be between 0 and 255 |
- Exceptions:
-
void e2d::graphics::Color::SetColor |
( |
const char * |
color |
) |
|
Sets a color value from a string RGB value.
- Parameters:
-
| color | String in the format "FFFFFF" |
void e2d::graphics::Color::SetColor |
( |
int |
red, |
|
|
int |
green, |
|
|
int |
blue | |
|
) |
| | |
- Parameters:
-
| red | Red component of the color, must be between 0 and 255 |
| green | Green component of the color, must be between 0 and 255 |
| blue | Blue component of the color, must be between 0 and 255 |
- Exceptions:
-
void e2d::graphics::Color::SetGreenComponent |
( |
int |
intensity |
) |
|
- Parameters:
-
| intensity | Green component of the color, must be between 0 and 255 |
- Exceptions:
-
void e2d::graphics::Color::SetRedComponent |
( |
int |
intensity |
) |
|
- Parameters:
-
| intensity | Red component of the color, must be between 0 and 255 |
- Exceptions:
-