#include <color.h>
Inheritance diagram for Wt::Color:
Public Types | |
Transparent = SDL_ALPHA_TRANSPARENT | |
Opaque = SDL_ALPHA_OPAQUE | |
enum | { Transparent = SDL_ALPHA_TRANSPARENT, Opaque = SDL_ALPHA_OPAQUE } |
The alpha channel values for transparent and opaque. More... | |
Public Member Functions | |
Color () | |
Color (Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha=Opaque) | |
Construct from a triple/quadruple. (R, G, B, A). | |
Color (const SDLColor &color) | |
constructor from SDLColor for implicit conversions | |
Color (const std::string &name) | |
Construct a named color (as find()). | |
Color (const char *name) | |
same thing, so compiler will autocreate temporaries from "foo" | |
operator const SDL_Color & () const | |
operator SDL_Color & () | |
int | red () const |
int | green () const |
int | blue () const |
int | alpha () const |
void | setRed (int red) |
void | setGreen (int green) |
void | setBlue (int blue) |
void | setAlpha (int alpha) |
void | setColor (int red, int green, int blue, int alpha) |
bool | equals (const SDLColor &other) const |
Compares colors (without alpha channel !). | |
bool | operator== (const SDLColor &other) const |
bool | operator!= (const SDLColor &other) const |
Inequality comparison. | |
Static Public Member Functions | |
static void | calcBlendFactors (int factor, int &new_factor, int &old_factor) |
static SDLColor | blend (const SDLColor &old_color, int old_factor, const SDLColor &new_color, int new_factor, int new_alpha_factor=Transparent, int old_alpha_factor=Opaque) |
Static Public Attributes | |
static Map | map |
Static Protected Member Functions | |
static Color | createColorFromRGBString (const std::string &rgb) |
Classes | |
class | Map |
Definition at line 31 of file color.h.
anonymous enum [inherited] |
The alpha channel values for transparent and opaque.
Definition at line 111 of file sdlcolor.h.
00111 { 00112 Transparent = SDL_ALPHA_TRANSPARENT, 00113 Opaque = SDL_ALPHA_OPAQUE 00114 };
Wt::Color::Color | ( | ) | [inline] |
Definition at line 33 of file color.h.
Referenced by createColorFromRGBString(), and Wt::Color::Map::Map().
Wt::Color::Color | ( | Uint8 | red, | |
Uint8 | green, | |||
Uint8 | blue, | |||
Uint8 | alpha = Opaque | |||
) | [inline] |
Wt::Color::Color | ( | const SDLColor & | color | ) | [inline] |
Wt::Color::Color | ( | const std::string & | name | ) |
Construct a named color (as find()).
Definition at line 542 of file color.cpp.
References createColorFromRGBString().
00542 { 00543 assert(sizeof(Color) == sizeof(SDLColor)); 00544 Map::iterator it = map.find(name); 00545 if (it != map.end()) 00546 *this = map[name]; 00547 else 00548 *this = createColorFromRGBString(name); 00549 }
Here is the call graph for this function:
Wt::Color::Color | ( | const char * | name | ) |
same thing, so compiler will autocreate temporaries from "foo"
Definition at line 551 of file color.cpp.
References createColorFromRGBString().
00551 { 00552 assert(sizeof(Color) == sizeof(SDLColor)); 00553 Map::iterator it = map.find(name); 00554 if (it != map.end()) 00555 *this = it->second; 00556 else 00557 *this = createColorFromRGBString(std::string(name)); 00558 }
Here is the call graph for this function:
int Wt::SDLColor::alpha | ( | ) | const [inline, inherited] |
Definition at line 83 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::blend(), Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend(), Wt::Painter::drawText(), Wt::SDLPixelFormat::mapToPixelValue(), Wt::operator<<(), Wt::SDLColor::SDLColor(), Wt::SDLColor::setAlpha(), and Wt::SDLColor::setColor().
00083 { 00084 return sdl_color.unused; 00085 }
static SDLColor Wt::SDLColor::blend | ( | const SDLColor & | old_color, | |
int | old_factor, | |||
const SDLColor & | new_color, | |||
int | new_factor, | |||
int | new_alpha_factor = Transparent , |
|||
int | old_alpha_factor = Opaque | |||
) | [inline, static, inherited] |
Definition at line 140 of file sdlcolor.h.
References Wt::SDLColor::alpha(), Wt::SDLColor::blue(), Wt::SDLColor::green(), Wt::SDLColor::red(), and Wt::SDLColor::SDLColor().
Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend(), and Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend().
00142 { 00143 00144 return SDLColor((new_factor * new_color.red() + old_factor * old_color.red()) / 255, 00145 (new_factor * new_color.green() + old_factor * old_color.green()) / 255, 00146 (new_factor * new_color.blue() + old_factor * old_color.blue()) / 255, 00147 (new_alpha_factor * new_color.alpha() + old_alpha_factor * old_color.alpha()) / 255); 00148 }
Here is the call graph for this function:
int Wt::SDLColor::blue | ( | ) | const [inline, inherited] |
Definition at line 79 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::blend(), Wt::SDLPixelFormat::mapToPixelValue(), Wt::operator<<(), Wt::SDLColor::SDLColor(), Wt::SDLColor::setBlue(), and Wt::SDLColor::setColor().
00079 { 00080 return sdl_color.b; 00081 }
static void Wt::SDLColor::calcBlendFactors | ( | int | factor, | |
int & | new_factor, | |||
int & | old_factor | |||
) | [inline, static, inherited] |
Definition at line 132 of file sdlcolor.h.
References Wt::SDLColor::Opaque.
Referenced by Wt::PixmapOf< Wt::SDLSurface >::blend(), and Wt::PixmapOf< Wt::SDLSurface >::blitAlphaBlend().
00132 { 00133 // it won't work in previous SDL 00134 assert(Opaque); 00135 // transparent == 0 00136 new_factor = factor; 00137 old_factor = Opaque - new_factor; 00138 }
Color Wt::Color::createColorFromRGBString | ( | const std::string & | rgb | ) | [static, protected] |
Definition at line 527 of file color.cpp.
References Color(), Wt::SDLColor::Opaque, and Warn.
Referenced by Color().
00527 { 00528 unsigned int r, g, b, a; 00529 const int conversions = sscanf(rgb.c_str(), 00530 "%u %u %u %u", &r, &g, &b, &a); 00531 00532 if (conversions == 4) 00533 return Color(r,g,b,a); 00534 00535 if (conversions == 3) 00536 return Color(r,g,b); 00537 00538 Warn("Resource: error parsing Colorvalue: '%s'\n", rgb.c_str()); 00539 return Color(0, 0, 255, Opaque); 00540 }
Here is the call graph for this function:
bool Wt::SDLColor::equals | ( | const SDLColor & | other | ) | const [inline, inherited] |
Compares colors (without alpha channel !).
Definition at line 117 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
00117 { 00118 return sdl_color.r == other.sdl_color.r && 00119 sdl_color.g == other.sdl_color.g && 00120 sdl_color.b == other.sdl_color.b; 00121 }
int Wt::SDLColor::green | ( | ) | const [inline, inherited] |
Definition at line 75 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::blend(), Wt::SDLPixelFormat::mapToPixelValue(), Wt::operator<<(), Wt::SDLColor::SDLColor(), Wt::SDLColor::setColor(), and Wt::SDLColor::setGreen().
00075 { 00076 return sdl_color.g; 00077 }
Wt::SDLColor::operator const SDL_Color & | ( | ) | const [inline, inherited] |
Definition at line 63 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
00063 { 00064 return sdl_color; 00065 }
Wt::SDLColor::operator SDL_Color & | ( | ) | [inline, inherited] |
Definition at line 67 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
00067 { 00068 return sdl_color; 00069 }
bool Wt::SDLColor::operator!= | ( | const SDLColor & | other | ) | const [inline, inherited] |
bool Wt::SDLColor::operator== | ( | const SDLColor & | other | ) | const [inline, inherited] |
Definition at line 123 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
00123 { 00124 return (memcmp(&sdl_color, &other.sdl_color, sizeof(SDL_Color)) == 0); 00125 }
int Wt::SDLColor::red | ( | ) | const [inline, inherited] |
Definition at line 71 of file sdlcolor.h.
References Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::blend(), Wt::SDLPixelFormat::mapToPixelValue(), Wt::operator<<(), Wt::SDLColor::SDLColor(), Wt::SDLColor::setColor(), and Wt::SDLColor::setRed().
00071 { 00072 return sdl_color.r; 00073 }
void Wt::SDLColor::setAlpha | ( | int | alpha | ) | [inline, inherited] |
Definition at line 99 of file sdlcolor.h.
References Wt::SDLColor::alpha(), and Wt::SDLColor::sdl_color.
Referenced by Wt::PushButton::drawButton(), and Wt::SDLColor::setColor().
Here is the call graph for this function:
void Wt::SDLColor::setBlue | ( | int | blue | ) | [inline, inherited] |
Definition at line 95 of file sdlcolor.h.
References Wt::SDLColor::blue(), and Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::setColor().
Here is the call graph for this function:
Definition at line 103 of file sdlcolor.h.
References Wt::SDLColor::alpha(), Wt::SDLColor::blue(), Wt::SDLColor::green(), Wt::SDLColor::red(), Wt::SDLColor::setAlpha(), Wt::SDLColor::setBlue(), Wt::SDLColor::setGreen(), and Wt::SDLColor::setRed().
Referenced by Wt::SDLColor::SDLColor().
00103 { 00104 setRed(red); 00105 setGreen(green); 00106 setBlue(blue); 00107 setAlpha(alpha); 00108 }
Here is the call graph for this function:
void Wt::SDLColor::setGreen | ( | int | green | ) | [inline, inherited] |
Definition at line 91 of file sdlcolor.h.
References Wt::SDLColor::green(), and Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::setColor().
Here is the call graph for this function:
void Wt::SDLColor::setRed | ( | int | red | ) | [inline, inherited] |
Definition at line 87 of file sdlcolor.h.
References Wt::SDLColor::red(), and Wt::SDLColor::sdl_color.
Referenced by Wt::SDLColor::setColor().
Here is the call graph for this function:
Color::Map Wt::Color::map [static] |
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.