DGtal  0.9.4beta
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
DGtal::Color Class Reference

#include <DGtal/io/Color.h>

Collaboration diagram for DGtal::Color:
[legend]

Public Member Functions

 ~Color ()
 
 Color (const unsigned int aRgb, unsigned char aAlpha=255)
 
 Color (const Color &aColor)
 
 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 ()
 
ColorsetRGBi (const unsigned char aRedValue, const unsigned char aGreenValue, const unsigned char aBlueValue, const unsigned char aAlphaValue)
 
ColorsetRGBA (DGtal::uint32_t aRGBA)
 
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
 
DGtal::uint32_t getRGB () const
 
DGtal::uint32_t getRGBA () const
 
bool valid () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
ColorsetRGBf (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
 
Coloroperator+= (const Color &v)
 
Color operator+ (const Color &v) const
 
Coloroperator-= (const Color &v)
 
Color operator- (const Color &v) const
 
Coloroperator*= (const double coeff)
 
Color operator* (const double coeff) const
 
Coloroperator= (const Color &pv)
 
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 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
 

Detailed Description

Structure representing an RGB triple with alpha component.

Description of class 'Color'

Note
if compilation flag COLOR_WITH_ALPHA_ARITH is set, then the arithmetical operations on colors also consider the alpha-channel. Otherwise, the alpha channel is not changed when summing up to colors for instance.
Examples:
dec/exampleDiscreteExteriorCalculusSolve.cpp, examples/tutorial-examples/polyhedralizer.cpp, geometry/curves/exampleAlphaThickSegment.cpp, geometry/curves/exampleAlphaThickSegmentTgtCover.cpp, geometry/curves/exampleArithmeticalDSS.cpp, geometry/curves/exampleGridCurve3d-2.cpp, geometry/surfaces/dvcm-3d.cpp, geometry/surfaces/greedy-plane-segmentation-ex2.cpp, geometry/surfaces/greedy-plane-segmentation.cpp, geometry/volumes/distance/distancetransform3D.cpp, geometry/volumes/distance/exampleFMM3D.cpp, geometry/volumes/distance/voronoimap2D.cpp, geometry/volumes/dvcm-2d.cpp, graph/graphTraversal.cpp, graph/volDistanceTraversal.cpp, io/boards/dgtalBoard2D-3-custom-classes.cpp, io/boards/dgtalBoard2D-3-custom-points.cpp, io/boards/dgtalBoard2D-4-colormaps.cpp, io/boards/dgtalBoard3D-1-points.cpp, io/boards/dgtalBoard3D-6-clipping.cpp, io/boards/dgtalBoard3DTo2D-3-objects.cpp, io/boards/dgtalBoard3DTo2D-5-custom.cpp, io/boards/dgtalBoard3DTo2D-6.cpp, io/boards/logoDGtal.cpp, io/digitalSetFromPointList.cpp, io/meshFromOFF.cpp, io/viewDualSurface.cpp, io/viewers/viewer3D-3-objects.cpp, io/viewers/viewer3D-5-custom.cpp, io/viewers/viewer3D-6-clipping.cpp, io/viewers/viewer3D-7-planes.cpp, io/viewers/viewer3D-7-stdplane.cpp, io/viewers/viewer3D-7bis-planes.cpp, io/viewers/viewer3D-7bis-stdplane.cpp, io/viewers/viewer3D-9-3Dimages.cpp, shapes/exampleEuclideanShapesDecorator.cpp, shapes/mesh3DConstructionAndVisualisation.cpp, topology/3dBorderExtraction.cpp, topology/3dKSSurfaceExtraction.cpp, topology/ctopo-1.cpp, topology/ctopo-2-3d.cpp, topology/ctopo-2.cpp, topology/ctopo-fillContours.cpp, topology/cubical-complex-illustrations.cpp, topology/digitalSetToCubicalComplexes2D.cpp, topology/digitalSurfaceSlice.cpp, topology/frontierAndBoundary.cpp, topology/generateSimplicityTables2D.cpp, topology/homotopicThinning3D.cpp, topology/khalimskySpaceScanner.cpp, topology/volBreadthFirstTraversal.cpp, topology/volScanBoundary.cpp, topology/volTrackBoundary.cpp, tutorial-examples/freemanChainFromImage.cpp, tutorial-examples/polyhedralizer.cpp, and tutorial-examples/volDTGranulo.cpp.

Definition at line 66 of file Color.h.

Constructor & Destructor Documentation

DGtal::Color::~Color ( )

Destructor.

Definition at line 186 of file Color.cpp.

187 {
188 }
DGtal::Color::Color ( const unsigned int  aRgb,
unsigned char  aAlpha = 255 
)

Constructor.

Parameters
aRgban unsigned int representing the color.
aAlphacolor transparency (default value =255);

Definition at line 44 of file Color.cpp.

References myBlue, myGreen, and myRed.

45  :myAlpha( aAlphaValue )
46 {
47  myRed = ( rgb & 0xFF0000u ) >> 16;
48  myGreen = ( rgb & 0xFF00u ) >> 8;
49  myBlue = rgb & 0xFF;
50 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
DGtal::Color::Color ( const Color aColor)
inline

Copy Constructor.

Parameters
aColorthe color to copy.

Definition at line 95 of file Color.h.

95  :
96  myRed(aColor.myRed),myGreen(aColor.myGreen),
97  myBlue(aColor.myBlue), myAlpha(aColor.myAlpha)
98  {}
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
DGtal::Color::Color ( const unsigned char  aRedValue,
const unsigned char  aGreenValue,
const unsigned char  aBlueValue,
const unsigned char  aAlphaValue = 255 
)
inline

Constructor from R, G, B and Alpha parameter.

Parameters
aRedValuered component
aGreenValuegreen component
aBlueValueblue component
aAlphaValuecolor transparency.

Definition at line 110 of file Color.h.

114  : myRed(aRedValue),myGreen(aGreenValue),myBlue(aBlueValue),myAlpha(aAlphaValue) { }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
DGtal::Color::Color ( unsigned char  aGrayValue,
unsigned char  aAlphaValue = 255 
)
inline

Constructor from gray scale value.

Parameters
aGrayValuethe color gray value.
aAlphaValuecolor transparency (default value =255);.

Definition at line 124 of file Color.h.

126  : myRed(aGrayValue),myGreen(aGrayValue), myBlue(aGrayValue), myAlpha(aAlphaValue) { }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
DGtal::Color::Color ( )
inline

Default Constructor.

Definition at line 134 of file Color.h.

135  : myRed(0),myGreen(0),myBlue(0), myAlpha(255)
136  {
137  }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409

Member Function Documentation

void DGtal::Color::alpha ( const unsigned char  aAlphaValue)
unsigned char DGtal::Color::alpha ( ) const
void DGtal::Color::blue ( const unsigned char  aBlueValue)
unsigned char DGtal::Color::blue ( ) const
unsigned char DGtal::Color::clamp ( const double  value) const
inlineprivate

Clamp an int to [0,255]

Parameters
[in]valuethe value to clamp
Returns
the clamped value

Definition at line 424 of file Color.h.

Referenced by operator*(), operator*=(), operator+(), operator+=(), operator-(), and operator-=().

425  {
426  return static_cast<unsigned char>(std::max( std::min(value, 255.0), 0.0));
427  }
void DGtal::Color::flushPostscript ( std::ostream &  stream) const

Definition at line 124 of file Color.cpp.

Referenced by LibBoard::Polyline::flushPostscript(), LibBoard::QuadraticBezierCurve::flushPostscript(), and LibBoard::Arc::flushPostscript().

125 {
126  stream << ((double)myRed/255.0) << " "
127  << ((double)myGreen/255.0) << " "
128  << ((double)myBlue/255.0) << " srgb\n";
129 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myBlue
Definition: Color.h:409
DGtal::uint32_t DGtal::Color::getRGB ( ) const
Returns
the unsigned integer ( DGtal::uint32_t ) coding each R, G, B canal on 8 bits starting from least significant bit.

Referenced by DGtal::functors::ColorRGBEncoder< TValue >::operator()().

DGtal::uint32_t DGtal::Color::getRGBA ( ) const
Returns
the unsigned integer ( DGtal::uint32_t ) coding each R, G, B, A canal on 8 bits starting from least significant bit.
void DGtal::Color::green ( const unsigned char  aGreenValue)
unsigned char DGtal::Color::green ( ) const
bool DGtal::Color::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 227 of file Color.cpp.

228 {
229  return true;
230 }
bool DGtal::Color::operator!= ( const Color aColor) const

Definition at line 96 of file Color.cpp.

References myAlpha, myBlue, myGreen, and myRed.

97 {
98  return myRed != aColor.myRed
99  || myGreen != aColor.myGreen
100  || myBlue != aColor.myBlue
101  || myAlpha != aColor.myAlpha;
102 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color DGtal::Color::operator* ( const double  coeff) const
inline

Multiplication by a scalar (component-wise)

Note
returned components are clamped to [0,255] interval.
Parameters
coeffthe scalar.
Returns
a scaled color

Definition at line 330 of file Color.h.

References clamp(), myAlpha, myBlue, myGreen, and myRed.

331  {
332  Color c;
333  c.myRed = clamp((double)this->myRed*coeff);
334  c.myBlue = clamp((double)this->myBlue*coeff);
335  c.myGreen = clamp((double)this->myGreen*coeff);
336 #ifdef COLOR_WITH_ALPHA_ARITH
337  c.myAlpha = clamp((double)this->myAlpha*coeff);
338 #else
339  c.myAlpha = this->myAlpha;
340 #endif
341  return c;
342  }
unsigned char clamp(const double value) const
Definition: Color.h:424
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color& DGtal::Color::operator*= ( const double  coeff)
inline

Multiplication by a scalar (component-wise)

Note
returned components are clamped to [0,255] interval.
Parameters
coeffthe scalar
Returns
the scaled color

Definition at line 311 of file Color.h.

References clamp(), myAlpha, myBlue, myGreen, and myRed.

312  {
313  this->myRed = clamp((double)this->myRed*coeff);
314  this->myBlue = clamp((double)this->myBlue*coeff);
315  this->myGreen = clamp((double)this->myGreen*coeff);
316 #ifdef COLOR_WITH_ALPHA_ARITH
317  this->myAlpha = clamp((double)this->myAlpha*coeff);
318 #endif
319  return *this;
320  }
unsigned char clamp(const double value) const
Definition: Color.h:424
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color DGtal::Color::operator+ ( const Color v) const
inline

Addition operator.

Note
returned components are clamped to [0,255] interval.
Parameters
vis the Color that gets added to *this.
Returns
a new Point that is the addition of 'this' to [v].

Definition at line 245 of file Color.h.

References clamp(), myAlpha, myBlue, myGreen, and myRed.

246  {
247  Color c;
248  c.myRed = clamp((int)this->myRed + (int)v.myRed);
249  c.myBlue =clamp((int)this->myBlue + (int)v.myBlue);
250  c.myGreen = clamp((int)this->myGreen + (int)v.myGreen);
251 #ifdef COLOR_WITH_ALPHA_ARITH
252  c.myAlpha = clamp((int)this->myAlpha + (int)v.myAlpha);
253 #else
254  c.myAlpha = this->myAlpha ;
255 #endif
256  return c;
257  }
unsigned char clamp(const double value) const
Definition: Color.h:424
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color& DGtal::Color::operator+= ( const Color v)
inline

Addition operator with assignement.

Note
returned components are clamped to [0,255] interval.
Parameters
vis the Color that gets added to *this.
Returns
a reference on 'this'.

Definition at line 225 of file Color.h.

References clamp(), myAlpha, myBlue, myGreen, and myRed.

226  {
227  this->myRed = clamp((int)this->myRed + (int)v.myRed);
228  this->myBlue = clamp((int)this->myBlue + (int)v.myBlue);
229  this->myGreen = clamp((int)this->myGreen + (int)v.myGreen);
230 #ifdef COLOR_WITH_ALPHA_ARITH
231  this->myAlpha = clamp((int)this->myAlpha + (int)v.myAlpha);
232 #endif
233  return *this;
234  }
unsigned char clamp(const double value) const
Definition: Color.h:424
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color DGtal::Color::operator- ( const Color v) const
inline

Substraction operator.

Note
returned components are clamped to [0,255] interval.
Parameters
vis the Color that gets substacted to *this.
Returns
a new Point that is the subtraction 'this'-[v].

Definition at line 287 of file Color.h.

References clamp(), myAlpha, myBlue, myGreen, and myRed.

288  {
289  Color c;
290  c.myRed = clamp((int)this->myRed - (int)v.myRed);
291  c.myBlue = clamp((int)this->myBlue - (int)v.myBlue);
292  c.myGreen = clamp((int)this->myGreen - (int)v.myGreen);
293 #ifdef COLOR_WITH_ALPHA_ARITH
294  c.myAlpha = clamp((int)this->myAlpha - (int)v.myAlpha);
295 #else
296  c.myAlpha = this->myAlpha ;
297 #endif
298  return c;
299  }
unsigned char clamp(const double value) const
Definition: Color.h:424
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color& DGtal::Color::operator-= ( const Color v)
inline

Substraction operator with assignement.

Note
returned components are clamped to [0,255] interval.
Parameters
vis the Point that gets substracted to *this.
Returns
a reference on 'this'.

Definition at line 268 of file Color.h.

References clamp(), myAlpha, myBlue, myGreen, and myRed.

269  {
270  this->myRed = clamp((int)this->myRed - (int)v.myRed);
271  this->myBlue = clamp((int)this->myBlue - (int)v.myBlue);
272  this->myGreen = clamp((int)this->myGreen - (int)v.myGreen);
273 #ifdef COLOR_WITH_ALPHA_ARITH
274  this->myAlpha = clamp((int)this->myAlpha - (int)v.myAlpha);
275 #endif
276  return *this;
277  }
unsigned char clamp(const double value) const
Definition: Color.h:424
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
bool DGtal::Color::operator< ( const Color aColor) const

Definition at line 105 of file Color.cpp.

References myAlpha, myBlue, myGreen, and myRed.

106 {
107  if ( myRed < aColor.myRed )
108  return true;
109  if ( myRed == aColor.myRed ) {
110  if ( myGreen < aColor.myGreen )
111  return true;
112  if ( myGreen == aColor.myGreen ) {
113  if ( myBlue < aColor.myBlue )
114  return true;
115  if ( myBlue == aColor.myBlue )
116  return myAlpha < aColor.myAlpha;
117  }
118  }
119  return false;
120 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color& DGtal::Color::operator= ( const Color pv)
inline

Assignement Operator

Parameters
pvthe object to copy.
Returns
a reference on 'this'.

Definition at line 350 of file Color.h.

References myAlpha, myBlue, myGreen, and myRed.

351  {
352  this->myRed = pv.myRed;
353  this->myGreen = pv.myGreen;
354  this->myBlue = pv.myBlue;
355  this->myAlpha = pv.myAlpha;
356  return *this;
357  }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
bool DGtal::Color::operator== ( const Color aColor) const

Definition at line 87 of file Color.cpp.

References myAlpha, myBlue, myGreen, and myRed.

88 {
89  return myRed == aColor.myRed
90  && myGreen == aColor.myGreen
91  && myBlue == aColor.myBlue
92  && myAlpha == aColor.myAlpha;
93 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
string DGtal::Color::postscript ( ) const

Definition at line 132 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().

133 {
134  char buffer[255];
135  secured_sprintf( buffer, 255, "%.4f %.4f %.4f", myRed/255.0, myGreen/255.0, myBlue/255.0 );
136  return buffer;
137 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myBlue
Definition: Color.h:409
void DGtal::Color::red ( const unsigned char  aRedValue)
unsigned char DGtal::Color::red ( ) const
void DGtal::Color::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Definition at line 217 of file Color.cpp.

218 {
219  out << "[Color] RGBA("<<(int)myRed<<","<<(int)myGreen<<","<<(int)myBlue<<","<<(int)myAlpha<<")";
220 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
DGtal::Color & DGtal::Color::setRGBA ( DGtal::uint32_t  aRGBA)

Set the color parameter from an unsigned integer coding each canal.

Parameters
aRGBAan unsigned integer on 32 bits(DGtal::unit32_t) representing the color coded with 4 bits on each components R, G, B and Alpha value.
Returns
a reference on the itself.

Definition at line 54 of file Color.cpp.

55 {
56  myRed = ( aRGBA & 0xFF000000u ) >> 24;
57  myGreen = ( aRGBA & 0xFF0000u ) >> 16;
58  myBlue = ( aRGBA & 0xFF00u ) >> 8;
59  myAlpha = aRGBA & 0xFF;
60  return *this;
61 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
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(), and LibBoard::Board::setPenColorRGBf().

68  {
69  if ( aRedValue > 1.0f ) aRedValue = 1.0f;
70  if ( aRedValue < 0.0f ) aRedValue = 0.0f;
71  myRed = static_cast<unsigned char>( 255 * aRedValue );
72  if ( aGreenValue > 1.0f ) aGreenValue = 1.0f;
73  if ( aGreenValue < 0.0f ) aGreenValue = 0.0f;
74  myGreen = static_cast<unsigned char>( 255 * aGreenValue );
75  if ( aBlueValue > 1.0f ) aBlueValue = 1.0f;
76  if ( aBlueValue < 0.0f ) aBlueValue = 0.0f;
77  myBlue = static_cast<unsigned char>( 255 * aBlueValue );
78  if ( aAlphaValue > 1.0f ) aAlphaValue = 1.0f;
79  if ( aAlphaValue < 0.0f ) aAlphaValue = 0.0f;
80  myAlpha = static_cast<unsigned char>( 255 * aAlphaValue );
81  return *this;
82 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
unsigned char myAlpha
Definition: Color.h:410
unsigned char myBlue
Definition: Color.h:409
Color& DGtal::Color::setRGBi ( const unsigned char  aRedValue,
const unsigned char  aGreenValue,
const unsigned char  aBlueValue,
const unsigned char  aAlphaValue 
)
string DGtal::Color::svg ( ) const

Definition at line 140 of file Color.cpp.

References None.

Referenced by LibBoard::Arrow::flushSVG(), LibBoard::Text::flushSVG(), and LibBoard::Shape::svgProperties().

141 {
142  char buffer[255];
143  if ( *this == DGtal::Color::None ) return "none";
144  secured_sprintf( buffer, 255, "rgb(%d,%d,%d)",myRed, myGreen, myBlue );
145  return buffer;
146 }
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
static const Color None
Definition: Color.h:387
unsigned char myBlue
Definition: Color.h:409
string DGtal::Color::svgAlpha ( const char *  aPrefix) const

Return a an SVG parameter string for the opacity value.

Parameters
aPrefixA prefix string to be appended to the returned string if not empty.
Returns
An empty string if alpha == 255, otherwise the string <prefix>-opacity="<alpha-value>".

Definition at line 149 of file Color.cpp.

References None.

Referenced by LibBoard::Arrow::flushSVG(), LibBoard::Text::flushSVG(), and LibBoard::Shape::svgProperties().

150 {
151  char buffer[255];
152  if ( myAlpha == 255 || *this == DGtal::Color::None ) return "";
153  secured_sprintf( buffer, 255, " %s-opacity=\"%f\"", prefix, myAlpha/255.0f );
154  return buffer;
155 }
unsigned char myAlpha
Definition: Color.h:410
static const Color None
Definition: Color.h:387
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.

Returns
a string representation of the color usable in TikZ commands.

Definition at line 158 of file Color.cpp.

References Black, Blue, Gray, Green, Lime, Navy, None, Purple, Red, Silver, and White.

Referenced by LibBoard::Shape::tikzProperties().

159 {
160  // see tex/generic/pgf/utilities/pgfutil-plain.def for color definitions
161  char buffer[255];
162  if ( *this == DGtal::Color::None ) return "none";
163  if ( *this == DGtal::Color::Black ) return "black";
164  if ( *this == DGtal::Color::Gray ) return "gray";
165  if ( *this == DGtal::Color::White ) return "white";
166  if ( *this == DGtal::Color::Red ) return "red";
167  if ( *this == DGtal::Color::Green ) return "green!50!black";
168  if ( *this == DGtal::Color::Lime ) return "green";
169  if ( *this == DGtal::Color::Blue ) return "blue";
170 // if ( *this == DGtal::Color::Cyan ) return "cyan";
171 // if ( *this == DGtal::Color::Magenta ) return "magenta";
172 // if ( *this == DGtal::Color::Yellow ) return "yellow";
173  if ( *this == DGtal::Color::Silver ) return "white!75!black";
174  if ( *this == DGtal::Color::Purple ) return "gray"; // ???: Is Color::Purple meant to be equal to Color::Gray?
175  if ( *this == DGtal::Color::Navy ) return "blue!50!black";
176 // if ( *this == DGtal::Color::Aqua ) return "cyan"; // ???: Is Color::Aqua meant to be equal to Color::Cyan?
177  secured_sprintf( buffer, 255, "{rgb,255:red,%d;green,%d;blue,%d}", myRed, myGreen, myBlue );
178  return buffer;
179 }
static const Color Black
Definition: Color.h:388
unsigned char myGreen
Definition: Color.h:408
unsigned char myRed
Definition: Color.h:407
static const Color Navy
Definition: Color.h:400
static const Color None
Definition: Color.h:387
static const Color Lime
Definition: Color.h:393
static const Color Blue
Definition: Color.h:394
static const Color Gray
Definition: Color.h:389
unsigned char myBlue
Definition: Color.h:409
static const Color Silver
Definition: Color.h:398
static const Color White
Definition: Color.h:390
static const Color Red
Definition: Color.h:391
static const Color Green
Definition: Color.h:392
static const Color Purple
Definition: Color.h:399
bool DGtal::Color::valid ( ) const

Field Documentation

const DGtal::Color DGtal::Color::Aqua
static

Definition at line 401 of file Color.h.

const DGtal::Color DGtal::Color::Black
static

Definition at line 388 of file Color.h.

Referenced by LibBoard::Board::State::State(), and tikz().

const DGtal::Color DGtal::Color::Blue
static
const DGtal::Color DGtal::Color::Cyan
static

Definition at line 395 of file Color.h.

const DGtal::Color DGtal::Color::Gray
static
Examples:
geometry/curves/greedyAlphaThickDecomposition.cpp.

Definition at line 389 of file Color.h.

Referenced by tikz().

const DGtal::Color DGtal::Color::Green
static
const DGtal::Color DGtal::Color::Lime
static

Definition at line 393 of file Color.h.

Referenced by tikz().

const DGtal::Color DGtal::Color::Magenta
static

Definition at line 396 of file Color.h.

unsigned char DGtal::Color::myAlpha
private
unsigned char DGtal::Color::myBlue
private

The blue component.

Definition at line 409 of file Color.h.

Referenced by Color(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator=(), and operator==().

unsigned char DGtal::Color::myGreen
private

The green component.

Definition at line 408 of file Color.h.

Referenced by Color(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator=(), and operator==().

unsigned char DGtal::Color::myRed
private

The red component.

Definition at line 407 of file Color.h.

Referenced by Color(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator=(), and operator==().

const DGtal::Color DGtal::Color::Navy
static

Definition at line 400 of file Color.h.

Referenced by tikz().

const DGtal::Color DGtal::Color::None
static
const DGtal::Color DGtal::Color::Purple
static

Definition at line 399 of file Color.h.

Referenced by tikz().

const DGtal::Color DGtal::Color::Red
static
const DGtal::Color DGtal::Color::Silver
static

Definition at line 398 of file Color.h.

Referenced by tikz().

const DGtal::Color DGtal::Color::White
static

Definition at line 390 of file Color.h.

Referenced by tikz().

const DGtal::Color DGtal::Color::Yellow
static
Examples:
tutorial-examples/volDTGranulo.cpp.

Definition at line 397 of file Color.h.


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