summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/epsf/bboxgrid.ps
blob: 7db6828817c87b49b5b9206e5b9bdbe46d198a06 (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
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
%!PS-Adobe
%%BoundingBox: 0 0 612 792
%%% ====================================================================
%%%  @PostScript-file{
%%%     author          = "Nelson H. F. Beebe",
%%%     version         = "1.01",
%%%     date            = "22 January 1994",
%%%     time            = "23:33:36 MST",
%%%     filename        = "bboxgrid.ps",
%%%     address         = "Center for Scientific Computing
%%%                        Department of Mathematics
%%%                        University of Utah
%%%                        Salt Lake City, UT 84112
%%%                        USA
%%%                        Tel: +1 801 581 5254
%%%                        FAX: +1 801 581 4148",
%%%     checksum        = "57568 317 1097 8973",
%%%     email           = "beebe@solitude.math.utah.edu (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "grid, measure, calibration",
%%%     supported       = "yes",
%%%     docstring       = "This PostScript file produces a numbered grid
%%%                        measured in PostScript units of big points
%%%                        for the determination of correct bounding
%%%                        boxes of other PostScript files.
%%%
%%%                        Accurate bounding box measurements are
%%%                        required if the PostScript is to be included
%%%                        in other PostScript documents, such as via
%%%                        the TeX \special{} command.
%%%
%%%                        While PostScript by default places the (0,0)
%%%                        origin at the lower-left page corner,
%%%                        variations of several points will be found in
%%%                        different printers, even between identical
%%%                        models from the same vendor.
%%%
%%%                        To correctly determine the BoundingBox of an
%%%                        arbitrary PostScript figure, overlay a
%%%                        printed copy of the figure on the grid
%%%                        produced by this file on the SAME printer,
%%%                        and measure from it the coordinates of the
%%%                        lower-left and upper-right corners.  These
%%%                        four integers should be entered in the
%%%                        PostScript file as a comment of the form
%%%
%%%                        %%BoundingBox: llx lly urx ury
%%%
%%%                        This comment should be placed near the
%%%                        beginning, preferably right after the initial
%%%                        line that should start %! or %!PS-Adobe...
%%%
%%%                        The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert
%%%                        Solovay's checksum utility.",
%%%  }
%%% ====================================================================

%%% 1.01 [22-Jan-1994]  add top label, and bp axis labels
%%% 1.00 [22-Nov-1991]  original version

/TickSize 5 def
/TickStep 5 def
/TickFontSize 9 def

/Frame                                  % x y width height Frame
{
        /height exch def
        /width exch def
        /y exch def
        /x exch def
        newpath
        x y moveto
        width 0 rlineto
        0 height rlineto
        width neg 0 rlineto
        closepath
        stroke

        x y width TickStep TickSize TickX
        x y width TickStep TickSize NumberX
        x y height add width TickStep TickSize neg TickX
        x y height add width TickStep TickSize neg NumberX
        x y height TickStep TickSize TickY
        x y height TickStep TickSize NumberY
        x width add y height TickStep TickSize neg TickY
        x width add y height TickStep TickSize neg NumberY
        x y 25 25 width height Grid
} def

/Grid                                   % x y dx dy width height Grid
{
        /Gheight exch def
        /Gwidth exch def
        /Gdy exch def
        /Gdx exch def
        /Gy exch def
        /Gx exch def

        Gx
        Gdx
        Gx Gwidth add
        {
                newpath
                Gy moveto
                0 Gheight rlineto
                closepath
                stroke
        }
        for

        Gy
        Gdy
        Gy Gheight add
        {
                newpath
                Gx exch moveto
                Gwidth 0 rlineto
                closepath
                stroke
        }
        for
} def


/NumberX                                % x y length dx tick NumberX
{
        /Helvetica findfont TickFontSize scalefont setfont
        /Ttick exch def
        /Tdx exch def
        /Tlength exch def
        /Ty exch def
        /Tx exch def

        /temp 12 string def
        Tx
        Tdx 5 mul
        Tx Tlength add
        {
                dup
                Ty moveto               % Tx already on stack
                Ttick 0 lt
                { 0 TickFontSize 0.5 mul rmoveto }
                { 0 TickFontSize -1.5 mul rmoveto }
                ifelse
                temp cvs
                dup stringwidth pop -2 div 0 rmoveto
                show
        }
        for
} def

/NumberY                                % x y length dy tick NumberY
{
        /Helvetica findfont TickFontSize scalefont setfont
        /Ttick exch def
        /Tdy exch def
        /Tlength exch def
        /Ty exch def
        /Tx exch def

        /temp 12 string def
        Ty
        Tdy 5 mul
        Ty Tlength add
        {
                dup
                Tx exch moveto          % Ty already on stack
                Ttick neg TickFontSize -2 div rmoveto
                temp cvs
                Ttick 0 gt
                { dup stringwidth pop neg 0 rmoveto }
                if
                show
        }
        for
} def

/TickX                                  % x y length dx tick TickX
{
        /Ttick exch def
        /Tdx exch def
        /Tlength exch def
        /Ty exch def
        /Tx exch def

        Tx
        Tdx
        Tx Tlength add
        {
                dup
                newpath
                Ty moveto               % Tx already on stack
                cvi Tdx 5 mul cvi mod 0 eq% draw tick, double length every 5th
                { Ttick 2 mul }
                { Ttick }
                ifelse
                0
                exch
                rlineto
                closepath
                stroke
        }
        for
} def

/TickY                                  % x y length dy tick TickY
{
        /Ttick exch def
        /Tdy exch def
        /Tlength exch def
        /Ty exch def
        /Tx exch def

        Ty
        Tdy
        Ty Tlength add
        {
                dup
                newpath
                Tx exch moveto          % Ty already on stack
                cvi Tdy 5 mul cvi mod 0 eq% draw tick, double length every 5th
                { Ttick 2 mul }
                { Ttick }
                ifelse
                0
                rlineto
                closepath
                stroke
        }
        for
} def

/inch
{
        72 mul
} def

/mm
{
        72 mul 25.4 div
} def

% (string) CenterCenterShow -- show centered at currentpoint
/CenterCenterShow
{
        dup stringwidth pop -2 div TickFontSize -2 div rmoveto show
} def

% (string) RightCenterShow -- show right-centered at currentpoint
/RightCenterShow
{
        dup stringwidth pop neg TickFontSize -2 div rmoveto show
} def

% (string) LeftCenterShow -- show right-centered at currentpoint
/LeftCenterShow
{
        0 TickFontSize -2 div rmoveto show
} def

% Select ONE of these pairs of page dimensions

% ISO A4-format paper
% /PageWidth   210 mm def
% /PageHeight  297 mm def

% US A-format paper
/PageWidth   8.5 inch def
/PageHeight 11.0 inch def

% Make grid lines half the normal thickness
currentlinewidth 0.5 mul setlinewidth

% Title the grid
/Helvetica-Bold findfont TickFontSize scalefont setfont
PageWidth 2 div 25 moveto
(bboxgrid.ps [Version 1.01] [22 January 1994]) dup
CenterCenterShow

PageWidth 2 div 780 moveto
CenterCenterShow

% You can change this line to make a different grid.  The values
% should all be multiples of 25.
% The values 50 50 525 700 are appropriate for an Apple LaserWriter II.
% x  y width height Frame
50 50   525    700 Frame

% label bottom horizontal axis at each end
50 30 moveto
(bp) CenterCenterShow
575 30 moveto
(bp) CenterCenterShow

% label top horizontal axis at each end
50 770 moveto
(bp) CenterCenterShow
575 770 moveto
(bp) CenterCenterShow

% label left vertical axis at each end
25 50 moveto
(bp) RightCenterShow
25 750 moveto
(bp) RightCenterShow

% label right vertical axis at each end
600 50 moveto
(bp) LeftCenterShow
600 750 moveto
(bp) LeftCenterShow

showpage