[NTG-context] Passing text to Metapost functions

David Arnold dwarnold45 at cox.net
Mon Dec 26 22:17:47 CET 2005


Willi et al,

No luck. I can't get any text to show up. I've spent about three days  
on this, reading, etc., and I'm no closer than I was three days ago.

%output=pdf

\setupcolors[state=start]

\definecolor[gridlines][s=0.7]

\startMPinclusions

color gridlines; gridlines:=\MPcolor{gridlines};

vardef create_grid(expr xxmin,xxmax,xxscl,yymin,yymax,yyscl,uux,uuy)=
   for k=xxmin step xxscl until xxmax:
     draw (xmin*uux,k*uuy)--(xmax*uux,k*uuy) withcolor \MPcolor 
{gridlines};
     draw (k*uux,ymin*uuy)--(k*uux,ymax*uuy) withcolor \MPcolor 
{gridlines};
   endfor;
enddef;

vardef create_axes (expr xxmin,xxmax,yymin,yymax,uux,uuy) (text xlbl)  =
   drawdblarrow (1.05*xxmin*uux,0)--(1.05*xxmax*uux,0);
   draw textext.origin(\MPbetex{xlbl});
   drawdblarrow (0,1.05*yymin*uuy)--(0,1.05*yymax*uuy);
enddef;

\stopMPinclusions

\starttext

\startMPpage

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-5;
xmax:=5;
xscl:=1;
ymin:=-5;
ymax:=5;
yscl:=1;

%initialize scale
numeric ux, uy;
(xmax-xmin)*ux=4in; (ymax-ymin)*uy=3in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,ux,uy);

%create the axes
\setMPtext{1}{x};
create_axes(xmin,xmax,ymin,ymax,ux,uy)(\MPbetex{1});

\stopMPpage

\stoptext

%%% Local Variables:
%%% mode: conTeXt-en
%%% End:


More information about the ntg-context mailing list