demo/eps_demo.cc
author deba
Wed, 21 Feb 2007 13:30:21 +0000
changeset 2376 0ed45a6c74b1
parent 1971 9a59a6cacfd9
child 2391 14a343be7a5a
permissions -rw-r--r--
Reorganization of the modules and groups
alpar@1971
     1
/* -*- C++ -*-
alpar@1971
     2
 *
alpar@1971
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@1971
     4
 *
alpar@1971
     5
 * Copyright (C) 2003-2006
alpar@1971
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1971
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@1971
     8
 *
alpar@1971
     9
 * Permission to use, modify and distribute this software is granted
alpar@1971
    10
 * provided that this copyright notice appears in all copies. For
alpar@1971
    11
 * precise terms see the accompanying LICENSE file.
alpar@1971
    12
 *
alpar@1971
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@1971
    14
 * express or implied, and with no claim as to its suitability for any
alpar@1971
    15
 * purpose.
alpar@1971
    16
 *
alpar@1971
    17
 */
alpar@1971
    18
alpar@1971
    19
/// \ingroup demos
alpar@1971
    20
/// \file
alpar@1971
    21
/// \brief Demo of the EPS grawing class \ref EpsDrawer()
alpar@1971
    22
///
alpar@1971
    23
/// This demo program shows examples how to use the class \ref
alpar@1971
    24
/// EpsDrawer(). It takes no input but simply creates a file
alpar@1971
    25
/// <tt>eps_demo.eps</tt> demonstrating the capability of \ref
alpar@1971
    26
/// EpsDrawer().
alpar@1971
    27
///
alpar@1971
    28
/// \include eps_demo.cc
alpar@1971
    29
alpar@1971
    30
#include <cmath>
alpar@1971
    31
#include <lemon/eps.h>
alpar@1971
    32
alpar@1971
    33
using namespace lemon;
alpar@1971
    34
alpar@1971
    35
void kosar(EpsDrawer &ed)
alpar@1971
    36
{
alpar@1971
    37
  double d,r;
alpar@1971
    38
  
alpar@1971
    39
  r = sqrt(2);
alpar@1971
    40
  
alpar@1971
    41
  ed.save();
alpar@1971
    42
  
alpar@1971
    43
  ed.translate(256,256).scale(256,256);
alpar@1971
    44
  ed.lineWidth(1/256);
alpar@1971
    45
  
alpar@1971
    46
  ed.collect();
alpar@1971
    47
  
alpar@1971
    48
  ed.moveTo(0,1);
alpar@1971
    49
  
alpar@1971
    50
  for(d=0;d<M_PI*2*5;d+=.1)
alpar@1971
    51
    {
alpar@1971
    52
      ed.lineTo(sin(d*3),cos(d*5));
alpar@1971
    53
    }
alpar@1971
    54
  
alpar@1971
    55
  ed.stroke();
alpar@1971
    56
  ed.restore();
alpar@1971
    57
  
alpar@1971
    58
}
alpar@1971
    59
alpar@1971
    60
void fonts(EpsDrawer &ed)
alpar@1971
    61
{
alpar@1971
    62
  ed.save().centerMode(true);
alpar@1971
    63
  
alpar@1971
    64
  ed.font("Helvetica").fontSize(90);
alpar@1971
    65
  ed.moveTo(256,512/3*2+50) << "Helvetica";
alpar@1971
    66
  ed.font("Courier");
alpar@1971
    67
  ed.moveTo(256,512/3+50) << "Courier" ;
alpar@1971
    68
  ed.font("Times-Roman");
alpar@1971
    69
  ed.moveTo(256,50) << "Times-Roman";
alpar@1971
    70
  
alpar@1971
    71
  ed.centerMode(false).restore();
alpar@1971
    72
}
alpar@1971
    73
alpar@1971
    74
int main()
alpar@1971
    75
{
alpar@1971
    76
alpar@1971
    77
  EpsDrawer ed("eps_demo.eps",512,512);
alpar@1971
    78
  ed.scale(1,1);
alpar@1971
    79
  
alpar@1971
    80
  ed.color(0,0,0).collect();
alpar@1971
    81
  ed.moveTo(0,0).lineTo(0,512).lineTo(512,512).lineTo(512,0).closePath().fill();
alpar@1971
    82
  
alpar@1971
    83
  ed.lineWidth(4);
alpar@1971
    84
  
alpar@1971
    85
  for(double r=0;r<=256;r+=2)
alpar@1971
    86
    {
alpar@1971
    87
      ed.color(r/256.0,0,1-r/256.0).circle(256,256,r);
alpar@1971
    88
    }
alpar@1971
    89
  
alpar@1971
    90
  
alpar@1971
    91
  ed.save();
alpar@1971
    92
  ed.color(0,0,0);
alpar@1971
    93
  ed.translate(256,256);
alpar@1971
    94
  
alpar@1971
    95
  for(int i=0;i<18;i++)
alpar@1971
    96
    {
alpar@1971
    97
      ed.rotate(20);
alpar@1971
    98
      
alpar@1971
    99
      for(double r=0;r<=256;r+=20)
alpar@1971
   100
	ed.fontSize(r/10+1).rotate(2).moveTo(0,r) << r;
alpar@1971
   101
      ed.rotate(-26);
alpar@1971
   102
      
alpar@1971
   103
    }
alpar@1971
   104
  
alpar@1971
   105
  ed.restore();
alpar@1971
   106
  
alpar@1971
   107
  fonts(ed.color(.7,.7,.7));
alpar@1971
   108
  ed.color(0,1,0);
alpar@2008
   109
alpar@2008
   110
  ed.node(ed.CIRCLE,128,333,25);
alpar@2008
   111
  ed.node(ed.SQUARE,256,333,25);
alpar@2008
   112
  ed.node(ed.DIAMOND,128+256,333,25);
alpar@2008
   113
alpar@1971
   114
  kosar(ed);
alpar@1971
   115
}