1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{MetaPost Graphics Grids}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36\startuseMPgraphic{meta:grd:basegrid}
37 begingroup ;
38
39 save nx, ny, dx, dy, ox, oy, sx, sy ;
40
41 sc := \directdummyparameter\c!factor\directdummyparameter\c!scale ;
42 nx := \directdummyparameter\c!nx ;
43 ny := \directdummyparameter\c!ny ;
44 dx := \MPdpar\directdummyparameter\c!dx sc ;
45 dy := \MPdpar\directdummyparameter\c!dy sc ;
46 ox := \MPdpar\directdummyparameter\c!xoffset ;
47 oy := \MPdpar\directdummyparameter\c!yoffset ;
48 sx := \directdummyparameter\c!xstep ;
49 sy := \directdummyparameter\c!ystep ;
50
51 if "\directdummyparameter\c!align" = "\v!middle" :
52 ax := dx 2 ;
53 ay := dy 2 ;
54 else :
55 ax := 0 ;
56 ay := 0 ;
57 fi ;
58
59 draw lmt_grid [ nx = nx, ny = ny, dx = 1, dy = 1 ]
60 xyscaled (dx,dy) shifted (ax, ay)
61 withpen pencircle scaled \MPdpar\directdummyparameter\c!rulethickness\space
62 withcolor "\directdummyparameter\c!rulecolor" ;
63
64 draw image (
65 if sx > 0 :
66 for i=1 step sx until nx :
67 draw thetextext.bot(decimal i,(idxax,oy));
68 endfor ;
69 fi ;
70 if sy > 0 :
71 for i=1 step sy until ny :
72 draw thetextext.lft(decimal i,(ox,idyay)) ;
73 endfor ;
74 fi ;
75 )
76 withcolor "\directdummyparameter\c!color" ;
77
78 endgroup ;
79\stopuseMPgraphic
80
81\permanent\tolerant\protected\def\basegrid[#1]
82 {\dontleavehmode
83 \hbox\bgroup
84 \getdummyparameters
85 [\c!nx=10,\c!ny=10,
86 \c!dx=.5,\c!dy=.5,
87 \c!xstep=0,\c!ystep=0,
88 \c!unit=\s!cm,\c!scale=1,\c!factor=1,
89 \c!offset=.25\exheight,
90 \c!xoffset=\directdummyparameter\c!offset,
91 \c!yoffset=\directdummyparameter\c!offset,
92 \c!align=,
93 \c!color=\currentcolorname,
94 \c!rulecolor=\currentcolorname,
95 \c!rulethickness=\linewidth,
96 #1]
97 \usedummystyleandcolor\c!style\c!color
98 \setexpandeddummyparameter\c!dx{\directdummyparameter\c!dx\directdummyparameter\c!unit}
99 \setexpandeddummyparameter\c!dy{\directdummyparameter\c!dy\directdummyparameter\c!unit}
100 \useMPgraphic{meta:grd:basegrid}
101 \egroup}
102
103\aliased\let\grid\basegrid
104
105\protect \endinput
106 |