DGtal
1.5.beta
|
Structure representing an RGB triple with alpha component. More...
#include <DGtal/io/Color.h>
Public Member Functions | |
~Color ()=default | |
Color (const unsigned int aRgb, unsigned char aAlpha=255) | |
Color (const Color &aColor)=default | |
Color (const unsigned char aRedValue, const unsigned char aGreenValue, const unsigned char aBlueValue, const unsigned char aAlphaValue=255) | |
Color (unsigned char aGrayValue, unsigned char aAlphaValue=255) | |
Color () | |
void | red (const unsigned char aRedValue) |
void | green (const unsigned char aGreenValue) |
void | blue (const unsigned char aBlueValue) |
void | alpha (const unsigned char aAlphaValue) |
unsigned char | red () const |
unsigned char | green () const |
unsigned char | blue () const |
unsigned char | alpha () const |
double | r () const |
double | g () const |
double | b () const |
double | a () const |
Color & | setRGBi (const unsigned char aRedValue, const unsigned char aGreenValue, const unsigned char aBlueValue, const unsigned char aAlphaValue=255) |
Color & | setRGBA (DGtal::uint32_t aRGBA) |
Color & | setFromHSV (const double h, const double s, const double v) |
std::array< double, 3 > | getHSV () const |
DGtal::uint32_t | getRGB () const |
DGtal::uint32_t | getRGBA () const |
bool | valid () const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Color & | setRGBf (float red, float green, float blue, float alpha=1.0) |
bool | operator== (const Color &aColor) const |
bool | operator!= (const Color &aColor) const |
bool | operator< (const Color &aColor) const |
bool | operator> (const Color &aColor) const |
bool | operator<= (const Color &aColor) const |
bool | operator>= (const Color &aColor) const |
Color & | operator+= (const Color &v) |
Color | operator+ (const Color &v) const |
Color & | operator-= (const Color &v) |
Color | operator- (const Color &v) const |
Color & | operator*= (const double coeff) |
Color | operator* (const double coeff) const |
Color & | operator= (const Color &pv)=default |
void | flushPostscript (std::ostream &) const |
std::string | svg () const |
std::string | svgAlpha (const char *aPrefix) const |
std::string | postscript () const |
std::string | tikz () const |
Static Public Member Functions | |
static void | HSVtoRGB (double &r, double &g, double &b, double h, const double s, const double v) |
static void | RGBtoHSV (double &h, double &s, double &v, const unsigned char r, const unsigned char g, const unsigned char b) |
Static Public Attributes | |
static const Color | None |
static const Color | Black |
static const Color | Gray |
static const Color | White |
static const Color | Red |
static const Color | Green |
static const Color | Lime |
static const Color | Blue |
static const Color | Cyan |
static const Color | Magenta |
static const Color | Yellow |
static const Color | Silver |
static const Color | Purple |
static const Color | Navy |
static const Color | Aqua |
Private Member Functions | |
unsigned char | clamp (const double value) const |
Private Attributes | |
unsigned char | myRed |
unsigned char | myGreen |
unsigned char | myBlue |
unsigned char | myAlpha |
Structure representing an RGB triple with alpha component.
Description of class 'Color'
|
default |
Destructor.
DGtal::Color::Color | ( | const unsigned int | aRgb, |
unsigned char | aAlpha = 255 |
||
) |
|
default |
Copy Constructor.
aColor | the color to copy. |
|
inline |
|
inline |
|
inline |
double DGtal::Color::a | ( | ) | const |
unsigned char DGtal::Color::alpha | ( | ) | const |
void DGtal::Color::alpha | ( | const unsigned char | aAlphaValue | ) |
double DGtal::Color::b | ( | ) | const |
Referenced by setFromHSV().
unsigned char DGtal::Color::blue | ( | ) | const |
Referenced by getHSV().
void DGtal::Color::blue | ( | const unsigned char | aBlueValue | ) |
Referenced by LibBoard::Board::fillGouraudTriangle(), LibBoard::Dot::flushCairo(), LibBoard::Line::flushCairo(), LibBoard::Arrow::flushCairo(), LibBoard::Polyline::flushCairo(), LibBoard::Rectangle::flushCairo(), LibBoard::QuadraticBezierCurve::flushCairo(), LibBoard::Ellipse::flushCairo(), LibBoard::Circle::flushCairo(), LibBoard::Arc::flushCairo(), LibBoard::GouraudTriangle::flushFIG(), LibBoard::GouraudTriangle::flushPostscript(), LibBoard::GouraudTriangle::flushSVG(), DGtal::Viewer3D< TSpace, TKSpace >::GLTextureImage::GLTextureImage(), LibBoard::GouraudTriangle::GouraudTriangle(), main(), DGtal::functors::BlueChannel::operator()(), DGtal::functors::MeanChannels::operator()(), and testGrayscaleColorMap().
|
inlineprivate |
Clamp an int to [0,255]
[in] | value | the value to clamp |
Definition at line 450 of file Color.h.
References max().
Referenced by operator*(), operator*=(), operator+(), operator+=(), operator-(), and operator-=().
void DGtal::Color::flushPostscript | ( | std::ostream & | stream | ) | const |
Definition at line 142 of file Color.cpp.
Referenced by LibBoard::Polyline::flushPostscript(), LibBoard::QuadraticBezierCurve::flushPostscript(), and LibBoard::Arc::flushPostscript().
double DGtal::Color::g | ( | ) | const |
Referenced by setFromHSV().
|
inline |
Definition at line 192 of file Color.h.
References blue(), green(), red(), and RGBtoHSV().
DGtal::uint32_t DGtal::Color::getRGB | ( | ) | const |
Referenced by DGtal::functors::ColorRGBEncoder< TValue >::operator()().
DGtal::uint32_t DGtal::Color::getRGBA | ( | ) | const |
unsigned char DGtal::Color::green | ( | ) | const |
Referenced by getHSV().
void DGtal::Color::green | ( | const unsigned char | aGreenValue | ) |
Referenced by LibBoard::Board::fillGouraudTriangle(), LibBoard::Dot::flushCairo(), LibBoard::Line::flushCairo(), LibBoard::Arrow::flushCairo(), LibBoard::Polyline::flushCairo(), LibBoard::Rectangle::flushCairo(), LibBoard::QuadraticBezierCurve::flushCairo(), LibBoard::Ellipse::flushCairo(), LibBoard::Circle::flushCairo(), LibBoard::Arc::flushCairo(), LibBoard::GouraudTriangle::flushFIG(), LibBoard::GouraudTriangle::flushPostscript(), LibBoard::GouraudTriangle::flushSVG(), DGtal::Viewer3D< TSpace, TKSpace >::GLTextureImage::GLTextureImage(), LibBoard::GouraudTriangle::GouraudTriangle(), main(), DGtal::functors::GreenChannel::operator()(), DGtal::functors::MeanChannels::operator()(), and testGrayscaleColorMap().
|
static |
Converts a color from the HSV (Hue,Saturation,Value) space to the RGB space.
r | The red component (out). |
g | The green component (out). |
b | The blue component (out). |
h | The hue of the color in [0..360) |
s | The saturation of the color in [0..1]. |
v | The value of the color in [0..1]. |
Referenced by setFromHSV().
bool DGtal::Color::isValid | ( | ) | const |
bool DGtal::Color::operator!= | ( | const Color & | aColor | ) | const |
|
inline |
|
inline |
bool DGtal::Color::operator< | ( | const Color & | aColor | ) | const |
bool DGtal::Color::operator<= | ( | const Color & | aColor | ) | const |
Assignement Operator
pv | the object to copy. |
bool DGtal::Color::operator== | ( | const Color & | aColor | ) | const |
bool DGtal::Color::operator> | ( | const Color & | aColor | ) | const |
Definition at line 123 of file Color.cpp.
References DGtal::operator<().
bool DGtal::Color::operator>= | ( | const Color & | aColor | ) | const |
string DGtal::Color::postscript | ( | ) | const |
Definition at line 150 of file Color.cpp.
Referenced by LibBoard::Dot::flushPostscript(), LibBoard::Line::flushPostscript(), LibBoard::Arrow::flushPostscript(), LibBoard::Ellipse::flushPostscript(), LibBoard::Arc::flushPostscript(), and LibBoard::Text::flushPostscript().
double DGtal::Color::r | ( | ) | const |
Referenced by setFromHSV().
unsigned char DGtal::Color::red | ( | ) | const |
Referenced by getHSV().
void DGtal::Color::red | ( | const unsigned char | aRedValue | ) |
Referenced by LibBoard::Board::fillGouraudTriangle(), LibBoard::Dot::flushCairo(), LibBoard::Line::flushCairo(), LibBoard::Arrow::flushCairo(), LibBoard::Polyline::flushCairo(), LibBoard::Rectangle::flushCairo(), LibBoard::QuadraticBezierCurve::flushCairo(), LibBoard::Ellipse::flushCairo(), LibBoard::Circle::flushCairo(), LibBoard::Arc::flushCairo(), LibBoard::GouraudTriangle::flushFIG(), LibBoard::GouraudTriangle::flushPostscript(), LibBoard::GouraudTriangle::flushSVG(), DGtal::Viewer3D< TSpace, TKSpace >::GLTextureImage::GLTextureImage(), LibBoard::GouraudTriangle::GouraudTriangle(), main(), DGtal::functors::RedChannel::operator()(), DGtal::functors::MeanChannels::operator()(), and testGrayscaleColorMap().
|
static |
Converts a color from the RGB space to the HSV (Hue,Saturation,Value) space.
h | (out) The hue of the color in [0..360) |
s | (out) The saturation of the color in [0..1]. |
v | (out) The value of the color in [0..1]. |
r | The red component. |
g | The green component. |
b | The blue component. |
Referenced by getHSV().
void DGtal::Color::selfDisplay | ( | std::ostream & | out | ) | const |
|
inline |
Set the color from HSV values
h | hue |
s | saturation |
v | value |
Definition at line 184 of file Color.h.
References b(), g(), HSVtoRGB(), r(), and setRGBf().
DGtal::Color & DGtal::Color::setRGBA | ( | DGtal::uint32_t | aRGBA | ) |
Set the color parameter from an unsigned integer coding each canal.
aRGBA | an unsigned integer on 32 bits(DGtal::unit32_t) representing the color coded with 4 bits on each components R, G, B and Alpha value. |
DGtal::Color & DGtal::Color::setRGBf | ( | float | red, |
float | green, | ||
float | blue, | ||
float | alpha = 1.0 |
||
) |
Definition at line 65 of file Color.cpp.
Referenced by LibBoard::Board::setFillColorRGBf(), setFromHSV(), and LibBoard::Board::setPenColorRGBf().
Color& DGtal::Color::setRGBi | ( | const unsigned char | aRedValue, |
const unsigned char | aGreenValue, | ||
const unsigned char | aBlueValue, | ||
const unsigned char | aAlphaValue = 255 |
||
) |
Referenced by LibBoard::Board::setFillColorRGBi(), LibBoard::Board::setPenColorRGBi(), and testColor().
string DGtal::Color::svg | ( | ) | const |
Definition at line 158 of file Color.cpp.
References None.
Referenced by LibBoard::Arrow::flushSVG(), LibBoard::Text::flushSVG(), and LibBoard::Shape::svgProperties().
string DGtal::Color::svgAlpha | ( | const char * | aPrefix | ) | const |
Return a an SVG parameter string for the opacity value.
aPrefix | A prefix string to be appended to the returned string if not empty. |
Definition at line 167 of file Color.cpp.
References None.
Referenced by LibBoard::Arrow::flushSVG(), LibBoard::Text::flushSVG(), and LibBoard::Shape::svgProperties().
string DGtal::Color::tikz | ( | ) | const |
Return a string representation of the color usable in TikZ commands. Use the corresponding named color (or a mixture of a named color and black) for predefined colors. Use a mixture of red, green and blue for general colors.
Definition at line 176 of file Color.cpp.
References Black, Blue, Gray, Green, Lime, Navy, None, Purple, Red, Silver, and White.
Referenced by LibBoard::Shape::tikzProperties().
bool DGtal::Color::valid | ( | ) | const |
|
static |
|
static |
Definition at line 413 of file Color.h.
Referenced by drawCCP(), DGtal::Shortcuts< TKSpace >::getZeroTickedColorMap(), main(), LibBoard::Board::State::State(), and tikz().
|
static |
Definition at line 419 of file Color.h.
Referenced by convexHull(), drawCCP(), main(), testAlphaThickSegmentConvexHullAndBox(), testAlphaThickSegmentFreeman(), testAlphaThickSpecialInit(), testConvexHullCompThickness(), testMeshGeneration(), testThicknessDefinitions(), testVisualTubularMesh(), and tikz().
|
static |
|
static |
Definition at line 414 of file Color.h.
Referenced by main(), testAlphaThickSegmentComputerFloatingPointContour(), testAlphaThickSegmentConvexHullAndBox(), testThicknessDefinitions(), and tikz().
|
static |
Definition at line 417 of file Color.h.
Referenced by drawCCP(), main(), testAlphaThickSegmentConvexHullAndBox(), testAlphaThickSegmentFreeman(), testAlphaThickSpecialInit(), testMeshGeneration(), testThicknessDefinitions(), and tikz().
|
static |
|
static |
Definition at line 421 of file Color.h.
Referenced by testAlphaThickSegmentConvexHullAndBox().
|
private |
The opacity.
Definition at line 436 of file Color.h.
Referenced by operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), and operator==().
|
private |
The blue component.
Definition at line 435 of file Color.h.
Referenced by Color(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), and operator==().
|
private |
The green component.
Definition at line 434 of file Color.h.
Referenced by Color(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), and operator==().
|
private |
The red component.
Definition at line 433 of file Color.h.
Referenced by Color(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), and operator==().
|
static |
|
static |
Definition at line 412 of file Color.h.
Referenced by LibBoard::Board::drawArc(), LibBoard::Board::drawArrow(), LibBoard::Board::fillCircle(), LibBoard::Shape::filled(), LibBoard::Board::fillEllipse(), LibBoard::Board::fillPolyline(), LibBoard::Board::fillRectangle(), LibBoard::Board::fillTriangle(), LibBoard::Arrow::flushCairo(), LibBoard::Polyline::flushCairo(), LibBoard::Rectangle::flushCairo(), LibBoard::QuadraticBezierCurve::flushCairo(), LibBoard::Ellipse::flushCairo(), LibBoard::Circle::flushCairo(), LibBoard::Arc::flushCairo(), LibBoard::GouraudTriangle::flushFIG(), LibBoard::Polyline::flushPostscript(), LibBoard::QuadraticBezierCurve::flushPostscript(), LibBoard::Ellipse::flushPostscript(), LibBoard::Arc::flushPostscript(), main(), LibBoard::Board::saveCairo(), LibBoard::Board::saveEPS(), LibBoard::Board::saveFIG(), DGtal::Shortcuts< TKSpace >::saveOFF(), LibBoard::Board::saveSVG(), LibBoard::Board::saveTikZ(), LibBoard::Board::State::State(), svg(), svgAlpha(), LibBoard::Shape::svgProperties(), testAlphaThickSegmentConvexHullAndBox(), testMultiWidth(), testThicknessDefinitions(), and tikz().
|
static |
Definition at line 424 of file Color.h.
Referenced by testAlphaThickSegmentConvexHullAndBox(), testMeshReader(), testThicknessDefinitions(), and tikz().
|
static |
Definition at line 416 of file Color.h.
Referenced by convexHull(), drawCCP(), laplacian(), main(), testAlphaThickSegmentConvexHullAndBox(), testConvexHullCompThickness(), testMesh(), testMeshReader(), testThicknessDefinitions(), and tikz().
|
static |
|
static |
Definition at line 415 of file Color.h.
Referenced by testMesh(), and tikz().
|
static |
Definition at line 422 of file Color.h.
Referenced by drawCCP(), testAlphaThickSegmentConvexHullAndBox(), and testMeshGeneration().