summaryrefslogtreecommitdiff
path: root/dviware/dvi-augsburg/manual/texfish.ps
blob: bd2da3953c803dfe7dcad5173ffc77eb8565a5f8 (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
%!
%%BoundingBox: -0.125903 -0.125882 252.126 252.126
%  The following are all the functions required to produce the famous
%  "Square Limit" drawing by M. C. Escher. These functions were derived by
%  Peter Henderson. See his paper in 1982 Conf. on LISP and Func. Prog.
%  (C) Miranda coding by Michael Parsons, September 1985
%  Translation to PostScript by Peter Bumbulis, July 1986
%

%  quartet combines 4 images, one image in each quadrant, to produce one image.
/quartet {
  4 -1 roll 1 2 div   0   1 zoom
  4 -1 roll 1 2 div   1   1 zoom
  4 -1 roll 1 2 div   0   0 zoom
  4 -1 roll 1 2 div   1   0 zoom
  4 {exec} /repeat cvx
  7 array astore cvx
} def

%  nonet arranges 9 images in equal sized squares to form 1 image.
/nonet {
  9 -1 roll 1 3 div   0   1 zoom
  9 -1 roll 1 3 div 0.5   1 zoom
  9 -1 roll 1 3 div   1   1 zoom
  9 -1 roll 1 3 div   0 0.5 zoom
  9 -1 roll 1 3 div 0.5 0.5 zoom
  9 -1 roll 1 3 div   1 0.5 zoom
  9 -1 roll 1 3 div   0   0 zoom
  9 -1 roll 1 3 div 0.5   0 zoom
  9 -1 roll 1 3 div   1   0 zoom
  9 {exec} /repeat cvx
  12 array astore cvx
} def

%  cycle combines 4 smaller copies of an image, each rotated by a different
%  multiple of 90 degrees.
/cycle {dup 270 rot dup 180 rot dup  90 rot quartet} def

%  t is one of the basic fish rearrangements.
/t {{p} {q} {r} {s} quartet} def

%  u is another of the basic fish rearrangements.
/u {{q} 90 rot cycle} def

%  side defines one side of the picture at level n.
/side {
  dup 0 le
    {  pop   {} dup t 90 rot t quartet}
    {1 sub side dup t 90 rot t quartet}
  ifelse
} def

%  corner defines one corner of the picture at level n.
/corner {
  dup 0 le
    {  pop         {}        {}         {} u quartet}
    {1 sub dup corner exch side dup 90 rot u quartet}
  ifelse
} def

%  quadcorner forms one quarter of the image at level n;
/quadcorner {
  dup corner exch side dup dup 90 rot dup u exch t 90 rot dup 3 1 roll
  {q} 90 rot nonet
} def

%  squarelimit produces the fish drawing.
/squarelimit {quadcorner cycle} def

%  fish gives a border to produce the final drawing.
/fish {
  squarelimit exec
  newpath
  0 0 moveto
  0 1 lineto
  1 1 lineto
  1 0 lineto
  closepath
  stroke
} def

/flip {0.5 0.5 translate 1 -1 scale -0.5 -0.5 translate} def

%  All the data needed to draw the fish.
/p {
    gsave flip
    newpath
    0 0.8125 moveto 0 0.5 lineto
    0 0.8125 moveto 0.1875 0.75 lineto
    0.75 0 moveto 0.8125 6.25e-2 lineto
    0.1875 0.75 moveto 0 0.5 lineto
    0.375 1 moveto 0.25 0.75 lineto
    0.25 0.6875 moveto 0.4375 0.625 lineto
    0.25 0.6875 moveto 0.25 0.375 lineto
    0.4375 0.625 moveto 0.25 0.375 lineto
    0.6875 1 moveto 0.625 0.75 lineto
    0.6875 1 moveto 0.875 0.875 lineto
    0.875 0.875 moveto 1 0.875 lineto
    0.625 0.75 moveto 0.8125 0.6875 lineto
    0.8125 0.6875 moveto 1 0.75 lineto
    0.625 0.75 moveto 0.5 0.5 lineto
    0.5625 0.625 moveto 0.75 0.5625 lineto
    0.75 0.5625 moveto 1 0.625 lineto
    0.5 0.5 moveto 0.75 0.4375 lineto
    0.75 0.4375 moveto 1 0.5 lineto
    0.5 0.5 moveto 0.25 0.1875 lineto
    0.25 0.1875 moveto 0 0 lineto
    0.5 0.25 moveto 1 0.375 lineto
    1 0.25 moveto 0.75 0.25 lineto
    0.75 0.25 moveto 0.5 0 lineto
    0.5 0 moveto 0.375 6.25e-2 lineto
    0.375 6.25e-2 moveto 0 0 lineto
    0.625 0 moveto 0.75 0.125 lineto
    0.75 0.125 moveto 1 0.1875 lineto
    1 0.125 moveto 0.8125 6.25e-2 lineto
    1 6.25e-2 moveto 0.875 0 lineto
    stroke
    grestore
} def

/q {
    gsave flip
    newpath
    0 0 moveto 0 0.25 lineto
    0 0.5 moveto 0 1 lineto
    0 1 moveto 0.5 1 lineto
    0.75 1 moveto 1 1 lineto
    0.125 1 moveto 0.25 0.6875 lineto
    0.25 1 moveto 0.375 0.6875 lineto
    0.375 1 moveto 0.5 0.6875 lineto
    0.5 1 moveto 0.625 0.625 lineto
    0.25 0.6875 moveto 0.25 0.5625 lineto
    0.375 0.6875 moveto 0.375 0.5625 lineto
    0.5 0.6875 moveto 0.5 0.5 lineto
    0.625 0.625 moveto 0.625 0.4375 lineto
    0.625 1 moveto 0.875 0.3125 lineto
    0.75 1 moveto 0.8125 0.75 lineto
    0.8125 1 moveto 1 0.625 lineto
    0.875 1 moveto 1 0.75 lineto
    0.9375 1 moveto 1 0.875 lineto
    0 0.25 moveto 0.1875 0.1875 lineto
    0 0.375 moveto 0.4375 0.3125 lineto
    0 0.5 moveto 0.25 0.5625 lineto
    0.125 0 moveto 0.1875 0.1875 lineto
    0.1875 0.1875 moveto 0.3125 0.125 lineto
    0.3125 0.125 moveto 0.25 0 lineto
    0.3125 0.125 moveto 0.4375 6.25e-2 lineto
    0.4375 6.25e-2 moveto 0.5 0 lineto
    0.5 6.25e-2 moveto 0.6875 6.25e-2 lineto
    0.6875 6.25e-2 moveto 0.5625 0.1875 lineto
    0.5625 0.1875 moveto 0.5 6.25e-2 lineto
    0.5625 0.25 moveto 0.75 0.25 lineto
    0.75 0.25 moveto 0.625 0.375 lineto
    0.625 0.375 moveto 0.5625 0.25 lineto
    1 0 moveto 0.75 0.375 lineto
    0.375 0 moveto 0.4375 6.25e-2 lineto
    0.75 0.375 moveto 0.375 0.5625 lineto
    0.375 0.5625 moveto 0.25 0.5625 lineto
    1 0 moveto 0.9375 0.375 lineto
    0.9375 0.375 moveto 1 0.5 lineto
    1 0.5 moveto 0.8125 0.75 lineto
    stroke
    grestore
} def

/r {
    gsave flip
    newpath
    0.5 0.5 moveto 0.125 0.25 lineto
    0.125 0.25 moveto 0 0 lineto
    0 0.5 moveto 0.125 0.25 lineto
    0 0.25 moveto 6.25e-2 0.125 lineto
    0 1 moveto 0.5 0.5 lineto
    0 0.75 moveto 0.3125 0.375 lineto
    6.25e-2 0.9375 moveto 0.25 1 lineto
    0.125 0.875 moveto 0.5 1 lineto
    0.1875 0.8125 moveto 0.5 0.875 lineto
    0.3125 0.6875 moveto 0.75 0.8125 lineto
    0.5 0.875 moveto 0.75 1 lineto
    0.75 0.8125 moveto 1 1 lineto
    0.5 0.5 moveto 0.875 0.625 lineto
    1 0.625 moveto 0.6875 0.375 lineto
    0.6875 0.375 moveto 0.375 0 lineto
    1 0.5 moveto 0.75 0.25 lineto
    1 0.75 moveto 0.875 0.625 lineto
    0.75 0.25 moveto 0.6875 0 lineto
    0.75 0.25 moveto 1 0 lineto
    1 0.375 moveto 0.8125 0.1875 lineto
    1 0.25 moveto 0.875 0.125 lineto
    1 0.125 moveto 0.9375 6.25e-2 lineto
    stroke
    grestore
} def

/s {
    gsave flip
    newpath
    0 1 moveto 0.25 0.875 lineto
    0.125 0.9375 moveto 0 0.75 lineto
    0.25 0.875 moveto 0.5 0.875 lineto
    0.5 0.875 moveto 1 1 lineto
    1 1 moveto 0.625 0.75 lineto
    0.625 0.75 moveto 0.5 0.625 lineto
    0 0.625 moveto 0.4375 0.75 lineto
    0 0.5 moveto 0.5 0.625 lineto
    0 0.375 moveto 0.4375 0.5 lineto
    0 0.25 moveto 0.4375 0.375 lineto
    0 0.125 moveto 0.4375 0.1875 lineto
    0.5 0.625 moveto 0.4375 0.5 lineto
    0.4375 0.5 moveto 0.4375 0.1875 lineto
    0.4375 0.1875 moveto 0.5 0 lineto
    0.625 0 moveto 0.6875 0.375 lineto
    0.75 0 moveto 0.8125 0.1875 lineto
    0.8125 0.1875 moveto 0.9375 0.4375 lineto
    0.9375 0.4375 moveto 1 0.5 lineto
    1 0.125 moveto 0.8125 0.1875 lineto
    1 0.25 moveto 0.875 0.3125 lineto
    1 0.375 moveto 0.9375 0.4375 lineto
    0.75 0.5625 moveto 0.75 0.75 lineto
    0.75 0.75 moveto 0.625 0.625 lineto
    0.625 0.625 moveto 0.75 0.5625 lineto
    0.8125 0.5625 moveto 0.9375 0.5 lineto
    0.9375 0.5 moveto 0.9375 0.6875 lineto
    0.9375 0.6875 moveto 0.8125 0.5625 lineto
    stroke
    grestore
} def

%  rot rotates an image by th radians anti-clockwise, about the image centre.
/rotcode {gsave 0.5 0.5 translate rotate -0.5 -0.5 translate exec grestore} def

/rot { /rotcode cvx 3 array astore cvx } def

%  zoom scales an image up or down with one fixed point.
/zoomcode {
  gsave 2 copy neg exch neg exch 5 2 roll translate dup scale translate exec grestore
} def
/zoom { /zoomcode cvx 5 array astore cvx} def
 
/setup {36 7 mul dup scale .001 setlinewidth} def
 
%  display a level 1 fish
 
setup
1 fish