_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <color.h>
Public Member Functions | |
Color () | |
Color (int color) | |
Color (int r, int g, int b, int a=255) | |
Color | operator+ (const Color &color) const |
Color | operator- (const Color &color) const |
Color | operator* (float value) const |
bool | operator== (const Color &color) const |
bool | operator!= (const Color &color) const |
Public Attributes | |
int | r |
int | g |
int | b |
int | a |
Represents a color with red, green, blue and alpha components.
Color::Color | ( | ) |
Constructor. Initializes the color to black.
Color::Color | ( | int | color | ) |
Constructs a color from the bytes in an integer. Call it with a hexadecimal constant for HTML-style color representation. The alpha component will be set to 255.
EXAMPLE: Color(0xff50a0) constructs Gui-chan's favourite color.
NOTE: Because of this constructor, integers will be automatically casted to a color by your compiler.
color | the color. |
Color::Color | ( | int | r, |
int | g, | ||
int | b, | ||
int | a = 255 |
||
) |
Constructor.
r | Red color component (range 0-255). |
g | Green color component (range 0-255). |
b | Blue color component (range 0-255). |
a | Color alpha, used for transparency. A value of 0 means totaly transparent, 255 is totaly opaque (the default). |
bool Color::operator!= | ( | const Color & | color | ) | const |
Compares two colors.
Color Color::operator* | ( | float | value | ) | const |
Multiplies the RGB values of a color with a float value. The values will be clamped if they go out of range.
value | the value to multiply the color with. |
Adds the RGB values of two colors together. The values will be clamped if they go out of range.
color | a color to add to this color. |
Subtracts the RGB values of one color from another. The values will be clamped if they go out of range.
color | a color to subtract from this color. |
bool Color::operator== | ( | const Color & | color | ) | const |
Compares two colors.
int gcn::Color::a |
Color alpha, used for transparency. A value of 0 means totaly transparent, 255 is totaly opaque (the default)
int gcn::Color::b |
Blue color component (range 0-255).
int gcn::Color::g |
Green color component (range 0-255).
int gcn::Color::r |
Red color component (range 0-255).