-
Notifications
You must be signed in to change notification settings - Fork 1
/
b.ps
606 lines (466 loc) · 13.5 KB
/
b.ps
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
%!PS-Adobe-2.0 EPSF-2.0
%%Title: Three shades of fish - a postscript on functional geometry
%%Creator: Einar W. Høst
%%Pages: 1
%%EndComments
%%BeginProlog
%%EndProlog
%%Page: 1 1
%%% DRAWING PROCEDURES
/draw-point { % x y
2 copy % x y x y
exch % x y y x
0.01 sub % x y y x-1
exch % x y x-1 y
0.01 sub % x y x-1 y-1
4 2 roll % x-1 y-1 x y
exch % x-1 y-1 y x
0.01 add % x-1 y-1 y x+1
exch % x-1 y-1 x+1 y
0.01 add % x-1 y-1 x+1 y+1
4 copy % x-1 y-1 x+1 y+1 x-1 y-1 x+1 y+1
3 1 roll % x-1 y-1 x+1 y+1 x-1 y+1 y-1 x+1
exch % x-1 y-1 x+1 y+1 x-1 y+1 x+1 y-1
moveto lineto
moveto lineto
} def
% Consumes: [ r g b ] color
% Produces:
% Side-effect: drawing.
/draw-birb { % color
newpath
% (draw-birb begin) ==
% (color) ==
% dup ==
0.000 0.000 moveto
% South side
0.134 0.093
0.237 0.128
0.396 0.137 curveto
0.420 0.013
0.447 -0.069
0.526 -0.168 curveto
0.630 -0.092
0.681 -0.021
0.679 0.132 curveto
0.818 0.128
0.901 0.086
1.000 0.000 curveto
% East side
1.072 0.224
1.015 0.374
0.877 0.476 curveto
0.801 0.481
0.699 0.385
0.623 0.390 curveto
0.485 0.492
0.428 0.642
0.500 0.866 curveto
% West side
0.376 0.823
0.298 0.772
0.225 0.654 curveto
0.359 0.579
0.395 0.500
0.408 0.372 curveto
0.283 0.353
0.199 0.370
0.079 0.411 curveto
0.008 0.269
-0.014 0.163
0.000 0.000 curveto
closepath
aload pop % r g b
gsave
setrgbcolor % oc % ic oc
fill
grestore
0 0 0 setrgbcolor
0.004 setlinewidth
stroke
% Lines
newpath
% BEAK
0.405 0.823 moveto
0.413 0.795
0.435 0.772
0.475 0.770 curveto
0.446 0.778 moveto
0.460 0.825
0.480 0.840
0.500 0.866 curveto
% WING LINES
% Line 1
0.098 0.316 moveto
0.072 0.220
0.060 0.150
0.068 0.047 curveto
% Line 2
0.155 0.300 moveto
0.140 0.228
0.132 0.160
0.137 0.080 curveto
% Line 3
0.215 0.289 moveto
0.205 0.228
0.198 0.170
0.203 0.105 curveto
% Line 4
0.276 0.282 moveto
0.270 0.230
0.262 0.170
0.268 0.123 curveto
% Line 5
0.337 0.276 moveto
0.330 0.230
0.328 0.175
0.332 0.132 curveto
% Line 6
0.400 0.279 moveto
0.392 0.230
0.392 0.180
0.396 0.137 curveto
%%%%%%
% Line 7
0.652 0.290 moveto
0.669 0.232
0.682 0.182
0.679 0.132 curveto
% Line 8
0.699 0.298 moveto
0.722 0.238
0.729 0.180
0.727 0.127 curveto
% Line 9
0.748 0.310 moveto
0.772 0.241
0.782 0.178
0.779 0.121 curveto
% Line 10
0.798 0.325 moveto
0.830 0.244
0.838 0.170
0.832 0.105 curveto
% Line 11
0.848 0.340 moveto
0.882 0.252
0.898 0.160
0.883 0.083 curveto
% Line 12
0.898 0.360 moveto
0.950 0.260
0.964 0.154
0.942 0.045 curveto
% HEAD
0.253 0.637 moveto
0.262 0.654
0.274 0.669
0.282 0.679 curveto
0.282 0.617 moveto
0.288 0.628
0.293 0.636
0.299 0.644 curveto
stroke
% Eye
newpath
0.367 0.753 0.01 0 360 arc
closepath
fill
0.004 setlinewidth
newpath
0.367 0.753 0.02 0 360 arc
closepath
stroke
% (end draw-birb) ==
} def
/step-point { % pos theta side
exch % pos side theta
3 -1 roll % side theta pos
aload pop % side theta x y
4 1 roll % y side theta x
2 index % y side theta x side
2 index % y side theta x side theta
cos mul add % y side theta x'
4 1 roll % x' y side theta
sin mul add % x' y'
2 array astore % pos'
} def
/cross-point { % pos theta side
dup % pos theta side side
4 1 roll % side pos theta side
1 index % side pos theta side theta
4 1 roll % side theta pos theta side
step-point % side theta pos'
exch % side pos' theta
60 add % side pos' theta'
3 -1 roll % pos' theta' side
step-point
} def
% Consumes: tx
% Produces: txw txe txn txm
/create-toxes { % tx
% (create-toxes begin) ==
% (original-tox) ==
% dup ==
aload pop % pos ang len
2 div % pos ang len'
3 array astore % txw
% (west-tox) ==
% dup ==
aload % pos ang len' txw
4 1 roll % txw pos ang len'
cross-point % txw ^pos
% (x-point) ==
% dup ==
% east
1 index % txw ^pos txw
aload pop % txw ^pos pos ang len'
3 -1 roll % txw ^pos ang len' pos
pop % txw ^pos ang len'
exch % txw ^pos len' ang
240 add 360 mod % txw ^pos len' ange
exch % txw ^pos ange len'
2 index % txw ^pos ange len' ^pos
3 1 roll % txw ^pos ^pos ange len'
3 array astore % txw ^pos txe
% (east-tox) ==
% dup ==
exch % txw txe ^pos
% north
2 index % txw txe ^pos txw
aload pop % txw txe ^pos pos ang len'
3 -1 roll % txw txe ^pos ang len' pos
pop % txw txe ^pos ang len'
exch % txw txe ^pos len' ang
120 add 360 mod % txw txe ^pos len' angn
exch % txw txe ^pos angn len'
2 index % txw txe ^pos angn len' ^pos
3 1 roll % txw txe ^pos ^pos angn len'
3 array astore % txw txe ^pos txn
exch % txw txe txn ^pos
% (north-tox) ==
% dup ==
% middle
3 index % txw txe txn ^pos txw
aload pop % txw txe txn ^pos pos ang len'
3 -1 roll % txw txe txn ^pos ang len' pos
pop % txw txe txn ^pos ang len'
exch % txw txe txn ^pos len' ang
180 add 360 mod % txw txe txn ^pos len' angm
exch % txw txe txn ^pos angm len'
2 index % txw txe txn ^pos angm len' ^pos
3 1 roll % txw txe txn ^pos ^pos angm len'
3 array astore % txw txe txn ^pos txm
exch % txw txe txn txm ^pos
pop % txw txe txn txm
% (middle-tox) ==
% dup ==
% (end create-toxes) ==
} def
%%% PICTURE PROCEDURES
% Consumes: a procedure that draws lines for a picture.
% Produces: a picture-procedure that consumes a lens [colors tox] and draws a picture.
/create-picture { % ls * dp
% (create-picture begin) ==
[ exch % ls * [ dp
{ % ls dp
gsave % ls dp
exch % dp ls
aload pop % dp cs tx
% (create-picture picture execution begin) ==
% (tox) ==
% dup ==
aload pop % dp cs pos ang len
3 -1 roll % dp cs ang len pos
aload pop % dp cs ang len x y
translate % dp cs ang len
dup % dp cs ang len len
scale % dp cs ang
rotate % dp cs
0 get % dp c
exch % c dp
exec %
grestore %
% (end create-picture picture execution) ==
} /exec cvx
] cvx
% (end create-picture) ==
} def
% Consumes: 4 pictures
% Produces: a single picture (lens -> drawing)
/quad-tri { % ls * pw pe pn pm
% (quad-tri begin) ==
[ % ls * pw pe pn pm [
5 1 roll % ls * [ pw pe pn pm
{ % ls pw pe pn pm
5 -1 roll % pw pe pn pm ls
aload pop % pw pe pn pm cs tx
% (quad-tri picture execution begin) ==
% (tox) ==
% dup ==
create-toxes % pw pe pn pm cs txw txe txn txm
4 index % pw pe pn pm cs txw txe txn txm cs
4 1 roll % pw pe pn pm cs txw cs txe txn txm
3 index % pw pe pn pm cs txw cs txe txn txm cs
3 1 roll % pw pe pn pm cs txw cs txe cs txn txm
2 index % pw pe pn pm cs txw cs txe cs txn txm cs
exch % pw pe pn pm cs txw cs txe cs txn cs txm
2 array astore % pw pe pn pm cs txw cs txe cs txn lsm
8 1 roll % pw pe pn lsm pm cs txw cs txe cs txn
2 array astore % pw pe pn lsm pm cs txw cs txe lsn
8 1 roll % pw pe lsn pn lsm pm cs txw cs txe
2 array astore % pw pe lsn pn lsm pm cs txw lse
8 1 roll % pw lse pe lsn pn lsm pm cs txw
2 array astore % pw lse pe lsn pn lsm pm lsw
8 1 roll % lsw pw lse pe lsn pn lsm pm
exec % lsw pw lse pe lsn pn
exec % lsw pw lse pe
exec % lsw ps
exec %
% (end quad-tri picture execution) ==
} /exec cvx
] cvx
% (end quad-tri) ==
} def
/inv-color { % ls * p
[ exch % ls * [ p
{ % ls p
exch % p ls
aload pop % p cs tx
exch % p tx cs
aload pop % p tx c1 c2
exch % p tx c2 c1
2 array astore % p tx cs'
exch % p cs' tx
2 array astore % p ls'
exch % ls' p
exec
} /exec cvx
] cvx
} def
% Consumes: a picture
% Produces: a picture
/self-tri {
% (self-tri begin) ==
dup
dup
dup
inv-color
quad-tri
% (end self-tri) ==
} def
% Consumes: a picture
% Produces: a picture
/diamond { % ls * p
[ exch % ls * [ p
{ % ls p
exch % p ls
dup % p ls ls
aload pop % p ls cs tx
aload pop % p ls cs pos ang len
2 copy % p ls cs pos ang len ang len
5 2 roll % p ls cs ang len pos ang len
step-point % p ls cs ang len pos'
3 1 roll % p ls cs pos' ang len
exch % p ls cs pos' len ang
180 add 360 mod % p ls cs pos' len ang'
exch % p ls cs pos' ang' len
3 array astore % p ls cs tx'
2 array astore % p ls ls'
2 index % p ls ls' p
exec % p ls
exch % ls p
exec
} /exec cvx
] cvx
} def
/diamant { % ls * pn ps
[ 3 1 roll % ls * [ pn ps
{ % ls pn ps
3 -1 roll % pn ps ls
dup % pn ps ls ls
aload pop % pn ps ls cs tx
aload pop % pn ps ls cs pos ang len
exch % pn ps ls cs pos len ang
300 add 360 mod % pn ps ls cs pos len ang'
exch % pn ps ls cs pos ang' len
3 array astore % pn ps ls cs tx'
2 array astore % pn ps ls ls'
3 -1 roll % pn ls ls' ps
inv-color % pn ls ls' ps'
exec % pn ls
exch % ls pn
exec
} /exec cvx
] cvx
} def
% Consumes: a picture
% Produces: a picture
/skip-top { % p
dup dup % p p p
/blank load % p p p _
exch % p p _ p
inv-color
quad-tri % p'
} def
% Consumes: a picture
% Produces: a picture
/skip-2 { % p
dup dup % p p p
/blank load % p p p _
3 1 roll % p _ p p
inv-color
quad-tri % p'
} def
% Consumes: a picture
% Produces: a picture
/skip-tri { % p
/blank load % p _
% west
dup % p _ _
2 index % p _ _ p
dup dup % p _ _ p p p
inv-color % p _ _ p p p'
quad-tri % p _ w
stack
3 1 roll % w p _
% east (skip what, north?)
1 index % w p _ p
dup dup % w p _ p p p
3 index % w p _ p p p _
exch % w p _ p p _ p
inv-color % w p _ p p _ p'
quad-tri % w p _ e
3 1 roll % w e p _
% north
1 index % w e p _ p
dup dup % w e p _ p p p
3 index % w e p _ p p p _
3 1 roll % w e p _ p _ p p
inv-color % w e p _ p _ p p'
quad-tri % w e p _ n
3 1 roll % w e n p _
% middle
pop % w e n p
dup dup dup % w e n p p p p
inv-color % w e n p p p p'
quad-tri % w e n m
quad-tri
} def
%%% PICTURES
/blank { pop } def
/birb-picture { draw-birb } create-picture def
/some-tox [ [100 300] 0 400 ] def
/other-tox [ [250 186.602539] 240 100 ] def
/some-colors [
[ 1 1 1 ] % white
[ 0.4 0.4 0.4 ] % dark grey
]
def
/some-lens [ some-colors some-tox ] def
%some-lens /birb-picture load self-tri dup skip-top exch skip-2 diamant exec
some-lens /birb-picture load exec
% gswin64 -sDEVICE=pdfwrite -o limit-4.pdf 3-color-fish.ps
%%Trailer
%%Pages: 1
%%EOF