dgtalboard-3-custom-classes.cpp

This example shows you how to modify the style of each drawable elements. You just have to create an instance of CustomColors, CustomPenColor, CustomFillColor or CustomPen and you attach this style to your drawable element type with an instance of CustomStyle outputed in the DGtalBoard stream.

//LICENSE-END

#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/DGtalBoard.h"
#include "DGtal/helpers/StdDefs.h"

using namespace std;
using namespace DGtal;
using namespace DGtal::Z2i;

int main( int argc, char** argv )
{
  trace.beginBlock ( "Example dgtalboard-3-custom-classes" );

  Point p1( -3, -2 );
  Point p2( 7, 3 );
  Point p3( 0, 0 );
  Domain domain( p1, p2 );

  DGtalBoard::Color red( 255, 0, 0 );
  DGtalBoard::Color dred( 192, 0, 0 );
  DGtalBoard::Color dgreen( 0, 192, 0 );
  DGtalBoard::Color blue( 0, 0, 255 );
  DGtalBoard::Color dblue( 0, 0, 192 );
  
  DGtalBoard board;
  board << domain 
        << CustomStyle( p1.styleName(), new CustomColors( red, dred ) )
        << p1
        << CustomStyle( p2.styleName(), new CustomFillColor( dgreen ) )
        << p2
        << CustomStyle( p3.styleName(), 
                        new CustomPen( blue, dblue, 6.0, 
                                       DGtalBoard::Shape::SolidStyle,
                                       DGtalBoard::Shape::RoundCap,
                                       DGtalBoard::Shape::RoundJoin ) )
        << p3;
  board.saveSVG("dgtalboard-3-custom-classes.svg");
  board.saveEPS("dgtalboard-3-custom-classes.eps");
  
  trace.endBlock();
  return 0;
}
//                                                                           //