DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
dgtalBoard2D-4-colormaps.cpp
Go to the documentation of this file.
1
16
29
38
40
#include <cmath>
41
#include <iostream>
42
#include "DGtal/base/Common.h"
43
#include "DGtal/io/boards/Board2D.h"
44
#include "DGtal/io/Color.h"
45
#include "DGtal/io/colormaps/GradientColorMap.h"
46
#include "DGtal/shapes/Shapes.h"
47
#include "DGtal/helpers/StdDefs.h"
49
50
using namespace
std
;
51
using namespace
DGtal
;
52
using namespace
Z2i
;
53
55
56
int
main
()
57
{
58
trace
.
beginBlock
(
"Example dgtalBoard2D-4-colormaps"
);
59
60
Point
p1( -10, -7 );
61
Point
p2( 10, 7 );
62
Domain
domain
( p1, p2 );
63
Point
c1( -5, -1 );
64
Point
c2( 5, 1 );
65
DigitalSet
shape_set(
domain
);
66
Shapes<Domain>::addNorm1Ball
( shape_set, c1, 5 );
67
Shapes<Domain>::addNorm1Ball
( shape_set, c2, 5 );
68
shape_set.
erase
( c1 );
69
shape_set.
erase
( c2 );
70
71
// Creating colormap.
72
GradientColorMap<int>
cmap_grad( 0, 15 );
73
cmap_grad.
addColor
(
Color
( 50, 50, 255 ) );
74
cmap_grad.
addColor
(
Color
( 255, 0, 0 ) );
75
cmap_grad.
addColor
(
Color
( 255, 255, 10 ) );
76
77
// Creating board.
78
Board2D
board;
79
board <<
SetMode
(
domain
.className(),
"Paving"
)
80
<<
domain
81
<<
SetMode
( p1.className(),
"Paving"
);
82
// This is the name of the style for a Point in mode "Paving".
83
string
specificStyle = p1.className() +
"/Paving"
;
84
for
(
DigitalSet::ConstIterator
it = shape_set.
begin
();
85
it != shape_set.
end
();
86
++it )
87
{
88
unsigned
int
d = (
unsigned
int) ceil( ( *it - c1 ).norm() );
89
// specific color depending on the distance to point c1.
90
board <<
CustomStyle
( specificStyle,
91
new
CustomColors
(
Color::Black
,
92
cmap_grad( d ) ) )
93
<< *it;
94
}
95
board.
saveSVG
(
"dgtalBoard2D-4-colormaps.svg"
);
96
board.
saveEPS
(
"dgtalBoard2D-4-colormaps.eps"
);
97
board.
saveTikZ
(
"dgtalBoard2D-4-colormaps.tikz"
);
98
99
#ifdef DGTAL_WITH_CAIRO
100
board.
saveCairo
(
"dgtalBoard2D-4-colormaps-cairo.pdf"
,
Board2D::CairoPDF
);
101
board.
saveCairo
(
"dgtalBoard2D-4-colormaps-cairo.png"
,
Board2D::CairoPNG
);
102
board.
saveCairo
(
"dgtalBoard2D-4-colormaps-cairo.ps"
,
Board2D::CairoPS
);
103
board.
saveCairo
(
"dgtalBoard2D-4-colormaps-cairo.svg"
,
Board2D::CairoSVG
);
104
#endif
105
106
trace
.
endBlock
();
107
return
0;
108
}
109
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::Color::Black
static const Color Black
Definition
Color.h:422
DGtal::DigitalSetByAssociativeContainer::end
ConstIterator end() const
DGtal::DigitalSetByAssociativeContainer::begin
ConstIterator begin() const
DGtal::DigitalSetByAssociativeContainer::erase
Size erase(const Point &p)
DGtal::DigitalSetByAssociativeContainer< Domain, std::unordered_set< typename Domain::Point > >::ConstIterator
Container::const_iterator ConstIterator
Definition
DigitalSetByAssociativeContainer.h:108
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition
GradientColorMap.h:120
DGtal::GradientColorMap::addColor
void addColor(const Color &color)
DGtal::Shapes::addNorm1Ball
static void addNorm1Ball(TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
DGtal::Point
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::endBlock
double endBlock()
DGtal::Domain
LibBoard::Board::saveTikZ
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1218
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1011
LibBoard::Board::CairoSVG
@ CairoSVG
Definition
Board.h:40
LibBoard::Board::CairoPDF
@ CairoPDF
Definition
Board.h:40
LibBoard::Board::CairoPNG
@ CairoPNG
Definition
Board.h:40
LibBoard::Board::CairoPS
@ CairoPS
Definition
Board.h:40
LibBoard::Board::saveCairo
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1138
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:100
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
DGtal::CustomColors::CustomColors
CustomColors(const Color &penColor, const Color &fillColor)
Definition
Board2D.h:289
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition
Board2D.h:254
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
examples
io
boards
dgtalBoard2D-4-colormaps.cpp
Generated on
for DGtal by
1.18.0