File: prolog.ps

package info (click to toggle)
sppc 1.0.1-9
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 456 kB
  • ctags: 469
  • sloc: cpp: 4,585; sh: 356; makefile: 63
file content (269 lines) | stat: -rw-r--r-- 9,466 bytes parent folder | download | duplicates (2)
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
" \
%------------------------------------------------ \n \
%--------------Font Definitions------------------ \n \
%------------------------------------------------ \n \
 \n \
% Load ISOLatin font for Times-Roman \n \
/Times-Roman findfont \n \
dup length dict begin \n \
  {1 index /FID ne {def} {pop pop} ifelse} forall \n \
  /Encoding ISOLatin1Encoding def \n \
  currentdict \n \
end \n \
/Times-Roman-ISOLatin1 exch definefont pop \n \
 \n \
% Load ISOLatin font for Times-Bold \n \
/Times-Bold findfont \n \
dup length dict begin \n \
  {1 index /FID ne {def} {pop pop} ifelse} forall \n \
  /Encoding ISOLatin1Encoding def \n \
  currentdict \n \
end \n \
/Times-Bold-ISOLatin1 exch definefont pop \n \
 \n \
% Load ISOLatin font for Helvetica-Roman \n \
/Helvetica-Roman findfont \n \
dup length dict begin \n \
  {1 index /FID ne {def} {pop pop} ifelse} forall \n \
  /Encoding ISOLatin1Encoding def \n \
  currentdict \n \
end \n \
/Helvetica-Roman-ISOLatin1 exch definefont pop \n \
 \n \
% Load ISOLatin font for Helvetica-Bold \n \
/Helvetica-Bold findfont \n \
dup length dict begin \n \
  {1 index /FID ne {def} {pop pop} ifelse} forall \n \
  /Encoding ISOLatin1Encoding def \n \
  currentdict \n \
end \n \
/Helvetica-Bold-ISOLatin1 exch definefont pop \n \
 \n \
/defFontSizeCopyright 6.0 def \n \
 \n \
% Define font definition macros \n \
/setTopLblFont    { TopLblFont    setfont /FH defFontSizeTopLbl store   } def \n \
/setSideLblFont   { SideLblFont   setfont /FH defFontSizeSideLbl store  } def \n \
/setAxisLblFont   { AxisLblFont   setfont /FH defFontSizeAxisLbl store  } def \n \
/setAnnotLblFont  { AnnotLblFont  setfont /FH defFontSizeAnnotLbl store  } def \n \
/setCopyrightFont { CopyrightFont setfont /FH defFontSizeCopyright store} def \n \
 \n \
% Define font locations/offsets (FH=Font height,UP, MIddle, BOTtom, LEFt, CENter, RIGht) \n \
/FH 0 def	% initialize to something \n \
/UP  {0 FH 0.1 mul rmoveto} bind def \n \
/MID {0 FH -0.3 mul rmoveto} bind def \n \
/BOT {0 FH -0.75 mul rmoveto} bind def \n \
/LEF {dup stringwidth pop neg 0 rmoveto} bind def \n \
/CEN {dup stringwidth pop -2 div 0 rmoveto} bind def \n \
/RIG {} def \n \
 \n \
% Define fonts \n \
/TopLblFont    /Helvetica-Bold-ISOLatin1   findfont defFontSizeTopLbl    scalefont def \n \
/SideLblFont   /Helvetica-Bold-ISOLatin1   findfont defFontSizeSideLbl   scalefont def \n \
/AxisLblFont   /Helvetica-Roman-ISOLatin1  findfont defFontSizeAxisLbl   scalefont def \n \
/AnnotLblFont  /Helvetica-Roman-ISOLatin1  findfont defFontSizeAnnotLbl  scalefont def \n \
/CopyrightFont /Helvetica-Bold-ISOLatin1   findfont defFontSizeCopyright scalefont def \n \
 \n \
% Routine for doing exponents \n \
/Exponentshow		% stack: mantissa exponent \n \
{ \n \
	0 begin \n \
	/expo exch def \n \
	/mant exch def \n \
	/regularfont currentfont def \n \
%	/exponentfont currentfont [0.8 0 0 0.7 0 0] makefont def \n \
	/exponentfont currentfont [0.9 0 0 0.8 0 0] makefont def \n \
	% Find the height of the numeral 1 \n \
	gsave \n \
		newpath \n \
		0 0 moveto \n \
		(1) true charpath \n \
		flattenpath \n \
		pathbbox /height exch def pop pop pop \n \
	grestore \n \
	% Print mantissa followed by the exponent \n \
	mant show \n \
	0 0.6 height mul rmoveto \n \
	exponentfont setfont expo show \n \
	0 0.6 height mul neg rmoveto \n \
	regularfont setfont        % return to original font \n \
	end \n \
} def \n \
/Exponentshow load 0 10 dict put \n \
 \n \
%------------------------------------------------ \n \
%--------------Linetype (dash) Definitions------- \n \
%------------------------------------------------ \n \
 \n \
/MLT_GD {[0.5 2] 0 setdash       } def   % GridDotted Line \n \
/MLT0  {[0 1] 0 setdash         } def   % No Line \n \
/MLT1  {[] 0 setdash            } def   % Solid Line \n \
/MLT2  {[6 6] 0 setdash         } def   % Dashed Line \n \
/MLT3  {[1 2] 1 setdash         } def   % Dotted Line \n \
/MLT4  {[6 2 2 2] 0 setdash     } def   % Dot-Dash Line \n \
/MLT5  {[2 2] 0 setdash         } def   % Long-dotted Line \n \
/MLT6  {[2 2 2 6] 0 setdash     } def   % Double-dotted Line \n \
/MLT7  {[8 2] 0 setdash         } def   % Long-dashed Line \n \
/MLT8  {[9 6 2 6] 0 setdash     } def   % Dot-Dashed Line \n \
/MLT9  {[1 1 1 1 1 3] 0 setdash } def   % Triple-dot Line \n \
/MLT10 {[3 3 3 3 6 3] 0 setdash } def   % DotDotDash Line \n \
 \n \
%------------------------------------------------ \n \
%---------------Flat quadrilateral--------------- \n \
%------------------------------------------------ \n \
 \n \
/FlatQuad		% stack: x y dx dy \n \
{ \n \
	gsave \n \
	newpath \n \
	4 -2 roll moveto		% moveto x,y; now stack contains dx dy \n \
	dup 0 exch rlineto exch 0 rlineto neg 0 exch rlineto \n \
	closepath \n \
	fill \n \
	grestore \n \
} bind def \n \
 \n \
% FlatQuad is partial emulation of rectfill for systems (Level 1) without rectfill \n \
/rectfill where {/FQ /rectfill load def} {pop /FQ /FlatQuad load def} ifelse \n \
 \n \
%------------------------------------------------ \n \
%--------------Interpolated quadrilateral-------- \n \
%------------------------------------------------ \n \
 \n \
/min {2 copy gt {exch} if pop} bind def \n \
/max {2 copy lt {exch} if pop} bind def \n \
 \n \
% IC = set Indexed Color \n \
/IC		% stack: color index -> () \n \
{ \n \
	/u exch def \n \
	RE u get GR u get BL u get setrgbcolor \n \
} bind def \n \
 \n \
/Triangle				% stack: x1 y1 x2 y2 x3 y3 u1 u2 u3 --> () \n \
{ \n \
	0 begin \n \
	/u3 exch def \n \
	/u2 exch def \n \
	/u1 exch def \n \
	/y3 exch def \n \
	/x3 exch def \n \
	/y2 exch def \n \
	/x2 exch def \n \
	/y1 exch def \n \
	/x1 exch def \n \
	gsave \n \
	% Form triangle path, find is bounding box in xmin,xmax,ymin,ymax, and set it to clip \n \
	newpath \n \
	x1 y1 moveto \n \
	x2 y2 lineto \n \
	x3 y3 lineto \n \
	closepath \n \
	% Test if u1==u2==u3; if so, draw flat triangle (avoiding division by zero) \n \
	u1 u2 eq u2 u3 eq and \n \
	{ \n \
		% Draw flat triangle \n \
		u1 IC \n \
		fill \n \
	} { \n \
		clip \n \
		pathbbox \n \
		/ymax exch def \n \
		/xmax exch def \n \
		/ymin exch def \n \
		/xmin exch def \n \
		% u = a + b*x + c*y, find a,b,c from conditions u(x1,y1)=u1, u(x2,y2)=u2, u(x3,y3)=u3 \n \
		/denom x2 y1 mul  x3 y1 mul  sub  x1 y2 mul  sub  x3 y2 mul  add  x1 y3 mul  add  x2 y3 mul  sub def \n \
		/a u3 x2 mul y1 mul  u2 x3 mul y1 mul  sub  u3 x1 mul y2 mul  sub  u1 x3 mul y2 mul  \n \
			add  u2 x1 mul y3 mul  add  u1 x2 mul y3 mul sub denom div def \n \
		/b u2 y1 mul  u3 y1 mul sub  u1 y2 mul sub  u3 y2 mul add u1 y3 mul add u2 y3 mul sub denom div def \n \
		/c u2 x1 mul  u3 x1 mul  sub  u1 x2 mul  sub  u3 x2 mul  add  u1 x3 mul  add  u2 x3 mul  sub  denom neg div def \n \
		/umin u1 u2 min u3 min def \n \
		/umax u1 u2 max u3 max def \n \
		% Epsilon is the spatial resolution we target at. Default is 1 unit (point, 1/72 inch). \n \
		% Notice that epsilon can be larger than the true resolution of the printer without compromising quality. \n \
		/epsilon 1 def \n \
		c abs b abs gt		% abs(c) > abs(b) ? \n \
		{ \n \
			/step epsilon c abs mul ceiling cvi 1 max def \n \
			/aplusbxmin a b xmin mul add def \n \
			/aplusbxmax a b xmax mul add def \n \
			/invc 1 c div def \n \
			umin step umax { \n \
				/ua exch def \n \
				/ub ua step add def \n \
				% y = (ua - a - b*x)/c \n \
				newpath \n \
				xmin ua aplusbxmin sub invc mul moveto \n \
				xmax ua aplusbxmax sub invc mul lineto \n \
				xmax ub aplusbxmax sub invc mul lineto \n \
				xmin ub aplusbxmin sub invc mul lineto \n \
				closepath \n \
				ua IC \n \
				fill \n \
			} for \n \
		} {			% no, abs(c) <= abs(b). \n \
			/step epsilon b abs mul ceiling cvi 1 max def \n \
			/apluscymin a c ymin mul add def \n \
			/apluscymax a c ymax mul add def \n \
			/invb 1 b div def \n \
			umin step umax { \n \
				/ua exch def \n \
				/ub ua step add def \n \
				% x = (ua - a - c*y)/b \n \
				newpath \n \
				ua apluscymin sub invb mul ymin moveto \n \
				ua apluscymax sub invb mul ymax lineto \n \
				ub apluscymax sub invb mul ymax lineto \n \
				ub apluscymin sub invb mul ymin lineto \n \
				closepath \n \
				ua IC \n \
				fill \n \
			} for \n \
		} ifelse \n \
	} ifelse \n \
	grestore \n \
	end \n \
} def \n \
/Triangle load 0 30 dict put \n \
 \n \
% Q means quadrilateral \n \
/Q			% stack: x1 y1 dx dy u1 u2 u3 u4 -> (), u1,u2,u3,u4 counterclockwise from x1,y1 \n \
{ \n \
	0 begin \n \
	/u4 exch def \n \
	/u3 exch def \n \
	/u2 exch def \n \
	/u1 exch def \n \
	/dy exch def \n \
	/dx exch def \n \
	/y1 exch def \n \
	/x1 exch def \n \
	gsave \n \
	x1 y1 translate \n \
	/xc dx 0.5 mul def \n \
	/yc dy 0.5 mul def \n \
	/uc u1 u2 add u3 add u4 add 0.25 mul round cvi def \n \
	0 0 dx 0 xc yc u1 u2 uc Triangle \n \
	dx 0 xc yc dx dy u2 uc u3 Triangle \n \
	dx dy 0 dy xc yc u3 u4 uc Triangle \n \
	0 0 xc yc 0 dy u1 uc u4 Triangle \n \
	grestore \n \
	end \n \
} def \n \
/Q load 0 30 dict put \n \
 \n \
%------------------------------------------------ \n \
%--------------Space-saving abbreviations-------- \n \
%------------------------------------------------ \n \
 \n \
% Defined above: IC=IndexedColor, FQ=FlatQuad, Q=Quad, FH=FontHeight, UP, MID, BOT, LEF, CEN, RIG \n \
/C {setrgbcolor} bind def \n \
/G {setgray}     bind def \n \
/L {lineto}      bind def \n \
/M {moveto}      bind def \n \
/N {newpath}     bind def \n \
/R {rlineto}     bind def \n \
/S {stroke}      bind def \n \
 \n \
"