eps_demo.cc File Reference


Detailed Description

This demo program shows examples how to use the class EpsDrawer. It takes no input but simply creates a file eps_demo.eps demonstrating the capability of EpsDrawer.

/* -*- C++ -*-
 *
 * This file is a part of LEMON, a generic C++ optimization library
 *
 * Copyright (C) 2003-2008
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
 *
 * Permission to use, modify and distribute this software is granted
 * provided that this copyright notice appears in all copies. For
 * precise terms see the accompanying LICENSE file.
 *
 * This software is provided "AS IS" with no warranty of any kind,
 * express or implied, and with no claim as to its suitability for any
 * purpose.
 *
 */


#include <lemon/math.h>
#include <lemon/eps.h>

using namespace lemon;

void kosar(EpsDrawer &ed)
{
  double d,r;
  
  r = sqrt(2);
  
  ed.save();
  
  ed.translate(256,256).scale(256,256);
  ed.lineWidth(1/256);
  
  ed.collect();
  
  ed.moveTo(0,1);
  
  for(d=0;d<PI*2*5;d+=.1)
    {
      ed.lineTo(sin(d*3),cos(d*5));
    }
  
  ed.stroke();
  ed.restore();
  
}

void fonts(EpsDrawer &ed)
{
  ed.save().centerMode(true);
  
  ed.font("Helvetica").fontSize(90);
  ed.moveTo(256,512/3*2+50) << "Helvetica";
  ed.font("Courier");
  ed.moveTo(256,512/3+50) << "Courier" ;
  ed.font("Times-Roman");
  ed.moveTo(256,50) << "Times-Roman";
  
  ed.centerMode(false).restore();
}

int main()
{

  EpsDrawer ed("eps_demo.eps",512,512);
  ed.scale(1,1);
  
  ed.color(0,0,0).collect();
  ed.moveTo(0,0).lineTo(0,512).lineTo(512,512).lineTo(512,0).closePath().fill();
  
  ed.lineWidth(4);
  
  for(double r=0;r<=256;r+=2)
    {
      ed.color(r/256.0,0,1-r/256.0).circle(256,256,r);
    }
  
  
  ed.save();
  ed.color(0,0,0);
  ed.translate(256,256);
  
  for(int i=0;i<18;i++)
    {
      ed.rotate(20);
      
      for(double r=0;r<=256;r+=20)
        ed.fontSize(r/10+1).rotate(2).moveTo(0,r) << r;
      ed.rotate(-26);
      
    }
  
  ed.restore();
  
  fonts(ed.color(.7,.7,.7));
  ed.color(0,1,0);

  ed.node(ed.CIRCLE,128,333,25);
  ed.node(ed.SQUARE,256,333,25);
  ed.node(ed.DIAMOND,128+256,333,25);

  kosar(ed);
}
#include <lemon/math.h>
#include <lemon/eps.h>

Generated on Thu Jun 4 04:03:09 2009 for LEMON by  doxygen 1.5.9