From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/24780 Path: news.gmane.org!not-for-mail From: David Arnold Newsgroups: gmane.comp.tex.context Subject: It works, passing text Date: Tue, 27 Dec 2005 12:41:38 -0800 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1135716186 17395 80.91.229.2 (27 Dec 2005 20:43:06 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 27 Dec 2005 20:43:06 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Tue Dec 27 21:43:04 2005 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1ErLew-0006e1-HD for gctc-ntg-context-518@m.gmane.org; Tue, 27 Dec 2005 21:43:02 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 5257012801; Tue, 27 Dec 2005 21:43:01 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22648-05; Tue, 27 Dec 2005 21:42:57 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2680A127EF; Tue, 27 Dec 2005 21:42:57 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 7945A127EF for ; Tue, 27 Dec 2005 21:42:55 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22727-03 for ; Tue, 27 Dec 2005 21:42:54 +0100 (CET) Original-Received: from fed1rmmtao07.cox.net (fed1rmmtao07.cox.net [68.230.241.32]) by ronja.ntg.nl (Postfix) with SMTP id CEE9A127ED for ; Tue, 27 Dec 2005 21:42:53 +0100 (CET) Original-Received: from [10.0.1.2] (really [70.191.56.23]) by fed1rmmtao07.cox.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20051227204207.FQJS3131.fed1rmmtao07.cox.net@[10.0.1.2]> for ; Tue, 27 Dec 2005 15:42:07 -0500 Original-To: Context Mailing List List X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:24780 Archived-At: Taco, I have something that works. Thanks for hanging in there with me. %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,ylbl) = textextoffset:=3pt; picture p; p:=textext.rt(xlbl); p:=p shifted (1.05*xxmax*ux,0); picture q; q:=textext.top(ylbl); q:=q shifted (0,1.05*yymax*uy); drawdblarrow (1.05*xxmin*uux,0)--(1.05*xxmax*uux,0); draw p; drawdblarrow (0,1.05*yymin*uuy)--(0,1.05*yymax*uuy); draw q; enddef; vardef drawf(expr xxmin,xxmax,yymin,yymax,uux,uuy,n)= path p; p:=(xxmin,f(xxmin)); numeric dx; dx=(xxmax-xxmin)/n; for x=xmin step dx until xxmax: p:=p--(x,f(x)); endfor; p:=p--(xxmax,f(xxmax)); path cpath; cpath:=(xxmin,yymin)--(xxmax,yymin)--(xxmax,yymax)--(xxmin,yymax)-- cycle; p:=p cutbefore cpath; p:=reverse p; p:=p cutbefore cpath; p:=p xyscaled (uux,uuy); drawdblarrow p withcolor blue; enddef; \stopMPinclusions \starttext \startMPpage %initialize function vardef f(expr x)= x*x enddef; %initialize window parameters numeric xmin, xmax, xscl, ymin, ymax, yscl; xmin:=-5; xmax:=5; xscl:=1; ymin:=-5; ymax:=5; yscl:=1; %initialize number of points numeric num_points; num_points:=100; %initialize dimensions of image numeric width, height; width=3in; height=3in; %initialize scale numeric ux, uy; (xmax-xmin)*ux=width; (ymax-ymin)*uy=height; %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$")("$y$"); %draw the function drawf(xmin,xmax,ymin,ymax,ux,uy,num_points); \stopMPpage \stoptext %%% Local Variables: %%% mode: conTeXt-en %%% End: