-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.c
163 lines (162 loc) · 4.15 KB
/
header.c
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
/* File generated by text2c filter from file header.ps
on Wed Jun 28 13:52:16 DST 1995 */
#include <stdio.h>
char *psheader[] = {
"%\n",
"% PS header for umat - SOM to PS converter\n",
"% Version 1.1 Wed June 28 1995\n",
"% Author: Jussi Hynninen <hynde@nucleus.hut.fi>\n",
"100 dict begin\n",
"\n",
"% predefine variables\n",
"/yoff 0 def /xoff 0 def /xstep 0 def /ystep 0 def /y 0 def /radius 0 def\n",
"/yoffset 0 def /xoffset 0 def\n",
"/picwidth 0 def /picheight 0 def\n",
"/doborder false def\n",
"% default font\n",
"/fontname /Helvetica def\n",
"% font size relative to radius\n",
"/fontsize 1.0 def\n",
"\n",
"% default black and white tresholds\n",
"/bt 0.0 def /wt 1.0 def\n",
"\n",
"% labelpallon sade suhteessa hexan sateeseen\n",
"/ballrad 0.2 def\n",
"\n",
"% newline function. Moves the y coordinate to the next line\n",
"/NL \n",
"{ /yoff yoff ystep sub def % next row\n",
" /y y 1 add def % add y by one\n",
" } bind def\n",
"\n",
"% start of line (for hexagonal lattice) - moves the current position in \n",
"% x direction to the correct place of the line\n",
"/XSH\n",
"{ xoff \n",
" y 4 mod\n",
" dup 3 eq {pop 1} if\n",
" xstep 2 div mul\n",
" add\n",
" yoff moveto % move to start of line\n",
"} bind def\n",
"\n",
"% start of line (for rectangular lattice) - moves the current position in \n",
"% x direction to the correct place of the line\n",
"/XSR { xoff yoff moveto } bind def\n",
"\n",
"% set label color. If block is light -> label is black and same for dark block\n",
"/sbc { .5 gt {0} {1} ifelse setgray } bind def\n",
"\n",
"% set gray level\n",
"/G { \n",
" 100 div dup bt le {pop 0}\n",
" { dup wt ge {pop 1} {bt sub wt bt sub div} ifelse\n",
" } ifelse\n",
"} bind def\n",
"\n",
"% unlabelled node\n",
"/LN { \n",
" gsave\n",
" G sbc\n",
" currentpoint radius ballrad mul 0 360 arc fill \n",
" grestore\n",
" xstep 2 mul 0 rmoveto\n",
"} bind def\n",
"\n",
"%select font\n",
"/selfont {\n",
" fontname findfont radius fontsize mul scalefont setfont\n",
"} bind def\n",
"\n",
"% print single label\n",
"\n",
"/LAB { \n",
" gsave\n",
" G sbc\n",
" dup %duplicate string \n",
" stringwidth\n",
" pop fontsize radius mul -0.25 mul exch\n",
" -2 div exch\n",
" rmoveto\n",
" show\n",
" grestore\n",
" xstep 2 mul 0 rmoveto\n",
"} bind def\n",
"\n",
"% print multiple labels on one unit\n",
"/ML {\n",
" gsave\n",
" G sbc\n",
" /numlabs exch def %number of labels\n",
" numlabs\n",
" 2 div \n",
" 0.25 sub\n",
" radius fontsize mul mul neg\n",
" 0 exch rmoveto\n",
" 1 1 numlabs {\n",
" pop\n",
" gsave\n",
" dup %duplicate string \n",
" stringwidth\n",
" pop \n",
" -2 div 0\n",
" rmoveto\n",
" show\n",
" grestore\n",
" 0 fontsize radius mul rmoveto\n",
" } for \n",
" grestore\n",
" xstep 2 mul 0 rmoveto\n",
"} bind def\n",
"\n",
"% print hexagon\n",
"/H { \n",
" gsave\n",
" G dup setgray %duplicate gray level\n",
" currentpoint translate\n",
" newpath 0 radius moveto\n",
" 5 {60 rotate 0 radius lineto} repeat\n",
" closepath\n",
" doborder { gsave fill grestore sbc stroke}\n",
" { fill pop } ifelse\n",
" grestore \n",
" xstep 0 rmoveto\n",
"} bind def\n",
"\n",
"% print rectangle\n",
"/R {\n",
" gsave\n",
" G dup setgray %duplicate gray level\n",
" currentpoint translate\n",
" newpath\n",
" xstep 0.5 mul dup moveto\n",
" xstep neg 0 rlineto\n",
" 0 xstep neg rlineto\n",
" xstep 0 rlineto\n",
" closepath\n",
" doborder { gsave fill grestore sbc stroke}\n",
" { fill pop } ifelse\n",
" grestore \n",
" xstep 0 rmoveto\n",
"} bind def\n",
"\n",
"% swap x\n",
"/swapx {\n",
"/xstep xstep neg def\n",
"/xoffset picwidth xoffset sub def\n",
"} bind def\n",
"\n",
"%swap y\n",
"/swapy {\n",
"/ystep ystep neg def\n",
"/yoffset picheight yoffset sub def\n",
"} bind def\n",
"\n",
"1 setlinewidth\n",
"\n",
"% End of umat PS header\n",
"% Start image\n",
"\n",
"\n",
NULL};