DGtal  1.0.0
dgtalBoard2D-3-custom-classes.cpp
Go to the documentation of this file.
1 
41 #include <iostream>
43 #include "DGtal/base/Common.h"
44 #include "DGtal/io/boards/Board2D.h"
45 #include "DGtal/helpers/StdDefs.h"
46 #include "DGtal/io/Color.h"
48 
49 using namespace std;
50 using namespace DGtal;
51 using namespace DGtal::Z2i;
52 
54 int main()
55 {
56  trace.beginBlock ( "Example dgtalBoard2D-3-custom-classes" );
57 
58  Point p1( -3, -2 );
59  Point p2( 7, 3 );
60  Point p3( 0, 0 );
61  Domain domain( p1, p2 );
62 
63  Color red( 255, 0, 0 );
64  Color dred( 192, 0, 0 );
65  Color dgreen( 0, 192, 0 );
66  Color blue( 0, 0, 255 );
67  Color dblue( 0, 0, 192 );
68 
69  Board2D board;
70  board << domain
71  << CustomStyle( p1.className(), new CustomColors( red, dred ) )
72  << p1
73  << CustomStyle( p2.className(), new CustomFillColor( dgreen ) )
74  << p2
75  << CustomStyle( p3.className(),
76  new CustomPen( blue, dblue, 6.0,
77  Board2D::Shape::SolidStyle,
78  Board2D::Shape::RoundCap,
79  Board2D::Shape::RoundJoin ) )
80  << p3;
81  board.saveSVG("dgtalBoard2D-3-custom-classes.svg");
82  board.saveEPS("dgtalBoard2D-3-custom-classes.eps");
83  board.saveTikZ("dgtalBoard2D-3-custom-classes.tikz");
84 
85 #ifdef WITH_CAIRO
86  board.saveCairo("dgtalBoard2D-3-custom-classes-cairo.pdf", Board2D::CairoPDF);
87  board.saveCairo("dgtalBoard2D-3-custom-classes-cairo.png", Board2D::CairoPNG);
88  board.saveCairo("dgtalBoard2D-3-custom-classes-cairo.ps", Board2D::CairoPS);
89  board.saveCairo("dgtalBoard2D-3-custom-classes-cairo.svg", Board2D::CairoSVG);
90 #endif
91 
92  trace.endBlock();
93  return 0;
94 }
95 // //
void beginBlock(const std::string &keyword="")
Custom style class redefining the pen attributes. You may use Board2D::Color::None for transparent co...
Definition: Board2D.h:373
Trace trace
Definition: Common.h:144
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:342
double endBlock()
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
Domain domain
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1139
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
std::string className() const
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1219
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70