From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/82359 Path: news.gmane.org!not-for-mail From: Marco Patzer Newsgroups: gmane.comp.tex.context Subject: Re: command for a MP graphic Date: Tue, 7 May 2013 09:51:49 +0200 Message-ID: <20130507075149.GM663@homerow> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1993823040==" X-Trace: ger.gmane.org 1367913132 4813 80.91.229.3 (7 May 2013 07:52:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 May 2013 07:52:12 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Tue May 07 09:52:11 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UZch0-0005HG-Gx for gctc-ntg-context-518@m.gmane.org; Tue, 07 May 2013 09:52:10 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D5C65101E9; Tue, 7 May 2013 09:52:07 +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 QH2yBCKlM5YA; Tue, 7 May 2013 09:52:06 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id EFE6C101E4; Tue, 7 May 2013 09:52:05 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AD21F101E4 for ; Tue, 7 May 2013 09:52:04 +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 2qvI25EgtUn1 for ; Tue, 7 May 2013 09:52:03 +0200 (CEST) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id 9BCB8101E0 for ; Tue, 7 May 2013 09:51:53 +0200 (CEST) Original-Received: from karen.lavabit.com (karen.lavabit.com [72.249.41.33]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r477pqoH025618 for ; Tue, 7 May 2013 09:51:52 +0200 Original-Received: from c.earth.lavabit.com (c.earth.lavabit.com [192.168.111.12]) by karen.lavabit.com (Postfix) with ESMTP id BAE0611BA98 for ; Tue, 7 May 2013 02:51:51 -0500 (CDT) Original-Received: from homerow (83.68.239.193) by lavabit.com with ESMTP id U5XE08YFBOC6 for ; Tue, 07 May 2013 02:51:51 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=Jhp3UtxYlRX2jkOvNwuK9jI1jEJuK3iP02VtdMpGyUiIpyNh+JNQnoSC+EcecSx5ad2cB3P6olYuoYkTqBOz/6ZoVCV3430Pw5ujlD9i6xCa8M9nkiIvUtIYctPAkmswuBOeUKI4jR0rkaFaR5St2+Ji/6n+84k1tosDDuUrv74=; h=Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:X-PGP-Key:User-Agent; Mail-Followup-To: ntg-context@ntg.nl In-Reply-To: X-PGP-Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xB8CFCB65D4F08C27 User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=72.249.41.33; country=US; region=TX; city=Dallas; postalcode=75204; latitude=32.8019; longitude=-96.7883; metrocode=623; areacode=214; http://maps.google.com/maps?q=32.8019,-96.7883&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0QJwTPQp3 - bb177e6d8fbc - 20130507 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 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:82359 Archived-At: --===============1993823040== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HcXnUX77nabWBLF4" Content-Disposition: inline --HcXnUX77nabWBLF4 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2013=E2=80=9305=E2=80=9307 Roland Thiers wrote: > Hi, > I did this code to get a regular polygon with metafun, it works but > I would like to have an user command like \define or \def > to be able to choose the number of sides, n. I don't know how to do > that ... Here's one way to do it: \startuniqueMPgraphic{polygoneregulier}{sides} drawoptions (withpen pencircle scaled 2pt); numeric u ; u:=3D1*cm ; numeric n ; n:=3D\MPvar{sides}; pair a[]; a[0]:=3D(0,3u); path polygone[] ; for i=3D1 upto n : a[i]:=3Da[0] rotatedaround(origin,i*360/n) ; polygone[i]:=3Da[i-1]--a[i]; draw polygone[i]; endfor; draw fullcircle scaled 6u withcolor blue; \stopuniqueMPgraphic %% \polyreg{} \define[1]\polyreg {\setupMPvariables[polygoneregulier][sides=3D#1]%% \uniqueMPgraphic{polygoneregulier}} \starttext \dontleavehmode \dorecurse{9}{\polyreg\recurselevel\space} \stoptext You can extent this to be able to use key-value syntax or default values if you like. Marco --HcXnUX77nabWBLF4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJRiLKVAAoJEPGqVaNSn0iKYsQIAKakqT2D0eF/842PEmVvyRN4 wrTsoCwSYwXXr+ZLsncy4GPS7l6EE5VwtOBjKczpRErEXDKtO+FPcxUIQjcrxz+Z TRkdhv27A0h7tmMETv1ayY2XVF7dt5iTrzme/r3nQuBx4h66YWQcAjNsKRXGLV7p Q9spkOrNzPlnlL7wEfX7YOEmbAnxSFyqCokD1DrndQXK6jIPJqMUYcDTpED8Aa8w zRM9Tign3DU6XnyIjUoojSkrxnvqwJr7Ds4bu5TfwVq3bHBzGjPmUjV5LrKXdeK5 PR44PhuHSq7xo8WrIAoQPa0NLCjDoO5rxr5r71jjX8F0eS1xD+yYM2mDq4lz9XQ= =IZDA -----END PGP SIGNATURE----- --HcXnUX77nabWBLF4-- --===============1993823040== 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 ___________________________________________________________________________________ --===============1993823040==--