Vault  4.1
Public Member Functions | Static Public Member Functions | Friends
VColor Class Reference

VColor defines a color value in terms of RGB and Alpha. More...

#include <vcolor.h>

List of all members.

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 VColorAQUA ()
static const VColorBLACK ()
static const VColorBLUE ()
static const VColorFUCHSIA ()
static const VColorGREEN ()
static const VColorGRAY ()
static const VColorLIME ()
static const VColorMAROON ()
static const VColorNAVY ()
static const VColorOLIVE ()
static const VColorORANGE ()
static const VColorPURPLE ()
static const VColorRED ()
static const VColorSILVER ()
static const VColorTEAL ()
static const VColorWHITE ()
static const VColorYELLOW ()

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)

Detailed Description

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.

Definition at line 28 of file vcolor.h.


Constructor & Destructor Documentation

VColor::VColor ( int  r,
int  g,
int  b,
int  alpha = 255 
) [inline]

Constructor for specifying each r/g/b component with optional alpha.

Parameters:
rthe red component (will be constrained to 0..255)
gthe green component (will be constrained to 0..255)
bthe blue component (will be constrained to 0..255)
alphathe alpha channel level (0 means fully transparent, 255 means fully opaque) (will be constrained to 0..255)

Definition at line 63 of file vcolor.h.

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.

See also:
<http://en.wikipedia.org/wiki/Web_colors>
<http://en.wikipedia.org/wiki/HTML_color_names> Not supported: rgb level percentages (e.g., "rgb(10%, 20%, 30%)") Not supported: specifying alpha level
Parameters:
cssColorthe 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().


Member Function Documentation

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.

Parameters:
streamthe 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
Returns:
the L in HSL, as a value in the range 0.0 to 1.0.

Definition at line 76 of file vcolor.cpp.

References V_MAX, and V_MIN.


The documentation for this class was generated from the following files:

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.