Vault
4.1
|
VColor defines a color value in terms of RGB and Alpha. More...
#include <vcolor.h>
Public Member Functions | |
VColor () | |
Default constructor yields black with full opacity. | |
VColor (int r, int g, int b, int alpha=255) | |
Constructor for specifying each r/g/b component with optional alpha. | |
VColor (const VString &cssColor) | |
Constructor for specifying using a CSS-style color string. | |
VColor (VBinaryIOStream &stream) | |
Constructor for reading the rgba value from a binary stream. | |
void | readFromStream (VBinaryIOStream &stream) |
Reads the color value from a binary stream. | |
void | writeToStream (VBinaryIOStream &stream) const |
Writes the color value to a binary stream. | |
int | getRed () const |
int | getGreen () const |
int | getBlue () const |
int | getAlpha () const |
VDouble | getLightness () const |
VString | getCSSColor () const |
void | setRed (int val) |
void | setGreen (int val) |
void | setBlue (int val) |
void | setAlpha (int val) |
void | setValues (int r, int g, int b, int alpha=255) |
void | setCSSColor (const VString &cssColor) |
See the css color constructor above for details. | |
Static Public Member Functions | |
static const VColor & | AQUA () |
static const VColor & | BLACK () |
static const VColor & | BLUE () |
static const VColor & | FUCHSIA () |
static const VColor & | GREEN () |
static const VColor & | GRAY () |
static const VColor & | LIME () |
static const VColor & | MAROON () |
static const VColor & | NAVY () |
static const VColor & | OLIVE () |
static const VColor & | ORANGE () |
static const VColor & | PURPLE () |
static const VColor & | RED () |
static const VColor & | SILVER () |
static const VColor & | TEAL () |
static const VColor & | WHITE () |
static const VColor & | YELLOW () |
Friends | |
bool | operator== (const VColor &lhs, const VColor &rhs) |
bool | operator!= (const VColor &lhs, const VColor &rhs) |
bool | operator< (const VColor &lhs, const VColor &rhs) |
bool | operator<= (const VColor &lhs, const VColor &rhs) |
bool | operator>= (const VColor &lhs, const VColor &rhs) |
bool | operator> (const VColor &lhs, const VColor &rhs) |
VColor defines a color value in terms of RGB and Alpha.
The value of each component is constrained to values 0..255, but for ease of use the APIs all use plain old "int" types.
VColor::VColor | ( | int | r, |
int | g, | ||
int | b, | ||
int | alpha = 255 |
||
) | [inline] |
Constructor for specifying each r/g/b component with optional alpha.
r | the red component (will be constrained to 0..255) |
g | the green component (will be constrained to 0..255) |
b | the blue component (will be constrained to 0..255) |
alpha | the alpha channel level (0 means fully transparent, 255 means fully opaque) (will be constrained to 0..255) |
VColor::VColor | ( | const VString & | cssColor | ) | [inline, explicit] |
Constructor for specifying using a CSS-style color string.
There are four formats for the string: Hexadecimal format: #rrggbb -- each hex pair indicates the value for that r/g/b component Abbreviated hexadecimal format: #rgb -- this is nothing more than a shortcut for #rrggbb RGB integer format: rgb(x, y, z) -- x, y, and z are integer strings for the r, g, and b components The values will be constrained to 0..255. Whitespace inside the parentheses is OK. HTML+CSS color names, for example: maroon There are 17 color names defined: The 16 HTML values plus the 1 additional CSS value (orange). Use here is case insensitive.
cssColor | the string indicating the color value in one of the formats noted above; leading and trailing whitespace is OK |
Definition at line 86 of file vcolor.h.
References setCSSColor().
void VColor::readFromStream | ( | VBinaryIOStream & | stream | ) | [inline] |
Reads the color value from a binary stream.
The stream data consists of 4 bytes: r, g, b, and a values.
stream | the stream to read from |
Definition at line 102 of file vcolor.h.
References VBinaryIOStream::readU32().
void VColor::writeToStream | ( | VBinaryIOStream & | stream | ) | const [inline] |
Writes the color value to a binary stream.
The stream data consists of 4 bytes: r, g, b, and a values.
Definition at line 106 of file vcolor.h.
References VBinaryIOStream::writeU32().
VDouble VColor::getLightness | ( | ) | const |
Definition at line 76 of file vcolor.cpp.