From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/87451 Path: news.gmane.org!not-for-mail From: Fabrice Couvreur Newsgroups: gmane.comp.tex.context Subject: Metapost and Metafun Date: Wed, 21 May 2014 19:55:50 +0200 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1635064262==" X-Trace: ger.gmane.org 1400694979 4760 80.91.229.3 (21 May 2014 17:56:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 May 2014 17:56:19 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed May 21 19:56:15 2014 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WnAkO-0004PU-FR for gctc-ntg-context-518@m.gmane.org; Wed, 21 May 2014 19:56:12 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 732AF10203 for ; Wed, 21 May 2014 19:56:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LJGKKb1hBJ4c for ; Wed, 21 May 2014 19:56:11 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 25CB51021F for ; Wed, 21 May 2014 19:56:07 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D92C9101E3 for ; Wed, 21 May 2014 19:56:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5aZSGXpU16Yy for ; Wed, 21 May 2014 19:56:00 +0200 (CEST) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by balder.ntg.nl (Postfix) with ESMTP id A6103101E2 for ; Wed, 21 May 2014 19:55:52 +0200 (CEST) Original-Received: from mail-ie0-x233.google.com (mail-ie0-x233.google.com [IPv6:2607:f8b0:4001:c03::233]) by filter3-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id s4LHtoqQ002896 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 21 May 2014 19:55:51 +0200 Original-Received: by mail-ie0-f179.google.com with SMTP id rd18so2280905iec.24 for ; Wed, 21 May 2014 10:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=zVsR10+ZGeTxWgldBP92CiOiAdfjizFzTEFqcdh5+ro=; b=Z/V6tewZAPv4XvEEamlx5DrJkJGX7IC5/OKAVHy4NdbR09BC5rU7ArX+2iNQ3sMK07 AyjEmuLLREg/++K0HVZbQrEqRm+9Kxw5/C3WrzjVTRT1HqOLr30PT7tlZTP/lAYrEkrQ qn1zmeB95afBhmVyxo/0eISopVuxe0Glxvai1ypjssmEJtuJXd1/FLbM5H6hp8sb4xS6 QedDWnVWBtNS20SXTabCEhD3v7UnHuvwUDg2aj+ol7iK/CKDRraCQOeWKEycD4HHQ4D+ h5o5yerCOQuPcVenm3+uYvRelgmues9nd5a9O0hH1zYoMESOaTi0i5x46xgTv3FL4b5U Fung== X-Received: by 10.42.214.143 with SMTP id ha15mr19741262icb.59.1400694950109; Wed, 21 May 2014 10:55:50 -0700 (PDT) Original-Received: by 10.50.194.133 with HTTP; Wed, 21 May 2014 10:55:50 -0700 (PDT) X-Bayes-Prob: 0.0001 (Score 0, tokens from: ntg-context@ntg.nl, base:default, @@RPTN) X-CanIt-Geo: ip=2607:f8b0:4001:c03::233; country=US X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 03M4FTPIQ - 39820ba94d23 - 20140521 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:87451 Archived-At: --===============1635064262== Content-Type: multipart/alternative; boundary=20cf301d439af0a7ad04f9ecb43d --20cf301d439af0a7ad04f9ecb43d Content-Type: text/plain; charset=UTF-8 Hi, As PSTricks (which I prefer) is not yet well integrated, I decided to learn Metapost starting with a simple code. \starttext \startMPcode numeric xmin, xmax, ymin, ymax; xmin := -2.5; xmax := 2.5; ymax :=2.5 ;ymin:=-2.5; u := 2cm; vardef f(expr x) = -x*x+1 enddef; xinc := 0.001; path pts_f; pts_f := (xmin,f(xmin))*u for x=xmin+xinc step xinc until xmax+xinc: .. (x,f(x))*u endfor; path axe_x,axe_y; path screen; screen=(xmin,ymin)*u--(xmax,ymin)*u--(xmax,ymax)*u--(xmin,ymax)*u--cycle; axe_x = (xmin,0)*u -- (xmax,0)*u; axe_y = (0,ymin)*u -- (0,ymax)*u; drawarrow axe_x; drawarrow axe_y; draw pts_f withpen pencircle scaled 1; clip currentpicture to screen; \stopMPcode \stoptext Are there any routines with Metafun to improve this code? thank you, Fabrice --20cf301d439af0a7ad04f9ecb43d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,
As PSTricks (which I prefer) is= not yet well integrated, I decided to learn Metapost starting with a simple code.
\starttext
\startMPcode
numeric xmin, xmax, ymin, ymax;
xmin := =3D -2.5; xmax :=3D 2.5; ymax :=3D2.5 ;ymin:=3D-2.5; u :=3D 2cm;
vardef = f(expr x) =3D -x*x+1 enddef;
xinc :=3D 0.001;
path pts_f;
pts_f := =3D (xmin,f(xmin))*u
for x=3Dxmin+xinc step xinc until xmax+xinc:
.. (x,f(x))*u
endfor;path axe_x,axe_y;
path screen;
screen=3D(xmin,ymin)*u--(xmax,ymin)*u= --(xmax,ymax)*u--(xmin,ymax)*u--cycle;
axe_x =3D (xmin,0)*u -- (xmax,0)*= u;
axe_y =3D (0,ymin)*u -- (0,ymax)*u;
drawarrow axe_x;
drawarrow axe_y= ;
draw pts_f withpen pencircle scaled 1;
clip currentpicture to scree= n;
\stopMPcode
\stoptext

Are there any routines = with Metafun to improve this code?
thank you,
Fabric= e
--20cf301d439af0a7ad04f9ecb43d-- --===============1635064262== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============1635064262==--