summaryrefslogtreecommitdiff
path: root/dviware/dvipsconfig/config.psgrid
blob: 86910c49fffe92d50a3c2a118f78121040b30b2a (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
%!
% config.psgrid
% Configuration and header file for dvips. Load with: dvips -P psgrid
%
% Draw a line grid in PostScript's standard coordinate grid.
% The resulting grid can be used for measuring BoundingBoxes.
%
% This code is based on code from the book
%
%	@Book{Merz:PostscriptAcrobatBibel,
%	  author =       "Thomas Merz",
%	  title =        "Die PostScript- und Acrobat-Bibel. Was Sie schon
%	  		 immer {\"u}ber PostScript und Acrobat/{PDF} wissen
%			 wollten",
%	  publisher =    "Thomas Merz Verlag",
%	  year =         "1996",
%	  address =      "M{\"u}nchen",
%	  edition =      "1",
%	  ISBN =         "3-9804943-0-6",
%	}
%	@Book{Merz:PostscriptAcrobatBible,
%	  author =       "Thomas Merz",
%	  title =        "PostScript & acrobat/{PDF}: applications,
%                	 troubleshooting, and cross-platform publishing",
%	  publisher =    "Springer",
%	  year =         "1997",
%	  address =      "Berlin",
%	  ISBN =         "3-540-60854-0",
%	}
%
% The original code can be found in file ps/eps/gitter.ps on the CD which
% accompanies the German edition.
% The original code is copyright (C) Thomas Merz 1994-96.
% Incorporation of the original code into this file is with permission of
% Thomas Merz.
% For further information about the book see http://www.pdflib.com/
%
% This file is built so it can be used both as the header file for
% PostScript and as the configuration file for dvips.
% (Note that dvips ignores any lines beginning with a space or a "%".)
%
% Copyright (C) 1995-2006 by Volker Kuhlmann.
% Released under the terms of the GNU General Public License (GPL) Version 2.
% See http://www.gnu.org/ for details.
%
% Volker Kuhlmann <VolkerKuhlmann@gmx.de>
%   25, 26 Oct 1997; 25 Jan 1998; 9 Mar 2000; 11 May 2006
%
 /dr@wgrid {
 
 save
 25 dict begin
 
 /step     10 def		% grid line increment, in PostScript point
 /medstep  50 def		% solid grid lines every this often
 /numstep 100 def		% numbered grid lines every this often
 
 /FontSize 10 def		% font size of numbers
 
 %initgraphics % don't use - can stuff things up and is not necessary
 newpath 0 setlinecap 0 setlinejoin 10 setmiterlimit
 
 clippath pathbbox newpath
 cvi /ury exch def
 cvi /urx exch def
 10 div floor 10 mul cvi /lly exch def
 10 div floor 10 mul cvi /llx exch def
 urx llx sub /lenx exch def
 ury lly sub /leny exch def
 
 /snaptopixel {
     transform
 	.25 sub round .25 add exch
 	.25 sub round .25 add exch
     itransform
 } bind def
 
 0.01 setlinewidth
 [1 2] 0 setdash		% dashed line
 0 setgray
 /set-line-style {
     dup medstep mod 0 eq { [ ] 0 setdash } if
     %dup 100 mod 0 eq { 0.75 setlinewidth 0.35 setgray } if
     %dup 0 eq { 1.25 setlinewidth } if
     %dup 0 eq { 0.8 setlinewidth } if
     dup numstep mod 0 eq { 0.4 setlinewidth } if
     dup 0 eq { 0.6 setlinewidth } if
 } bind def
 
 llx step urx { %  draw vertical lines
     gsave
     set-line-style
     lly snaptopixel moveto 0 leny snaptopixel rlineto stroke
     grestore
 } for
 
 lly step ury { % draw horizontal lines
     gsave
     set-line-style
     llx exch snaptopixel moveto lenx 0 snaptopixel rlineto stroke
     grestore
 } for
 
 % circle at (0,0)
 [ ] 0 setdash 1 setlinewidth newpath 15 0 moveto 0 0 15 0 360 arc stroke
 
 /kreis { % clip light circle from existing lines
     gsave 1 setgray
     %/d (500) stringwidth pop def
     dup stringwidth pop /d exch def % adjust circle size to string width
     currentpoint FontSize 3 div add exch d 2 div add exch
     d 0.6 mul 0 360 arc
     fill grestore
 } def
 
 % axes labelling font
 /Helvetica-Bold findfont FontSize scalefont setfont
 0.5 setgray
 
 % print axis labelling, X
 llx numstep div floor numstep mul cvi
 numstep urx { % for
     dup 0 eq
     {
       pop
     }{
       dup 20 moveto
       (      ) cvs dup stringwidth pop 2 div neg 0 rmoveto
       kreis show
     } ifelse
 } bind for
 
 % print axis labelling, Y
 lly numstep div floor numstep mul cvi
 numstep ury { % for
     dup 0 eq
     {
       pop
     }{
       40 1 index moveto
       (      ) cvs dup stringwidth pop 
       neg 3 sub FontSize 3 div neg rmoveto
       kreis show
     } ifelse
 } bind for
 
 end restore
 
 } bind def  % dr@wgrid
 
 % %% Hook into dvips-generated PS
 % at start of page:
 %/bop-hook where
 %	{
 %	  pop
 %	  /@ldbophookgrid /bop-hook load def
 %	  /bop-hook { @ldbophookgrid dr@wgrid } def
 %	}{
 %	  /bop-hook { dr@wgrid } def
 %	} ifelse
 % at end of page:
 /eop-hook where
 	{
 	  pop
 	  /@ldeophookgrid /eop-hook load def
 	  /eop-hook { @ldeophookgrid dr@wgrid } def
 	}{
 	  /eop-hook { dr@wgrid } def
 	} ifelse
%
 { % start a procedure so PostScript `ignores' the dvips configuration part.
h config.psgrid
 } pop % PostScript cleanup
%
% EOF config.psgrid