[NTG-context] Re: Draw grid
Hans Hagen
ntg-context@ntg.nl
Sat, 03 Jan 2004 22:13:52 +0100
Hi David,
I added to mp-tool:
% showgrid(-5,10,1cm,-10,10,1cm);
def showgrid (expr MinX, MaxX, DeltaX, MinY, MaxY, DeltaY)=
begingroup
save defaultfont, defaultscale, size ;
string defaultfont ; defaultfont := "cmtt10"; % i.e. infofont
numeric defaultscale ; defaultscale := 8pt / fontsize defaultfont;
numeric size ; size := 2pt ;
for x=MinX upto MaxX :
for y=MinY upto MaxY :
draw (x*DeltaX, y*DeltaY)
withpen pencircle scaled
if (x mod 5 = 0) and (y mod 5 = 0) :
1.5size withcolor .50white
else :
size withcolor .75white
fi ;
endfor ;
endfor ;
for x=MinX upto MaxX:
label.bot(decimal x, (x*DeltaX,-size));
endfor ;
for y=MinY upto MaxY:
label.lft(decimal y, (-size,y*DeltaY)) ;
endfor ;
endgroup
enddef;
I also send you a supp-pdf that does not fail on you example (peculiar
sequence of settings catched)
Hans