ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: David Arnold <dwarnold45@cox.net>
Subject: Re: Passing text to Metapost functions
Date: Mon, 26 Dec 2005 10:04:02 -0800	[thread overview]
Message-ID: <CD8D05FF-290C-4E1E-A9CC-2287A90C5727@cox.net> (raw)
In-Reply-To: <43AFD7AB.7020607@wxs.nl>

Hans,

I've tried various things without much success. I cannot seem to  
access the contents of xlbl below.

Is this approach ever going to work?

Note: I am trying to pass the string "x" to the parameter xlbl.

%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(\MPstring{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
create_axes(xmin,xmax,ymin,ymax,ux,uy)(x);

\stopMPpage

\stoptext

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

  reply	other threads:[~2005-12-26 18:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-26  3:34 David Arnold
2005-12-26 11:44 ` Hans Hagen
2005-12-26 18:04   ` David Arnold [this message]
2005-12-26 20:03     ` Willi Egger
2005-12-26 21:17       ` David Arnold
2005-12-27  8:09     ` Taco Hoekwater
2005-12-27  8:24       ` David Arnold
2005-12-27  8:58         ` Taco Hoekwater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CD8D05FF-290C-4E1E-A9CC-2287A90C5727@cox.net \
    --to=dwarnold45@cox.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).