summaryrefslogtreecommitdiff
path: root/support/pstools/ps_conv/ps_conv.ps
blob: 103dc72ac3d2de419fb786717f1939f059ed4f89 (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
%!PS-Adobe-2.0
%%Subject: PostScript prolog for converting PostScript files into 
%%Subject: a canonical EPS form, acceptable by such programs as
%%Subject: CorelDRAW!(R), Adobe Illustrator(TM) and Fontographer(R).
%%Copyright: (c) BOP s.c. 1993--1999
%%Public domain
%%Version: 0.54
%%LastUpdate: Wednesday, January 5th, 2000
%%BeginProcSet: ps_conv.ps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Authors:   P. Pianowski and B. Jackowski
% Address:   BOP s.c., ul. Piastowska 70, 80-363 Gda\'nsk, Poland
%            bop@bop.com.pl
% History:
% ver. 0.50, Friday, October 27th, 1995:
%      * first official public domain release
% October 30th, 1995:
%      * GC.BAT and GC.PAR touched
% ver. 0.52, Wednesday, April 10th, 1996
%      * oper_kind added to degenerated paths (i.e. containing only
%        `m' operation)
%      * paper format commands neutralized
%      * new parameter called PREC added; decimal numbers are printed with 
%        precision PREC (default PREC=3; max. 3 digits follow period)
% ver. 0.53, Friday, November 8th, 1996
%      * the bug in `print_rounded' fixed: numbers of the form `0.0123' i.e.
%        with leading zeros following the period were badly printed.
% ver. 0.54, Wednesday, January 5th, 2000
%      * the file `gc_head' has been improved, paths beeng eofilled
%        and eoclipped are closed explicity
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/ExportDict 100 dict def ExportDict begin
%
% command line parameters:
systemdict /SCALE known {/SCALE SCALE def} {/SCALE 10 def} ifelse
systemdict /XOFF known {/XOFF XOFF def} {/XOFF 0 def} ifelse
systemdict /YOFF known {/YOFF YOFF def} {/YOFF 0 def} ifelse
systemdict /DASHED known {/DASHED true def} {/DASHED false def} ifelse
systemdict /DOS known
  {/print_new_line {<0D0A> print} def}
  {/print_new_line {<0A> print} def} ifelse
systemdict /PREC known {/PREC PREC def} {/PREC 3 def} ifelse
% end of parameters
%
statusdict begin 
  /letter {} def
  /note {} def
  /legal {} def
  /a3 {} def
  /a4 {} def
  /a5 {} def
  /a6 {} def
  /b4 {} def
  /b5 {} def
  /flsa {} def
  /flse {} def
  /halfletter {} def
  /11x17 {} def
  /ledger {} def
  /setpageparams {pop pop pop pop} def
  /setpage {pop pop pop} def
end
%
/val_str 20 string def
/epsilon 0.001 def
SCALE dup matrix scale setmatrix
/curr_matr matrix currentmatrix def
/default_matr curr_matr def
/xl 100000 def
/yl 100000 def
/xh -100000 def
/yh -100000 def
/save_bb {ExportDict begin xl yl xh yh end} def
/restore_bb {ExportDict begin /yh exch def /xh exch def
  /yl exch def /xl exch def end} def
/ori_restore /restore load def
/restore {ExportDict begin save_bb 5 -1 roll ori_restore restore_bb end} def
%
% <x> <y> set_bb <x> <y>
/set_bb {ExportDict begin 
  dup yl lt {dup /yl exch def} if
  dup yh gt {dup /yh exch def} if
  exch
  dup xl lt {dup /xl exch def} if
  dup xh gt {dup /xh exch def} if
  exch
  end} def
%
/accuracy 10 PREC neg exp def
/accuracy_mask (00000000000000000000000000000000000000000000000)
  0 PREC 1 add getinterval def
/print_rounded {ExportDict begin
  dup abs 0.000001 lt {pop (0) print} {accuracy div round
  dup abs 16#7FFFFFFF gt {pop (INTEGER OUT of RANGE!\n) ori_print quit} if
  cvi
  /minus_sign false def dup 0 lt {neg /minus_sign true def} if
  %
  dup /int_to_pull exch def /dig_to_pull 0 def
  {int_to_pull 0 eq {exit} if
  /mod_to_pull int_to_pull 10 mod def
  mod_to_pull 0 eq {/dig_to_pull dig_to_pull 1 add def
  /int_to_pull int_to_pull 10 idiv def} {exit} ifelse} loop
  %
  /fractional_dig PREC dig_to_pull sub 0 max def
  minus_sign {(-) print} if
  val_str cvs 
  %
% dup length PREC le {/leading_zeros accuracy_mask def %% !! ERROR
  dup length PREC le {/leading_zeros PREC 1 add string def
  leading_zeros 0 accuracy_mask putinterval
  %
  leading_zeros exch
  dup length PREC 1 add exch sub exch putinterval leading_zeros} if
  dup dup length PREC sub 0 exch getinterval print
  fractional_dig 0 eq {pop} {(.) print
  dup length PREC sub fractional_dig getinterval
  print} ifelse} ifelse end} def
/print_scaled_x {ExportDict begin SCALE div XOFF sub print_rounded end} def
/print_scaled_y {ExportDict begin SCALE div YOFF sub print_rounded end} def
%
% <s0>..<sn> <r> n_print
/n_print {ExportDict begin -1 1 {-1 roll print_rounded ( ) print} for end} def
%
/p_trans {ExportDict begin /r_param exch def
  r_param -1 roll dup /trans_x exch def r_param 1 roll
  /r_param r_param 1 sub def
  r_param -1 roll dup /trans_y exch def r_param 1 roll
  trans_x trans_y curr_matr transform
  set_bb
  exch
  print_scaled_x ( ) print
  print_scaled_y ( ) print
  end} def
%
/check_point {ExportDict begin
  x_1 curr_x sub dup mul
  y_1 curr_y sub dup mul add sqrt epsilon ge 
  end} def
%
/ori_currentcmykcolor /currentcmykcolor load def
/ori_gsave /gsave load def
/ori_grestore /grestore load def
/ori_moveto /moveto load def
/ori_curveto /curveto load def
/ori_lineto /lineto load def
/ori_closepath /closepath load def
%
/my_moveto {ExportDict begin 
  matrix currentmatrix curr_matr ne {/curr_matr matrix currentmatrix def} if
  /y_start exch def
  /x_start exch def
  /curr_x x_start def
  /curr_y y_start def
  oper_to_send {oper_kind dup (s) eq {pop (S)} if print print_new_line} if
  /oper_to_send true def
  curr_x curr_y
  2 p_trans
  (m) print print_new_line
  ori_moveto
  end} def
/my_curveto {ExportDict begin
  /y_1 exch def /x_1 exch def
  check_point
  {
  x_1 y_1
  6 p_trans
  4 p_trans
  2 p_trans
  (c) print print_new_line
  /curr_x x_1 def
  /curr_y y_1 def
  }
  {x_1 y_1} ifelse
  ori_curveto
  end} def
/my_lineto {ExportDict begin
  /y_1 exch def /x_1 exch def
  check_point
  {
  x_1 y_1
  2 p_trans
  (l) print print_new_line
  /curr_x x_1 def
  /curr_y y_1 def
  }
  {x_1 y_1} ifelse
  ori_lineto
  end} def
/my_closepath {ExportDict begin 
  curr_x curr_y y_start ne exch x_start ne or 
  {x_start y_start 2 p_trans (l) print print_new_line ori_lineto} if
  oper_kind print print_new_line
  /oper_to_send false def
  ori_closepath
  end} def
/gsave {ExportDict begin (q) print print_new_line ori_gsave end} def
/grestore {ExportDict begin(Q) print print_new_line ori_grestore end} def
%
/show {ExportDict begin
  ori_gsave 
  currentfont [1 0 0 1 0 0] makefont setfont
  false charpath currentpoint
  (*u) print print_new_line
  ori_currentcmykcolor 4 n_print (k) print print_new_line
  /oper_kind (f) def /oper_to_send false def
  {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
  oper_to_send {oper_kind print print_new_line} if
  (*U) print print_new_line
  ori_grestore
  newpath moveto
  end} def
/eofill {ExportDict begin
  ori_gsave
  closepath
  (*u) print print_new_line
  ori_currentcmykcolor 4 n_print (k) print print_new_line
  /oper_kind (f) def /oper_to_send false def
  {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
  oper_to_send {oper_kind print print_new_line} if
  (*U) print print_new_line
  ori_grestore newpath
  end} def
/eoclip {ExportDict begin 
  ori_gsave
  closepath
  (*u) print print_new_line
  /oper_kind (h W n) def /oper_to_send false def
  {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
  oper_to_send {oper_kind print print_new_line} if
  (*U) print print_new_line
  ori_grestore newpath
  end} def
/local_transform{ExportDict begin 0
  default_matr matrix invertmatrix matrix currentmatrix matrix concatmatrix
  aload pop pop pop 0 0 6 array astore transform 
  dup mul exch dup mul add sqrt
  end} def
/print_local_transform{ExportDict begin local_transform print_rounded end} def
/n_print_local {ExportDict begin
  -1 1 {-1 roll print_local_transform ( ) print} for end} def
/stroke {ExportDict begin
  ori_gsave
  (*u) print print_new_line
  currentlinewidth print_local_transform ( w ) print
  currentlinejoin print_rounded ( j ) print
  currentlinecap print_rounded ( J ) print
  currentmiterlimit local_transform dup 1 lt {pop 1} if print_rounded
    ( M ) print
  DASHED {
    print_new_line
    currentdash exch dup length /dashlength exch def
    aload pop ([) print dashlength n_print_local (] ) print print_rounded
    ( d) print} if
  print_new_line
  ori_currentcmykcolor 4 n_print (K) print print_new_line
  /oper_kind (s) def /oper_to_send false def
  {my_moveto} {my_lineto} {my_curveto} {my_closepath} pathforall
  oper_to_send {(S) print print_new_line} if
  (*U) print print_new_line
  ori_grestore newpath
  end} def
/fill /eofill load def
/clip /eoclip load def
%
/out_file (!ps_exp1.ps) (w) file def
/showpage {ExportDict begin
  out_file flushfile
  out_file closefile
  /out_file (!ps_exp2.ps) (w) file def
  (%!PS-Adobe-2.0 EPSF-2.0) print print_new_line
  (%%Creator: GhostScript rev. ) print revision print_rounded print_new_line
  (%%BoundingBox: ) print
    xl print_scaled_x ( ) print
    yl print_scaled_y ( ) print
    xh print_scaled_x ( ) print
    yh print_scaled_y print_new_line
  (%%EndComments) print print_new_line
  out_file flushfile
  out_file closefile
  quit
  end} def
/ori_print /print load def
/print {ExportDict begin out_file exch writestring end} def
end
%%EndProcSet: ps_conv.ps
ExportDict begin