32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/Color.h"
34 #include "DGtal/io/colormaps/CColorMap.h"
35 #include "DGtal/io/colormaps/GrayscaleColorMap.h"
36 #include "DGtal/io/colormaps/HueShadeColorMap.h"
37 #include "DGtal/io/colormaps/ColorBrightnessColorMap.h"
38 #include "DGtal/io/colormaps/SimpleDistanceColorMap.h"
39 #include "DGtal/io/colormaps/GradientColorMap.h"
40 #include "DGtal/io/colormaps/RandomColorMap.h"
41 #include "DGtal/io/boards/Board2D.h"
42 #include "Board/PSFonts.h"
46 using namespace DGtal;
52 template <
typename TColorMap>
54 const TColorMap & aColorMap,
66 for (
Value x = aColorMap.min(); x <= aColorMap.max(); x += step ) {
70 static_cast<double>( step ),
77 unsigned int nbok = 0;
87 <<
"," << int(c0.
green()) <<
"," << int(c0.
blue()) << std::endl;
88 nbok += ( c0 == Color::Black );
90 Color c128 = cmap(128);
92 cerr << int(c128.
red())
93 <<
"," << int(c128.
green()) <<
"," << int(c128.
blue()) << std::endl;
94 nbok += ( c128 ==
Color(128,128,128) );
96 Color c255 = cmap(255);
98 cerr << int(c255.
red())
99 <<
"," << int(c255.
green()) <<
"," << int(c255.
blue()) << std::endl;
100 nbok += ( c255 == Color::White );
109 cerr << int(c0.
red())
110 <<
"," << int(c0.
green()) <<
"," << int(c0.
blue()) << std::endl;
111 nbok += ( c0 == Color::Black );
113 Color c255 = cmap(128);
115 cerr << int(c255.
red())
116 <<
"," << int(c255.
green()) <<
"," << int(c255.
blue()) << std::endl;
117 nbok += ( c255 == Color::White );
126 <<
"," << int(c.green()) <<
"," << int(c.blue()) << std::endl;
127 nbok += (c == Color::White);
130 trace.
info() <<
"Should be around 127,127,127: ";
132 <<
"," << int(c.green()) <<
"," << int(c.blue()) << std::endl;
144 trace.
emphase() << ( res1 ?
"Passed." :
"Error." ) << endl;
168 cmap_random.
addColor(Color::Yellow);
170 const int yellow = DGTAL_RGB2INT(255,255,0);
171 const int red = DGTAL_RGB2INT(255,0,0);
176 cmap_grad3.
addColor( Color::Green );
177 cmap_grad3.
addColor( Color::Yellow );
183 cmap_grad3.
addColor( Color::White );
224 board.
saveEPS(
"colormaps.eps" );
225 board.
saveSVG(
"colormaps.svg" );
229 board.
saveCairo(
"colormaps-cairo.pdf", Board2D::CairoPDF);
232 return ( res1 ) ? 0 : 1;
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Structure representing an RGB triple with alpha component.
void green(const unsigned char aGreenValue)
void red(const unsigned char aRedValue)
void blue(const unsigned char aBlueValue)
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void addColor(const Color &color)
Aim: This class template may be used to (linearly) convert scalar values in a given range into gray l...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: access to random color from a gradientColorMap.
void addColor(const Color &aColor)
Aim: simple blue to red colormap for distance information for instance.
void beginBlock(const std::string &keyword="")
Class for EPS, FIG or SVG drawings.
void drawRectangle(double x, double y, double width, double height, int depthValue=-1)
Board & setFont(const Fonts::Font font, double fontSize)
Board & setPenColor(const DGtal::Color &color)
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Shape & translate(double dx, double dy)
void drawText(double x, double y, const char *text, int depthValue=-1)
Board & setFillColor(const DGtal::Color &color)
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines the concept describing a color map. A color map converts a value within a given range in...
bool testGrayscaleColorMap()
void addColorMapSample(const char *name, const TColorMap &aColorMap, const typename TColorMap::Value step, Board &board)