NCBI C++ ToolKit
|
Search Toolkit Book for CRgbaColor
class CRgbaColor provides a simple abstraction for managing colors. More...
#include <gui/utils/rgba_color.hpp>
Public Member Functions | |
CRgbaColor () | |
default ctor More... | |
CRgbaColor (const float *color, size_t size) | |
construct around a given float array More... | |
CRgbaColor (float r, float g, float b) | |
construct an RGBA color around an Fl_Color More... | |
CRgbaColor (float r, float g, float b, float a) | |
construct with explicit (floating point) RGB+alpha values More... | |
CRgbaColor (const CRgbaColor &rgb, float alpha) | |
CRgbaColor (unsigned char r, unsigned char g, unsigned char b) | |
construct with explicit (unsigned char) RGB values. More... | |
CRgbaColor (unsigned char r, unsigned char g, unsigned char b, unsigned char a) | |
construct with explicit (unsigned char) RGB+alpha values. More... | |
CRgbaColor (int r, int g, int b) | |
construct with explicit (int) RGB values. More... | |
CRgbaColor (int r, int g, int b, int a) | |
construct with explicit (int) RGB+alpha values. More... | |
CRgbaColor (const string &s) | |
construct from a string encoded in the form "r g b" More... | |
void | Set (float r, float g, float b) |
set the color from an Fl_Color More... | |
void | Set (float r, float g, float b, float a) |
set the values from explicit (floating point) RGB+alpha values More... | |
void | Set (unsigned char r, unsigned char g, unsigned char b) |
set the values from explicit (unsigned char) RGB values. More... | |
void | Set (unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
set the values from explicit (unsigned char) RGB+alpha values. More... | |
void | SetRed (float r) |
Set specific channels from floating point values. More... | |
void | SetGreen (float r) |
void | SetBlue (float r) |
void | SetAlpha (float r) |
void | SetRed (unsigned char r) |
Set specific channels from floating unsigned char values. More... | |
void | SetGreen (unsigned char r) |
void | SetBlue (unsigned char r) |
void | SetAlpha (unsigned char r) |
float | GetRed (void) const |
Get specific channels in floating point values. More... | |
float | GetGreen (void) const |
float | GetBlue (void) const |
float | GetAlpha (void) const |
unsigned char | GetRedUC (void) const |
Get specific channels in unsigned char values. More... | |
unsigned char | GetGreenUC (void) const |
unsigned char | GetBlueUC (void) const |
unsigned char | GetAlphaUC (void) const |
CVect4< unsigned char > | GetRgbaUC () |
CVect3< unsigned char > | GetRgbUC () |
const float * | GetColorArray (void) const |
Access the color array directly. More... | |
void | PrintTo (CNcbiOstream &strm) const |
print the color to a stream in the form "r g b" More... | |
void | PrintTo (CNcbiOstream &strm, bool printAlpha, bool uchars=true) const |
string | ToString (bool printAlpha=true, bool uchars=true) const |
Return a string representation of the current color. More... | |
string | ToCssString (bool printAlpha=true) const |
Return a CSS string representation of the current color. More... | |
string | ToHtmlString () const |
Return an HTML string representation of the current color. More... | |
void | FromString (const string &str) |
Assign color values encoded in a string. More... | |
CRgbaColor & | operator+= (const CRgbaColor &c1) |
CRgbaColor & | operator*= (float f) |
void | Lighten (float scale) |
void | Darken (float scale) |
CRgbaColor | GetGreyscale () const |
Returns the greyscale equivalent of the current color. More... | |
CRgbaColor | ContrastingColor (bool onlyBW=true) const |
Return a color guaranteed to contrast nicely with this color. More... | |
Static Public Member Functions | |
static const char * | ColorStrFromName (const string &desc) |
return a mapped color string from a named color More... | |
static CRgbaColor | GetColor (const string &color_type) |
return a color based on a string. More... | |
static CRgbaColor | Interpolate (const CRgbaColor &color1, const CRgbaColor &color2, float alpha) |
Interpolate two colors. More... | |
static CRgbaColor | Invert (const CRgbaColor &color1) |
returns XOR complementary color, alpha is not affected More... | |
static CRgbaColor | RotateColor (const CRgbaColor &c, float degrees) |
Rotate the hue of the color by degrees. More... | |
static float | Brightness (const CRgbaColor &rgb) |
return the brightness or luminance of the color. More... | |
static float | ColorDistance (const CRgbaColor &c1, const CRgbaColor &c2) |
returns the distance in the RGB color cube between the two colors, scaled to a range [0, 1]. More... | |
Color space conversion functions. | |
static void | RgbToHsv (const CRgbaColor &rgb, float &h, float &s, float &v) |
convert RGB to HSV. More... | |
static CRgbaColor | HsvToRgb (float h, float s, float v) |
static void | RgbToYuv (const CRgbaColor &rgb, float &y, float &u, float &v) |
convert RGB to YUV. More... | |
static bool | YuvToRgb (float y, float u, float v, CRgbaColor &rgb) |
Not all possible input values of y, u and v will make a valid RGB color. More... | |
Private Member Functions | |
void | x_Clamp () |
Private Attributes | |
float | m_Rgba [4] |
class CRgbaColor provides a simple abstraction for managing colors.
Keep the class concrete to make it efficient for use in arrays/buffers (do not derive from this class or add virtual functions.)
Definition at line 57 of file rgba_color.hpp.