DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dgtalBoard2D-3-custom-points.cpp
1 
16 //LICENSE-END
30 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/Color.h"
34 #include "DGtal/io/boards/Board2D.h"
35 #include "DGtal/helpers/StdDefs.h"
37 
38 using namespace std;
39 using namespace DGtal;
40 using namespace DGtal::Z2i;
41 
44 {
47  MyDrawStyleCustomColor( const Color & penColor,
48  const Color & fillColor )
49  : myPenColor( penColor ), myFillColor( fillColor )
50  {}
51 
52  virtual void setStyle( Board2D & aboard) const
53  {
54  aboard.setFillColor( myFillColor);
55  aboard.setPenColor( myPenColor );
56  }
57 };
58 
59 int main()
60 {
61  trace.beginBlock ( "Example dgtalBoard2D-3-custom-points" );
62 
63  Point p1( -3, -2 );
64  Point p2( 7, 3 );
65  Point p3( 0, 0 );
66  Domain domain( p1, p2 );
67 
68  Color red( 255, 0, 0 );
69  Color dred( 192, 0, 0 );
70  Color green( 0, 255, 0 );
71  Color dgreen( 0, 192, 0 );
72  Color blue( 0, 0, 255 );
73  Color dblue( 0, 0, 192 );
74 
75  Board2D board;
76  board << domain
77  << CustomStyle( p1.className(), new MyDrawStyleCustomColor( red, dred ) )
78  << p1
79  << CustomStyle( p2.className(), new MyDrawStyleCustomColor( green, dgreen ) )
80  << p2
81  << CustomStyle( p3.className(), new MyDrawStyleCustomColor( blue, dblue ) )
82  << p3;
83  board.saveSVG("dgtalBoard2D-3-custom-points.svg");
84  board.saveEPS("dgtalBoard2D-3-custom-points.eps");
85  board.saveTikZ("dgtalBoard2D-3-custom-points.tikz");
86 
87 #ifdef WITH_CAIRO
88  board.saveCairo("dgtalBoard2D-3-custom-points-cairo.pdf", Board2D::CairoPDF);
89  board.saveCairo("dgtalBoard2D-3-custom-points-cairo.png", Board2D::CairoPNG);
90  board.saveCairo("dgtalBoard2D-3-custom-points-cairo.ps", Board2D::CairoPS);
91  board.saveCairo("dgtalBoard2D-3-custom-points-cairo.svg", Board2D::CairoSVG);
92 #endif
93 
94  trace.endBlock();
95  return 0;
96 }
97 // //