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