|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
24-bit RGB color with mixing, inversion, distance and palette-generation helpers. More...
#include <MathClasses.h>
Public Member Functions | |
| Color () | |
| Black (0,0,0). | |
| Color (uint8 red, uint8 green, uint8 blue) | |
| From RGB components. | |
| Color (const char *name) | |
| From a named color in ColorMap (case-insensitive); black when unknown. | |
| Color (const Color &color) | |
| Copy constructor. | |
| virtual | ~Color () |
| Color | mixOn (Color &color, double weight) |
| Blend this color onto a background color. | |
| Color | getReverseColor () |
| Component-wise inverse (255-r, 255-g, 255-b). | |
| uint8 | getGreyValue () |
| Grey value as the plain average (r+g+b)/3. | |
| double | distance (Color &otherColor) |
| Euclidean distance to another color in RGB space. | |
| std::string | toRGBString () |
| Format as "r,g,b" decimal text. | |
Static Public Member Functions | |
| static std::vector< Color > | createColorsMaxDifference (uint32 count, bool mix=false) |
Generate count colors spread for maximum mutual visual difference (e.g. | |
Public Attributes | |
| uint8 | r |
| uint8 | g |
| uint8 | b |
| uint32 | size |
24-bit RGB color with mixing, inversion, distance and palette-generation helpers.
A Color is three 8-bit components (r, g, b) with no alpha; transparency is handled separately by the drawing code (e.g. Bitmap::putTransPixel()'s weight parameter). Colors can be constructed from ~200 CSS/X11 names via ColorMap, blended with mixOn(), compared with distance(), and generated as maximally distinguishable palettes for charts/overlays with createColorsMaxDifference().
Definition at line 287 of file MathClasses.h.
| cmlabs::Color::Color | ( | ) |
Black (0,0,0).
Definition at line 1286 of file MathClasses.cpp.
Referenced by Color(), createColorsMaxDifference(), distance(), getReverseColor(), and mixOn().
| cmlabs::Color::Color | ( | uint8 | red, |
| uint8 | green, | ||
| uint8 | blue ) |
From RGB components.
Definition at line 1290 of file MathClasses.cpp.
| cmlabs::Color::Color | ( | const char * | name | ) |
From a named color in ColorMap (case-insensitive); black when unknown.
Definition at line 1299 of file MathClasses.cpp.
| cmlabs::Color::Color | ( | const Color & | color | ) |
|
virtual |
Definition at line 1303 of file MathClasses.cpp.
|
static |
Generate count colors spread for maximum mutual visual difference (e.g.
for chart series).
| count | Number of colors. |
| mix | Interleave rather than order by hue. |
Definition at line 1388 of file MathClasses.cpp.
Referenced by _wrap_Color_createColorsMaxDifference__SWIG_0(), and _wrap_Color_createColorsMaxDifference__SWIG_1().
| double cmlabs::Color::distance | ( | Color & | otherColor | ) |
Euclidean distance to another color in RGB space.
| otherColor | Other color. |
Definition at line 1384 of file MathClasses.cpp.
References b, Color(), g, and r.
Referenced by _wrap_Color_distance().
| uint8 cmlabs::Color::getGreyValue | ( | ) |
Grey value as the plain average (r+g+b)/3.
Definition at line 1372 of file MathClasses.cpp.
Referenced by _wrap_Color_getGreyValue().
| Color cmlabs::Color::getReverseColor | ( | ) |
Blend this color onto a background color.
Computes this*weight + color*(1-weight) per component, i.e. weight is the fraction of this color in the result and color acts as the background. Weight is clamped to [0,1].
| color | Background color. |
| weight | Fraction [0,1] of this color in the result. |
Definition at line 1359 of file MathClasses.cpp.
|
inline |
Format as "r,g,b" decimal text.
Definition at line 319 of file MathClasses.h.
References b, g, r, and cmlabs::utils::StringFormat().
| uint8 cmlabs::Color::b |
Definition at line 306 of file MathClasses.h.
Referenced by Color(), distance(), cmlabs::Bitmap::eraseBitmap(), cmlabs::Bitmap::fillBox(), getGreyValue(), cmlabs::Bitmap::getPixelColor(), getReverseColor(), mixOn(), cmlabs::Bitmap::putTransPixel(), cmlabs::Bitmap::replaceColor(), toRGBString(), and cmlabs::Bitmap::UnitTest().
| uint8 cmlabs::Color::g |
Definition at line 306 of file MathClasses.h.
Referenced by Color(), createColorsMaxDifference(), distance(), cmlabs::Bitmap::eraseBitmap(), cmlabs::Bitmap::fillBox(), getGreyValue(), cmlabs::Bitmap::getPixelColor(), getReverseColor(), mixOn(), cmlabs::Bitmap::putTransPixel(), cmlabs::Bitmap::replaceColor(), toRGBString(), and cmlabs::Bitmap::UnitTest().
| uint8 cmlabs::Color::r |
Definition at line 306 of file MathClasses.h.
Referenced by Color(), distance(), cmlabs::Bitmap::eraseBitmap(), cmlabs::Bitmap::fillBox(), getGreyValue(), cmlabs::Bitmap::getPixelColor(), getReverseColor(), mixOn(), cmlabs::Bitmap::putTransPixel(), cmlabs::Bitmap::replaceColor(), toRGBString(), and cmlabs::Bitmap::UnitTest().
| uint32 cmlabs::Color::size |
Definition at line 307 of file MathClasses.h.
Referenced by Color().