DGtal  0.9.2
exampleBezierCurve.cpp
1 
30 #include <iostream>
32 #include "ConfigExamples.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/base/Common.h"
35 
36 #include "DGtal/io/boards/Board2D.h"
38 
39 using namespace std;
40 using namespace DGtal;
41 
43 
44 int main( int argc, char** argv )
45 {
46  trace.beginBlock ( "Example exampleBezierCurve" );
47  trace.info() << "Args:";
48  for ( int i = 0; i < argc; ++i )
49  trace.info() << " " << argv[ i ];
50  trace.info() << endl;
51 
52  //control points
53  typedef PointVector<2,int> Point;
54  Point P(0,0), Q(4,4), R(8,0);
55 
56  //display
57  Board2D board;
58 
59  //with fill
60  board << SetMode(P.className(), "Grid") << P << Q << R;
61  board.drawQuadraticBezierCurve(P[0], P[1], Q[0], Q[1], R[0], R[1]);
62 
63  board.saveSVG("BezierCurve.svg", Board2D::BoundingBox, 5000 );
64  board.saveEPS("BezierCurve.eps", Board2D::BoundingBox, 5000 );
65  board.saveTikZ("BezierCurve.tikz", Board2D::BoundingBox, 5000 );
66  board.saveFIG("BezierCurve.fig", Board2D::BoundingBox, 5000 );
67 #ifdef WITH_CAIRO
68  board.saveCairo("BezierCurve.pdf", Board2D::CairoPDF);
69 #endif
70 
71  board.clear();
72  //without fill
73  board << SetMode(P.className(), "Grid") << P << Q << R;
74  board.setFillColor(Color::None);
75  board.drawQuadraticBezierCurve(P[0], P[1], Q[0], Q[1], R[0], R[1]);
76 
77  board.saveSVG("BezierCurve2.svg", Board2D::BoundingBox, 5000 );
78  board.saveEPS("BezierCurve2.eps", Board2D::BoundingBox, 5000 );
79  board.saveTikZ("BezierCurve2.tikz", Board2D::BoundingBox, 5000 );
80  board.saveFIG("BezierCurve2.fig", Board2D::BoundingBox, 5000 );
81 #ifdef WITH_CAIRO
82  board.saveCairo("BezierCurve2.pdf", Board2D::CairoPDF);
83 #endif
84 
85  trace.endBlock();
86  return 0;
87 }
88 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:130
STL namespace.
double endBlock()
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
void saveFIG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0, bool includeFIGHeader=true) const
Definition: Board.cpp:907
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1139
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1219
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
DGtal is the top-level namespace which contains all DGtal functions and types.
Board & setFillColor(const DGtal::Color &color)
Definition: Board.cpp:322
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
std::ostream & info()
void drawQuadraticBezierCurve(double x1, double y1, double x2, double y2, double x3, double y3, int depthValue=-1)
Definition: Board.cpp:384
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
Definition: Board2D.h:247
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70