summaryrefslogtreecommitdiff
path: root/info/laan/paradigm/paradigm.postscript
blob: c92955bf0cb0990e0e9ef8f0f02c81012a81d77e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
%Started May 1996, C.G. van der laan, cgl@rc.service.rug.nl
%Version June 1996
\newif\ifdraft\drafttrue
\draftfalse
\ifdraft\else\input psfig \fi
%Watch out for double ! in verbatim, especially  with %!!PS
\input blue.tex  \loadtocmacros\tolerance500\hbadness=499\hfuzz=5pt
                 \parindent=1pc\everyverbatim{\unmc}
%Needed EPS files: baker.eps, barnwindowii.eps, bentley.eps,
%                  eschera.eps, escherb.eps, escherknotmf.eps,
%                  escherknotiii.epsabr, flower.eps, 
%                  gurariabc.eps, gurarisq.eps
%                  jvr.eps, linebundle.eps, malbork.eps, 
%                  polygon.eps, polygonii.eps, prpie.eps, 
%                  sine.eps, sinedisks.eps, seal.eps, 
%                  textalongarc.eps, textalongspiral.eps.

\bluetitle Paradigms: Just a little bit of PostScript

\blueissue \maps{96}2

\bluepictures\metapostpic\pstexpic

\blueabstract It is all about creating EPS\Dash with graphics\Dash
   to be merged with \AllTeX{} scripts.
   The emphasis is on creating raw PostScript for simple symmetrical pictures.
   Asides, like 
     incorporating accurate graphs of math functions,
     typesetting text along curved paths, or 
     tables set sideways have been addressed.
   A poor man's mftoeps approach is touched upon:
   (declarative) METAFONT into (imperative) PostScript.

\bluekeywords Declarative program, education, EPS, Escher, graphics, 
    imperative code, \AllTeX, 
    math graphs, METAFONT, merging EPS and \AllTeX, 
    MetaPost, mftoeps, PostScript,
    sideways tables,  text along curved paths.          

\beginscript

\bluehead BLUe's Design X

Hi folks. 
The user's guide which comes with BLUe's format system\Dash 
Publishing with \TeX, PWT for short\Dash
is processed {\em completely\/} by \TeX, {\em no\/} other tools such as
\PS{} are needed.\ftn{Nobody knows what the future has in store, but for
   the moment I consider it a good thing that the PWT guide can be processed 
   just by \TeX, well \dots with BLUe's format.}
However, of late I exercised \MF
\Dash well, eventually MetaPost with the help of Jos Winnink\Dash
for graphics to be included in \TeX{} documents, and finally embarked PostScript 
straightaway to create EPS pictures.

$$\metapostpic$$

\PS{} is involuntary needed to (electronically) paste up the graphics, and 
as resulting file format.\ftn{For exchange the {\tt.tex} and 
   (hand-coded) {\tt.eps} files are much better suited
   because of their conciseness. This can't be beaten, not even by 
   Adobe's PDF\Dash Portable Document Format.}

If we come to think of graphics as  
$$\vbox{\hbox{just doing the `right' strokes or fills}}$$
then \PS{} provides the means for this: 
   lines, splines and circular arcs,
to be drawn or filled.\ftn{PostScript II also provides for colors and 
   processing in a network.}
I use the sidestep 
$$\vbox{\hbox{\MF{} $\rightarrow $MetaPost $\rightarrow$ EPS}}$$
for general pictures but also for obtaining the right (control) points 
explicitly from a decalarative specification in \MF, 
as shown by Escher's knot at the end.\ftn{Another way 
   for arriving at the EPS code is 
   to use Jackowski's |mftoeps| package or to use MetaPost.}  

$$\pstexpic$$

With respect to graphics \PS{} can be seen as a {\em little\/} language
in the UNIX tradition.\ftn{See Bentley's Little languages in
   `More programming pearls\Dash\-Confes\-sions from a coder.' Addison-Wesley.}
A little bit of \PS{} adheres the 80\%--20\% adage: 
80\% of the effects (or more) with
20\% of the energy (or less).

One can with a little knowledge of \PS{} code graphics immediately 
and {\em completely\/} in \PS. 
The more so because of the ubiquitous public domain GhostScript 
previewers to verify the result, 
next to of course the \PS{} laser printers.

Furthermore, text is just a special case of graphics, and merging 
just a little bit of  text\Dash malenki Russians would say\Dash
with the graphics goes equally simple at first glance.

And to end the lovesong the inclusion of accurate graphs of mathematical functions
goes well via coding these in \PS{} and including these as figures.
(Of course Hobby's graph extension could be used as well, or other advanced
 graphics packages.)
This is illustrated by a graph of the sine function to convey the idea.

PStricks is about {\em interfacing}. Not assuming knowledge of \PS.
This note discusses mainly {\em merging}. 
Is about extending your \TeX pertise 
with just a little\Dash tsjut-tsjut Russians would say\Dash 
knowledge of \PS{} rewarded by high returns. 

Below I'll summarize what is needed from \PS, and illustrate the use of it 
with a few examples, introducing en route the operators we need given the example.

\bluehead PostScript

\bluesubhead Processing

\PS{} comes with a user's guide (cookbook) and reference manual,
the so-called blue and red books in the Adobe \PS{} series.
For processing \PS{} an interpreter is needed, such as
a \PS{} laser printer or a GhostScript previewer. 
For inclusion in \AllTeX{} I use the psfig macros.\ftn{Courtesy Trevor J. Darrell.}
Goossens in his PostScript and \AllTeX, \maps{92}1, nicely details about
inclusion of PostScript.\ftn{See also the \LaTeX{} Companion.}

As with PDF I consider the post-processing capability {\em independently\/} from
the tool which created the \PS{} source, very powerful and flexible.

\bluesubhead Subset 0 from the language

\PS{} is stack-oriented. 
This means that operations are  prescribed in polish-reverse notation,
also known as prefix notation, 
similar to the HP pocket calculators.
Addition\Dash use of operator |add|\Dash for example is notated as follows. 

\beginverbatim
2 3 add%yields 5 on the stack, 2 3 consumed
!endverbatim 

\PS{} is artificially structured via structure information in
comments, double \%-ed comments. Programs which obey the Adobe
structure are called conforming and this is usually needed for inclusion 
within \AllTeX, especially the BoundingBox line is required.

\blueexample Conforming EPS structure

\beginverbatim
%!!PS EPS
%%Title: <name>
%%Creator: <name>
%%CreationData: <date>
%%BoundingBox: <llx> <lly> <urx> <ury>
%%DocumentFonts: (atend)
%%EndComments
<prolog>
%%EndProlog
%%Page: 0 1
<page 1>
%%Page: 1 2
<page 2>
%%Trailer
<...>
%%DocumentFonts: Times-Roman ...
%%Pages: 3
%%EOF
!endverbatim 

Creating and drawing paths is done by separate operators. 
For creating paths operations like
|moveto| are provided while drawing goes via |stroke|. 

\beginverbatim
0 0 moveto 0 10 lineto%create path 
stroke%draw a v-line of 10pt height
!endverbatim 

Variables\Dash names to be associated with their values\Dash
are handled via the so-called dictionaries. 
The functionality can also be obtained via procedures.

\beginverbatim
/size {10} def
!endverbatim 

The so-called literal name is preceded by a slash to distinguish the declaration 
from its invoke. The invoke is done by just the name, also called executable name.
The procedure text is surrounded by curly braces.
Parameters are absent too. The (operand) stack is used.

For graphics we have a CurrentTransformMatrix\Dash CTM\Dash which maps the
user space on the device space, the printer or screen.
Equally powerful is the concept of encapsulating graphics via
|gsave| and |grestore|, that is the graphics state is local\Dash encapsulated\Dash
after |gsave| until |grestore|.

Next to the CTM \PS{} maintains the currentpoint and currentpath.

Batagelj, \maps{95}1\Dash Combining \TeX{} and \PS\Dash 
provides an in a nutshell overview.\ftn
   {Nice are the hints to remove repeated parts from files which are
    generated by CorelDRAW and Mathematica, in order to reduce the size
    of the automatically generated and to be included files. 
   (The idea is to remove duplicate `dictionaries' which are included with each result.)
   The example of how to include graphs of math functions in a document is 
   {\em very\/} useful.
   However, with respect to his first picture I would prefer to use the 
   inherent symmetry in the data as opposed to providing all the data.}
Another introduction is in Fokker en van Oostrum's `Plaatjes in een tekst,'
\maps{94}2, next to a survey of drawing software.
\bluesubhead Summary of (graphics) commands

The following snapshot is borrowed from Gurari, well \dots a little modified.\ftn{%
   Gurari E.M (1994): 
   \TeX{} \& \LaTeX\Dash Drawing \& Literate Programming.
   McGraw Hill. ISBN 0-07-025208-4.}
Its main purpose is to show that the number of relevant graphics primitives
is low.
The functionalities will be dealt with along the way in the examples. 
For the details of the  commands or the list of operators
see the red book.\ftn{A complete list with functional summaries is 
   in the red book section 6.2 Operator summary.}

$$\everyverbatim{\emc}
\vbox{\halign{\hfil#\cr
\bf Arithmetic and math operators\hfill\cr
|<num>| |<num>| mul $num$ \cr
|<num>| sine $num$ \cr
%
\bf Path construction operators\hfill\cr
currentpoint  $x$ $y$  \cr
|<x>| |<y>| moveto     \cr 
|<dx>| |<dy>| rmoveto  \cr
|<x>| |<y>|lineto      \cr
|<dx>| |<dy>| rlineto  \cr
$\langle q_{1x}\rangle$ $\langle q_{1y}\rangle$ $\langle q_{2x}\rangle$ 
   $\langle q_{2y}\rangle$ $\langle p_{2x}\rangle$ $\langle p_{2y}\rangle$ 
   curveto \cr
$\langle c_x\rangle$ $\langle c_y\rangle$ $\langle r\rangle$ 
   $\langle ang_1\rangle$ $\langle ang_2\rangle$ arc \cr
%
\bf String operators\hfill\cr
|<string>| |<num>| |<num>| getinterval \cr
%
\bf Character and font operators\hfill\cr
{\tt\char92}|<fontname>| findfont \cr
          \ |<fontsize>| scalefont setfont \cr
|<string>| show                  \cr
|{<body>}| |<string>| kshow    \cr
%
\bf Graphics state operators\hfill\cr
|<num>| setgray               \cr
|<num>| setlinewidth          \cr
%
\bf Dictionary operators\hfill\cr
/|<defname> {<body>}| def        \cr
%
\bf Coordinate system and matrix operators\hfill\cr
|<num>| |<num>| translate \cr
|<num>| |<num>| scale     \cr
|<num>| rotate    \cr
%
\bf Relational, boolean, and bitwise operators\hfill\cr
|<num>|\||<string>| |<num>|\||<string>| le $bool$\cr
%
\bf Control operators\hfill\cr
|<bool> {<truepart>} {<falsepart>}| ifelse \cr
|<num> {<body>}| repeat        \cr
|<from> <step> <to>{<body>}| for \cr  }
}$$

With prefix
 $\langle in\rangle\> \langle operator\rangle\>\langle result\rangle$
is elegant.   

\bluesubhead What is not allowed as EPS?

I'm not knowledgeable enough to answer that question, nor do I know of
a full-blown definition of EPS. 
For the moment it is some subset which works with all interpretors,
with my subset 0 in there.
When one restricts oneself to the basics of graphics, arithmetic and similar 
operations then the boundary area between EPS and full \PS\Dash
or its various implementations\Dash is not in sight.

\bluesubhead Documentation

The red book\Dash the reference manual\Dash is generally recommended, though 
the blue book\Dash the tutorial and cookbook\Dash is also nice.\ftn{I used the 
   \PS I red book and this is well-suited to get the flavour. 
   For \TeX{} and METAFONT %\MF{} %font not available
   this is similar. To grasp the basic ideas
   Knuth's first book is a more concise survey of the main lines of thought than
   \TB{} and {\sl The METAFONTbook}.}

\blueexample Pie chart from the blue book

$$\ifdraft\vbox to3in{\vss\hbox{Pie chart}\vss}
\else\psfig{file=prpie.eps,height=3in}
\fi$$

The invoke is essentially as follows and shows that the codes can be used
straightforwardly.\ftn{It is not standard \PS. We have to construct some kind of
   library to use the PostScript programs from. 
   Maybe the CTAN as global network library?
   Copied on the various CD-ROMS?} 
It is no longer necessary to mesh around with the picture environment or so,
to achieve the effect.

\beginverbatim
%preliminary matter
(January Pie Sales) 
  24 12 %... array size
  [ [(Blueberry) .12 ]
    [(Cherry) .30 ]
    [(Apple) .26 ]
    [(Boston Cream) .16 ]
    [(Other) .04 ]
    [(Vanilla Cream) .12 ]
  ] 306 396%translate center to 
    140    %size
    DrawPieChart
showpage
!endverbatim

There is also a \PS-FAQ, consult

|ftp  wilma.cs.brown.edu:|\\
\null\qquad \qquad |pub/comp.lang.postscript|.

It contains an annotated bibliography as well.

The examples from Adobe's blue book are available on the net.

\bluesubhead  Proofing 

For previewing  or printing, {\em as such\/} 
I have to include a shift to move the picture away from the lower left corner, 
say

\beginverbatim
300 500 translate
!endverbatim

\bluesubhead Inclusion

I usually build a figure symmetrically around the origin and then include 
it via

\beginverbatim
$$\psfig{file=<name>,height=<number><unit>}$$
!endverbatim

A unit can be |in|(ch), |cm|, and ilks. \cs{psfig} is very vulnerable to 
 spaces because of \TeX's parsing. So no spaces in there.
Now and then I forget to inactivate the |translate| needed while previewing.
No real problem.  

\bluesubsubhead BoundingBox

Providing the right BoundingBox coordinates has all to do with
proper placement within context, the look-and-feel.
Default \PS{} assumes the origin\Dash in user space\Dash
at the lower left corner of the paper\Dash in device space.

Surround the picture by as-if lines and supply the coordinates, in points as units
in user space coordinates,
of the lower left corner and the upper right corner in the
BoundingBox specification.
Simple is to build a picture around its symmetry point\Dash
and let this coincide with the origin\Dash
with as pleasing result that the horizontal positioning comes out centered,
when used within math display.
Vertically, I add a 10 or so
extra on either side in the BoundingBox specification,
but that depends on the character of the picture.

Some preview systems can measure the BoundingBox and allow adjustment 
interactively.\ftn{For a summary of tools to assist finding the BoundingBox
   coordinates see, Reckdahl K (1995): Using EPS graphics in \LaTeX{}
   documents. reckdahl@leland.stanford.edu.}

\bluesubhead Writing PostScript

A line bundle and a variant of it are introduced to
show how to create simple EPS.

\bluesubsubhead  A line bundle

$$\ifdraft\vbox to1in{\vss\hbox{Line bundle}\vss}
\else\psfig{file=linebundle.eps,height=1in}
\fi$$

How to do this in \PS? A line as such is simple.
First a |moveto| and then a |lineto|. So a way is to create a loop and repeatedly
draw from the origin to the end of the various lines.
This can be done elegantly by using  appropriately the CTM.

\beginverbatim
%!!PS EPS
%%Title: Line bundle
%%Creator: cgl 
%%CreationDate: June 4 1996
%%BoundingBox: -40 -45 40 45  
%%Pages: 1
%%EndProlog
%%Page: 1 1
/r 36 def
10{0 0 moveto r 0 lineto 
   36 rotate
}repeat stroke showpage
!endverbatim

Explanation. 
The idea is that first a simple line is draw, for example along the x-axes.
What happens if after that we rotate? Right, the mapping is changed.
And what happens if we supply the {\em same\/} line after this?
Indeed, it will show up rotated. Because \PS{} is an interpretive
language we can realize this specification after the rotate via a loop,
which for this simple case reads |10{...}repeat|.\ftn{Do you see the variant
   for drawing a polygon? This duality linebundle and polygon has been used
   by Gabo and is about what he called stereometry versus perimetry, 
   the structure versus the surface}

\beginquote
Appropriately maintaining the CTM for symmetrical pictures can yield simple 
looking \PS{} programs.
\endquote

\bluesubsubhead  A flower

$$\ifdraft\vbox to1in{\vss\hbox{Flower}\vss}
\else\psfig{file=flower.eps,height=1in}
\fi$$

This exercises the use of |arc|.

\beginverbatim
%!!PS EPS
%%Title: Flower 
%%Creator: cgl (Courtesy Papert)
%%CreationDate: June 4 1996
%%BoundingBox: -40 -45 40 45 
%%Pages: 1
%%EndProlog
%%Page: 1 1
/r 36 def
10{r r moveto%begin drawing point  
   r 0 r 90 180 arc 
   currentpoint%origin
   0 r r 270 360 arc
   36 rotate
}repeat stroke showpage
!endverbatim

Explanation. 
We have the same structure as the previous program but the `line' is now
a little more elaborated: two arcs of a circle.
\PS{} provides an operator for drawing circular arcs, called arc.
The arc has $(x,y)$ as centre, r as radius, 
$ang_1$ the angle of a vector from $(x,y)$  of length $r$ 
to the first endpoint of the arc, and
$ang_2$ the angle of a vector from $(x,y)$ of length $r$ 
to the second endpoint of the arc.\ftn{The arc is drawn counter clockwise.
   |arcn| draws clockwise.} 
These arguments are expected to be on the stack.

\beginverbatim
x y r ang1 ang2 !bf arc
!endverbatim

Important is to realize that arc {\em counts\/} its angle from (x, 0) and that
the {\em drawing\/} starts from the point on the stack

The specification of the flower in \MF/\MP{} reads essentially as follows.

\beginverbatim
for k:= 1 upto 10: 
draw(origin{up}..{right}(up+right){down}..
    {left}origin) rotated 36k;
endfor
!endverbatim

Explanantion.
\MF{} allows for specification of the directions\ftn{There is also a 
  quartercircle which apart from orientation is drawn similarly.} 
$up =(0,1), right=(1,0)$.

IMHO, with all respect the \MF{} and \PS{} programs are similar 
modulo some syntactic sugar.
However, the extra possibility of specifying the directions is more convenient
than using control points.
But perhaps that is a matter of taste, although the handling of control points
is powerful as B\'ezier himself has shown in the past.
From this I conclude that for these simple kinds of pictures we can as well use
\PS{} straightaway. 

\bluehead Some more Graphics

\blueexample Malbork window

This is all about using |curveto|, especially choosing suitable control points.

$$\ifdraft\vbox to1in{\vss\hbox{Malbork window}\vss}
\else\psfig{file=malbork.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Malbork Window
%%Creator: cgl 
%%CreationDate: May 21 1996
%%BoundingBox: -40 -40 40 40 
%%Pages: 1
%%EndProlog
%%Page: 1 1
45 rotate 10 0 moveto
4{20 0 37.5 12.5 25 25 curveto
  12.5 37.5 0 20 0 10 curveto
 90 rotate
}repeat%inside lops next
5 0 moveto
4{5 35 35 5 0 5 curveto
  90 rotate
}repeat%enclosing circle next
36 0 moveto
0 0 36 0 360 arc
stroke showpage
!endverbatim 

Explanation. 
|translate| changes the CTM, 
with the effect that the device coordinates are shifted. (Useful for 
use of \PS{} alone out of context.)

|rotate| changes the CTM, and because of being an interpretive language
the various loop traversals map the {\em same\/} user coordinates on the
rotated device coordinates. 

$\langle number\rangle \{\dots\}$ |repeat| is a loop to be traversed 
$\langle number\rangle$ of times.

|curveto| adds a spline to the current path 
from the currentpoint to the last point on the stack. 
The first two points are the so-called control points of the spline.\ftn{Much similar
   as in METAFONT. Choosing for the inner lop the control
   points in this way is borrowed from 
    Haralambous Y (1995): Some METAFONT techniques. 
    \tubissue{16}(1), 46\dash53. It is also supplied in the description
    of |curveto| in the red book.}

|arc| adds a circular arc to the current path from the currentpoint.

The details of the arguments for the operators are nicely documented in the
red book.

\blueexample Escher's impossible triangle

This is all about {\em wrong\/} projections.
However, these kinds of pictures are intriguing and fun.
I consider them well-suited to illustrate \PS's drawing capabilities.

$$\ifdraft\vbox to1in{\vss\hbox{Escher's impossible triangle}\vss}
\else\psfig{file=eschera.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Escher's impossible triangle
%%Creator: cgl (inspired  by Guy Shaw)
%%CreationDate:  May 23 1996
%%BoundingBox: -40 -40 40 40
%%Pages: 1
%%EndProlog
%%Page: 1 1
3{25  34 moveto
  25 -34 lineto
  17 -38.2 lineto 
  17 20 lineto
 -17.6 0 lineto
120 rotate
}repeat stroke showpage
!endverbatim 

\on5{} points, the right stroke and a rotation or two, that's it. 
End of story.

However, it is all about finding those \on5{} points.

$$\ifdraft\vbox to1in{\vss\hbox{the 5 points}\vss}
\else\psfig{file=escherb.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Essential stroke
%%Creator: cgl (inspired  by Guy Shaw)
%%CreationDate: May 23 1996
%%BoundingBox: -40 -40 40 40
%%Pages: 1
%%EndProlog
%%Page: 0 1
25  34 moveto currentpoint
0  -68 rlineto currentpoint%down
  -120 rotate 
25  34 lineto%preserve symmetry 
   120 rotate currentpoint  
17  20 lineto currentpoint
-17.6 0 lineto currentpoint
%labels
/Courier findfont 8 scalefont setfont
moveto -5 -3 rmoveto (5) show 
moveto 1 1 rmoveto (4) show 
moveto 2 -5 rmoveto (3) show 
moveto 2 0 rmoveto (2) show 
moveto 2 0 rmoveto (1) show 
stroke showpage
!endverbatim

Explanation.
The essential stroke figure also illustrates the integration 
of text in this case digits.
|currentpoint| pushes the point on the stack.
The last |moveto|-s pop these coordinates up.
|rmoveto| moves {\em relatively.}

\smallbreak
And what about their relationships, and 
what about the minimal information to be prescribed?

Looking more closely it turns out that {\em only\/} the first point is all 
that is needed. 
The rest is implicit to the nature of the figure.\ftn{Of course 
   one can also think of other equivalent parameters like size and thickness.}

\beginverbatim
%!!PS EPS
%%Title: Escher's Impossible triangle II
%%Creator: cgl 
%%CreationDate: May 23 1996
%%BoundingBox: -40 -40 40 40
%%Pages: 1
%%EndProlog
%%Page: 1 1
%Parameterized over p1 
/point {25 34} def%note x<y
%
3{point moveto 
currentpoint neg lineto%down
  -120 rotate 
point  lineto%preserve symmetry 
   120 rotate 
currentpoint 2 div neg lineto 
currentpoint 3 sqrt mul sub 0 lineto
120 rotate
}repeat stroke showpage
!endverbatim 

Explanation. 
|currentpoint| yields the coordinates of the current point of the path on the stack.
The other operations do what their names suggest.
The temporarily change of the CTM within the loop expresses the
rotation symmetry relation between points \on1{} and \on3.

\blueexample Bentley's polygon

This code is all about a double loop and using the loop variable from the stack,
next to using the |gsave| and |grestore| advantageously.

$$\ifdraft\vbox to1in{\vss\hbox{Bentley's polygon}\vss}
\else\psfig{file=bentley.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Bentley's double loop
%%Creator: cgl 
%%CreationDate: May 30 1996
%%BoundingBox: -100 -105  100 105
%%EndProlog
10{1 1 9{100 0 moveto
         gsave
         36 mul rotate%loopcount*36
         100 0 lineto stroke
         grestore
   } for
   36 rotate
}repeat showpage
!endverbatim

Explanantion. 
|gsave| and |grestore| are needed to draw locally, that is at the end
the graphics state\Dash currentpoint, currentpath and CTM\Dash
is restored with the values at the beginning.
\on1{} \on1{} \on9{} stand for beginvalue step and endvalue of the |for| counter.

\blueexample Another double loop

A set of nested polygons provide also a double loop situation.

$$\ifdraft\vbox to1in{\vss\hbox{Polygons}\vss}
\else\psfig{file=polygon.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS Nested pentagons
%%Title: Pentagons  
%%Creator: cgl 
%%CreationDate: June 17 1996
%%BoundingBox: -100 -100 100 100
%%Pages: 1
%%EndProlog
%%Page: 1 1
10 10 100{dup 0 moveto
   5{72 rotate
     dup 0 lineto
     }repeat
}for stroke showpage
!endverbatim

\blueexample Polygons with splines as sides

This generalization of polygons was introduced by Jackowski at Euro\TeX{} \on95.
A special case of \MF's interpath functionality is shown en-passant. 

$$\ifdraft\vbox to1in{\vss\hbox{flexess}\vss}
\else\psfig{file=polygonii.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS Nested `squares'
%%Title: polygon.eps II 
%%Creator: cgl 
%%CreationDate: June 17 1996
%%BoundingBox: -100 -100 100 100
%%Pages: 1
%%EndProlog
%%Page: 1 1
/r 100 def
/r1 {r .25 mul} def
/r3 {r .75 mul} def
25{r 0 moveto 
   4{r3 r3 r1 r1 0 r curveto
     90 rotate
     }repeat
   .9 .9 scale
}repeat stroke showpage
!endverbatim
 
\blueexample Barn window

This is all about playing with circles and circular arcs.\ftn{The first example
   in the blue book collection provides a similar picture with gradually
   changing scales of grey.}

$$\ifdraft\vbox to1in{\vss\hbox{Barn window}\vss}
\else\psfig{file=barnwindowii.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Barn Window II
%%Creator: cgl 
%%CreationDate: May 29 1996
%%BoundingBox: -45 -45 45 45 
%%Pages: 1
%%EndProlog
%%Page: 1 1
/l 36 def 
/r {l 22.5 sin mul} def
/m {l 22.5 cos mul} def
8{r .5 mul 0  moveto
  l 0 lineto 
  currentpoint   %begin circular arc 
  22.5 rotate m 0%center
  r              %radius
  -90 90 arc
  22.5 rotate 
}repeat
%inner circle
/rin {r .5 mul} def
rin 0  moveto
0 0 rin 0 360 arc
%outer circle
/rout {r m add} def
rout 0  moveto
0 0 rout 0 360 arc
%extra circles
/rin {r .25 mul} def
22.5 rotate
8{m rin add 0 moveto
  m 0 rin 0 360 arc
  45 rotate
}repeat stroke showpage
!endverbatim

I'm sure I'll come back some day and look again through this window, 
but then pastel colored.

\blueexample Baker's inspiration

$$\ifdraft\vbox to1in{\vss\hbox{Woody Baker's picture}\vss}
\else\psfig{file=baker.eps,height=1in}
\fi$$

This example is similar to Escher's impossible triangle.
Find the essential stroke and rotate.

\beginverbatim
%!!PS EPS
%%Creator: cgl (inspired  by Woody Baker)
%%CreationDate: May 1996
%%BoundingBox: -80 -80 80 80 
%%Pages: 1
%%EndProlog
%%Page: 1 1
4{-15 25 moveto
    0 -10 rlineto
   60 0 rlineto
    0 -30 rlineto
   10 0 rlineto
    0 40 rlineto
  -70 0 rlineto
    0 10 rlineto
   80 0 rlineto
    0 -60 rlineto
  -30 0 rlineto
    0 10 rlineto
   10 0 rlineto
%
   35 -25 moveto
    0 -10 rlineto
   20 0 rlineto
   10 10 rlineto
%
   45 15 moveto
   10 10 rlineto
90 rotate
}repeat stroke 
%
/Courier findfont 10 scalefont setfont
-55 -75 moveto
(Courtesy Woody Baker)show
showpage
!endverbatim

\blueexample Romanovsky's real Escher

$$\ifdraft\vbox to1in{\vss\hbox{JVR's picture}\vss}
\else\psfig{file=jvr.eps,height=1in}
\fi$$

Grey scales can be obtained simply via $\langle number\rangle$ |setgray|,
with $\langle number\rangle \in [0, 1]$.
0 denotes black and 1 is white.
The idea is to construct the essential path\Dash 
         the stroke denoted by a grey scale\Dash
and to use this \on3{} times.

\bluehead Math graphs

In \AllTeX{} documents it is a problem\ftn{Communicated by Nico Temme. 
   He solved the problem by doing the calculations in PASCAL.
   For advanced manipulations Mathematica or Mapple
   are generally used where the resulting EPS is pasted up in the
   \AllTeX{} script as usual.}
how to include accurate graphs of mathematical functions.
Because of \PS's arithmetic and graphics capabilities it is
handy to use \PS.

\blueexample Sine function

$$\ifdraft\vbox to1in{\vss\hbox{sine function}\vss}
\else\psfig{file=sine.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Sine function
%%Creator: cgl (inspired  by Batagelj)
%%CreationDate: May 27 1996
%%BoundingBox: -200 -110  200 110
%%EndProlog
/Courier findfont 15 scalefont setfont
%figure scaled by 100
%x-axes and label
-200 0 moveto 200 0 lineto
-15 -15 rmoveto (x) show
%y-axes and label
0 -110 moveto 0 110 lineto
-35 -10 rmoveto (sin) show
%function
-180 0 moveto
-180 10 180{%from step to
   dup sin 100 mul%(x, 100sin x)
   lineto
}for stroke showpage
!endverbatim

The invoke might read as follows.

\beginverbatim
$$\psfig{file=sine.eps,height=1in}$$
!endverbatim

\bluehead Text set along curved paths

A teaser. With the advent of scalable and rotationable outline fonts
this is possible too.

\blueexample Along a circle 

$$\ifdraft \vbox to 1in{\vss\hbox{text along an arc}\vss}
\else \psfig{file=textalongarc.eps,height=1in}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Typesetting along arcs
%%Creator: cgl 
%%CreationDate: June 4 1996
%%BoundingBox: -100 50 100 125 
%%Pages: 1
%%EndProlog
%%Page: 1 1
/Courier findfont 10 scalefont setfont
/text (happybirthday) def
50 rotate
0 1 12{0 100 moveto
  text exch 1 getinterval show
  -10 rotate
}for stroke showpage
!endverbatim

Joseph Romanovsky communicated that |kshow|\Dash kerning (and more general
positioning) under user control\Dash 
is available which allows a general
def to be executed between two characters of a string.

\blueexample Along a spiral

The blue book provides an example of typesetting along a path\Dash 
   a quotation of Woody Allen\Dash
where the path accentuates his filmmaker profession.
The example below shows a nice effect with little knowledge of \PS, 
essentially the use of |kshow|.

$$\ifdraft \vbox to 2in{\vss\hbox{text along spiral}\vss}
\else \psfig{file=textalongspiral.eps}
\fi$$

\beginverbatim
%!!PS EPS
%%Title: Text along spiral
%%Creator: J.V. Romanovsky
%%BoundingBox: -100 -90 60 70
%%EndProlog
/Courier findfont 20 scalefont setfont
-100 0 moveto 50 rotate
{-10 rotate 3 0 rmoveto .98 .98 scale}
 (Olga Grineva my charming 
  St Peterburg hostess)kshow
showpage
!endverbatim

\blueexample Seals

The problem has been discussed by Hoenig at Euro\TeX{} \on92,
and Zlatu\v{s}ka at Euro\TeX{} \on95, both biased by \MF.
\PS{} alone is suited too with an overall simpler process.
Combining two earlier supplied examples yields Zlatu\v{s}ka's seal 
in principle.\ftn{The blue book also provides a seal\Dash 
Symphony No.\on9\Dash
   but that is more complex and ipso facto requires more knowledge of \PS{} 
   to understand what is going on, IMHO, with all respect.
   To set this poster  from the blue book is no more difficult than the 
   use of |arc|, however. My example gives you the feeling that you
   understand what is going on, I hope.}

\beginverbatim
%!!PS EPS
%%Title: Seal, in principle
%%Creator: cgl 
%%CreationDate: June 6 1996
%%BoundingBox: -110 -45 110 100 
%%Pages: 1
%%EndProlog
%%Page: 1 1
%150 650 translate
/Courier findfont 10 scalefont setfont
/text (happy postscripting to you) def
/r 100 def
gsave
   90 rotate %begin orientation 
   0 r moveto%begin point 
{-7.04 rotate 0 r moveto} text kshow
grestore%next the central Escher
3{25  34 moveto
  25 -34 lineto
  17 -38.2 lineto 
  17 20 lineto
 -17.6 0 lineto
120 rotate
}repeat stroke showpage
!endverbatim

$$\ifdraft \vbox to 1.5in{\vss\hbox{seal}\vss}
\else \psfig{file=seal.eps,height=1.5in}
\fi$$

Remark. The difference of fonts in the main text and that used by \PS{}
        is no longer there when \PS{} fonts are used throughout, be it
        the \PS{} version of the CM family.

\blueexample Gurari's squares

$$\ifdraft \vbox to 1in{\vss\hbox{Gurari's squares}\vss}
  \else \psfig{file=gurarisq.eps,height=1in}
  \fi$$

\beginverbatim
%!!PS Gurari squares
%%BoundingBox: -200 -110  200 110
%%Creator: cgl
%%CreationDate: June 20 1996
%%EndProlog
/r 22 def
/square {1 1 4{0 r rlineto
         90 rotate}for} def
0 0 moveto 90 rotate
50{r 0 rmoveto square
   -30 rotate .9 .9 scale
}repeat stroke showpage
!endverbatim

\blueexample Gurari's ABC

Very nice this suggestion of motion. 

$$\ifdraft \vbox to 1.5in{\vss\hbox{Gurari's speedy ABC}\vss}
  \else \psfig{file=gurariabc.eps,height=1.5in}
  \fi$$

\beginverbatim
%!PS EPS
%%Title: Guarai's ABC
%%BoundingBox: 0 -45  100 75
%%Creator: Gurari
%%CreationDate: copied June 17 1996 
%%Pages: 1
%%EndComments
%%EndProlog
%%Page: 1 1
/Times-Bold findfont 45 scalefont setfont
-40 rotate
1 -.03 0{setgray 
         0 0 moveto
         (ABC) show
         3 rotate
        } for
0 0 moveto -4 rotate 
1 setgray (ABC) show
showpage
!endverbatim

\blueexample Walking along the S-curve

In {\sl The METAFONTbook\/} ex\on13.\on10{} is about drawing overlapping
disks along a path, the S-figure.
How to do this in \PS{} straightaway?
There is no `point of' a path operator so the best we can attain is
to walk along a math function.

$$\ifdraft \vbox to 1in{\vss\hbox{S-figure}\vss}
  \else \psfig{file=sinedisks.eps,height=1in}
  \fi$$

\beginverbatim
%!PS Sine with overlapping disks
%%BoundingBox: -200 -110  200 110
%%Creator: cgl (METAFONTbook ex13.10)
%%CreationDate: June 17 1996
%%EndProlog
newpath
-180 10 180{dup sin 100 mul%(x, 100sin x)
    12.5 0 360 arc
    gsave 1 setgray fill grestore
    stroke
}for showpage
!endverbatim

Explanation. |1 setgray fill| is the erase functionality, encapsulated to 
yield what we want.

\bluehead Tables set sideways

Another teaser is to set tables rotated. 
Rokicki provided rotate macros along with his |dvips|, among others. 
I have borrowed the essence from his rotate macros
and recast into the following.

\beginverbatim
\def\rotate#1%stuff
           #2%degrees in PS direction
{\setbox\abox=\hbox{#1}%
 \adim\ht\abox\advance\adim by\dp\abox
 \hbox to\adim{\vbox to\wd\abox
 {\vskip\wd\abox
 \special{ps: gsave 
    currentpoint currentpoint translate 
    #2 neg rotate 
    neg exch neg exch translate}%
 \box\abox\vss}\hss}%
 \special{ps: currentpoint 
        grestore moveto}%
}%end rotate
!endverbatim

The point is that it is not much. 
The |ps:| is dependent on the system still, alas.

\blueexample Rotated table

The example works under UNIX with Rokicky's |dvips|.
%under UNIX
\newdimen\adim
\newbox\abox
%
\def\rotate#1%stuff
           #2%degrees in PS direction
{\setbox\abox=\hbox{#1}%
 \adim\ht\abox\advance\adim by\dp\abox
 \hbox to\adim{\vbox to\wd\abox{\vskip\wd\abox
 \special{ps: gsave currentpoint currentpoint 
    translate #2 neg rotate 
    neg exch neg exch translate}%
 \box\abox\vss}\hss}%
 \special{ps: currentpoint grestore moveto}%
}%end rotate

\begindemo
\def\data{1\cs2\rs 
          3\cs4 }
pre
\rotate{\framed
        \btable\data}
       {90}
post
!yields
\def\data{1\cs2\rs 3\cs4 }
pre
\rotate{\framed\btable\data}{90}
post
\enddemo

Remark.
Gurari (1994) has provided some more examples of \PS$\leftrightarrow$(Al)Dra\TeX{}
interaction. Real interfacing.
Apart from portability problems it gets quite complicated.
For the moment I refrain and code the `pictures' in raw \PS{}
assisted by \MF{} for prompting control points of those curves
which can be specified elegantly in a declarative way.

\bluehead METAFONT/MetaPost user interface

Sometimes it is more natural to specify points and {\em directions}.
It is true that specifying a control point along the direction
can yield the same effect but the distance between the point
and its control point influences the shape.

\blueexample Escher's knot

This example is all about specifying directions.

$$\ifdraft\vbox to1in{\vss\hbox{Escher knot II}\vss}
\else\psfig{file=escherknotmf.eps,height=1in}
\fi$$

In \MF{} the coding would read as follows.

\beginverbatim
%Escher's Knot. June 96. cgl@rc.service.rug.nl
def openit = openwindow currentwindow
   from origin to (screen_rows,screen_cols) 
   at (-2r,3r)enddef;
pickup pencircle scaled 1;
tracingstats:=proofing:=1; screenstrokes;
pair p[];
%parameters
r:=100; alfa=90;
%
p2:=(0,.85r); %independent from p1,3,4
p4:=(0,-.5r);
%dependent points because of symmetry
p1:=p4 rotated -120;
p3:=p4 rotated  120;
path q;
q=p1{dir alfa}..{(1,0)}p2..
    {dir(-alfa)}p3..{dir(alfa-240)}p4;
draw q; 
draw q rotated 120;  
draw q rotated-120;
showit;
end
!endverbatim

By the nature of the figure not only  points are related but 
also their directions. 
How to cope with this in \PS?
It can be done but is not so elegant, honestly speaking cumbersome. 
But \dots there is a solution or two, hang on.

\beginverbatim
%!!PS EPS
%%Title: Escher knot II
%%Creator: cgl (inspired  by Knotplot)
%%CreationDate: June 1996
%%BoundingBox: -95 -95 95 95 
%%Pages: 1
%%EndProlog
%%Page: 1 1
%
/angle 90 def
/r 100 def
/point {0 -.5 r mul}def
/p1 {-.25 r mul 3 sqrt mul  .25 r mul moveto
     currentpoint
     angle sin 2 mul add exch 
     angle cos 2 mul add exch
     -20 .85 r mul
     0 .85 r mul 
     curveto stroke} def
/p3 { .25 r mul 3 sqrt mul  .25 r mul moveto
     %Control point
     currentpoint
     angle sin -15 mul add  exch 
     angle cos  15 mul add  exch
     %Control point: 
     % 58.62 -.5 r mul 5 add%angle 90
     0          angle -240 add cos -15 mul add
      -.5 r mul angle -240 add sin -15 mul add  
     0 -.5 r mul 
     curveto stroke} def
3{p1
  gsave -1 1 scale p1 grestore%reflect
  p3
  120 rotate
}repeat showpage
!endverbatim

Explanation.
The essential curve is split into \on3{} pieces: p$_1$,\dots p$_3$. 
The first two are related by reflection.
The third must properly match. In the Columbus's egg paragraph 
the straight |.eps| code is given,
biased by the knowledge of the (control) points.

\bluesubhead A teaser

More complicated is when the line is changed into a tube, and 
when we have to deal with hidden lines.
In \MF{} the code could read as follows, where use is made of
|intersectiontimes| and of subpaths.\ftn{This code works as such on my Mac
   with Bluesky's PD METAFONT. For other environments build a character
   from it, or adapt it for use in MetaPost, or even simpler copy the 
   bread-and-butter EPS code which is appended at the end.}

\blueexample Escher's knot III

This example is all about getting from a {\em declarative\/} specification 
in \MF{} to a {\em imperative\/} EPS code.

$$\ifdraft\vbox to1in{\vss\hbox{Escher knot III}\vss}
\else\psfig{file=escherknotiii.epsabr,height=1in}
\fi$$

First the declarative \MF{} code.
\beginverbatim
%Escher Knot III. June 96. cgl@rc.service.rug.nl
def openit = openwindow currentwindow
   from origin to (screen_rows,screen_cols) 
   at (-2r,3r)enddef;
pickup pencircle scaled 1;
tracingstats:=proofing:=1; screenstrokes;
numeric t, u, v, w;
pair p[]; path q[];
def assignpoints=
 p2:=(0,.85r); %independent from p1,3,4
 p4:=(0,-.5r);
 %dependent points because of symmetry
 p1:=p4 rotated -120;
 p3:=p4 rotated  120;
enddef;
%
alfa=90;r:=100;  assignpoints;
q1:=p1{dir alfa}..{(1,0)}p2..
    {dir(-alfa)}p3..{dir(alfa-240)}p4;
%inside
        r:=.75r; assignpoints;
q2:=p1{dir alfa}..{(1,0)}p2..
 {dir(-alfa)}p3..{dir(alfa-240)}p4;
(t,u)= subpath (2.5,3) of q1 
   intersectiontimes (q2 rotated -120);
(v,w)= q2 intersectiontimes 
                      (q1 rotated 120);
%showvariable t,u;
draw subpath (0,2.5 + t/2) of q1; 
draw subpath (0,2.5 + t/2) of q1
                           rotated 120;  
draw subpath (0,2.5 + t/2) of q1 
                           rotated-120;
%showvariable v,w;
draw subpath (v,3) of q2; 
draw subpath (v,3) of q2 rotated 120; 
draw subpath (v,3) of q2 rotated-120;
showit;
end
!endverbatim

To give the reader an impression of what \MP{} will yield
|escherknotIII.eps|, the imperative code, is included.\ftn{A white lie. I have edited the file
  and reduced the data\Dash and deleted  
  |dtransform|, |idtransform| and the various |set...|\Dash 
  for the \on6{} strokes into only \on2{} and rotated these. 
  METAFONT allowed me to declaratively specify the picture while
  MetaPost provided me with the essential path data.
  Well\dots even METAFONT can be asked to provide those (control) points.}

\beginverbatim
%!!PS EPS
%%BoundingBox: -40 -31 40 43 
%%Creator: MetaPost and JJW, CGL
%%CreationDate: June 17 1996
%%Pages: 1
%%EndProlog
%%Page: 1 1
3{-21.6507 12.5 moveto
-21.6507 27.74551 -13.78212 42.5003
    0 42.5003 curveto
13.78212 42.5003 21.6507 27.74551 
   21.6507 12.5 curveto
21.6507 -0.24506 16.04897 -12.19249 
   6.58395 -20.3313 curveto 
% 
-14.3152 15.86746 moveto
-12.43301 23.58928 -7.45113 29.75021 
   0 29.75021 curveto
9.64748 29.75021 15.15549 19.42186 
   15.15549 8.75 curveto
15.15549 -2.07904 9.37823 -12.08548 
   0 -17.5 curveto 
120 rotate
}repeat stroke showpage
!endverbatim

As can be seen from the last code it is all about finding the right
(control) points and draw the strokes, as remarked at the beginning of this note. 
The difference between the declarative \MF{} specification and 
the resulting (unedited) \MP{} code is striking.
When the last code is shown first one would say, ah\dots \PS{}
is easy just data and some strokes.
The resulting code is equivalent to Woody Baker's code: 
just the right stroke and a rotation or two.

KnotPlot on the net provides a more complicated version where 
the light reflection is emulated by shades of grey. 
The gzipped file is \on64KB, however.
A world of difference.

\bluesubhead Columbus' egg

Why not use \MF{} to create `the (control) points' from the descriptive picture
and use these in raw \PS{} straightaway?

After assigning 
|precontrol|-s and |postcontrol|-s to pairs and 
inserting |show|-s, \MF{} yielded for the simple Escher knot the data
in the transcript file.
A little editing of this log file resulted in the following 
imperative EPS code.

\beginverbatim
%!!PS EPS
%%Title: Escher knot (mf prompted)
%%Creator: cgl 
%%CreationDate: June 1996
%%BoundingBox: -80 -80 80 80 
%%Pages: 1
%%EndProlog
%%Page: 1 1
3{-43.30139 25 moveto 
 -43.30139 55.49103 -27.56424 85.00061 
  0 85.00061 curveto 
  27.56424 85.00061 43.30139 55.49103 
  43.30139 25 curveto 
  43.30139 -5.94014 26.79497 -34.5299  
  0 -50 curveto 
120 rotate
}repeat stroke showpage
!endverbatim

I presume the functionality is similar to Jackowski's |mftoeps|.
The above method is my Poor Man's \MF2EPS, with concise, very concise 
and intelligible EPS as result.  

\bluehead Acknowledgements

First of all Don Knuth and John Hobby thank you.

Thank you Joseph Romanovsky for 
showing by example the power of \PS, and for
your cooperation on the \MF$\leftrightarrow$\PS{} duality. 

Thank you Bogus\l{}aw Jackowski for your `\PS{} for \TeX ies'
at Bacho\TeX{} \on96, suggesting that \PS{} as such is beneficial 
for \TeX ies, next to your mftoeps.

Thank you Eitan Gurari and anonymous \TeX ies of which I borrowed material, 
not in the least Adobe for providing \PS{} to start with.

Piet Tutelaers provided me with a copy of the PSFAQ, and 
Erik Frambach traced the file with examples from the blue book, next to KnotPlot.

As usual Jos Winnink proofed the paper and lend a helping hand in 
procrusting towards MAPS inclusion if not for processing |escherknot.mf|
into |escherknot.eps| via \MP.

\bluehead Conclusion

To code symmetrical and simple curves in raw \PS{} is fun and yields elegant
scripts and concise files.
To merge text with graphics is fun too, and the teaser to set along curved paths
can be done by \PS{} elegantly.
Another teaser of drawing math curves accurately along with \AllTeX{} is solved also
by means of \PS.
Powerful too is to {\em extend\/} the inclusion of .eps files
at the dvi level by a little more interaction between \AllTeX{} and \PS.
Rotating a box, with as applications for example 
typesetting tables in landcape, is possible in \PS, at the expense of system
dependency because of the \cs{special}-s.

{\em Merging\/} a little knowledge of \PS{} with \TeX pertise is powerful.
PStricks concentrates on {\em interfacing\/} \AllTeX{} with \PS{} at the expense 
of burdening \AllTeX{} too much, IMHO, with all respect.
For \cs{rotate} I interfaced too. However, for typesetting along curved
paths I would not think of interfacing via rotated boxes or so.

Of course, people who do need advanced features or have special wishes
might better use Adobe Illustrator, CorelDRAW, Mathematica, or Adobe Photoshop, 
and not to forget the pleasing MetaPost.

To understand and learn \TeX{} did take me a couple of years. 
To acqaint myself with \MF{} did cost me a few months. 
Learning just a little bit of \PS{} was a matter of weeks, and 
when concentrating
on paths and (control) points the |moveto|, |arc| and |curveto|
can be grasped in a late afternoon.

Although the blue book contains also examples of typesetting text,
I consider \TeX{} unsurpassed for this. The best of both worlds is to
combine \AllTeX{} and \PS. 

Maybe we should follow Adobe and extend the use of \PS{} by PDF\Dash
or use the alternative HTML\Dash to facilitate WWW surfing.
 
\bluehead What more?

For  pictures I use a \TeX{} controlled database with the beneficial side-effect
that I don't have to worry about file systems when using pictures 
(tools, references and ilks) on different machines. 
I would welcome a similar functionality for my collection of \PS{}
pictures to be used with \cs{psfig}.

A next step is the manipulation of colors either via \MP{} or \PS{} directly.
Jackowski uses Adobe Illustrator for example to enrich interactively
the systematic EPS pictures created by \MF. 
Indeed interesting, very interesting,
but beyond my possibilities for some time to come.
Neither do I have access to color \PS{} printers as yet, alas.
My case rests.

Have fun, and all the best. 
\makesignature
\pasteuptoc
\endscript