From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/94384 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: \startuseMPgraphic Date: Mon, 11 Apr 2016 22:27:06 +0200 Message-ID: <570C089A.3070905@gmail.com> References: <6F480A64-E220-4B9F-A2C2-87E0049042B2@me.com> <20160411081715.36e2c239@cea.fr> <81D8AB9F-83C8-452E-A392-02B7416873EC@uva.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2553230723038578962==" X-Trace: ger.gmane.org 1460406483 19544 80.91.229.3 (11 Apr 2016 20:28:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Apr 2016 20:28:03 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Apr 11 22:27:51 2016 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1apiR5-0001kv-EQ for gctc-ntg-context-518@m.gmane.org; Mon, 11 Apr 2016 22:27:51 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id F166BA359; Mon, 11 Apr 2016 22:27:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w_GM0_p8Vghx; Mon, 11 Apr 2016 22:27:22 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 59AEBA354; Mon, 11 Apr 2016 22:27:22 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 47EFDA33E for ; Mon, 11 Apr 2016 22:27:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7UQ0NtQ_Haik for ; Mon, 11 Apr 2016 22:27:20 +0200 (CEST) Original-Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id EDCD0A332 for ; Mon, 11 Apr 2016 22:27:09 +0200 (CEST) Original-Received: by mail-wm0-f45.google.com with SMTP id v188so101340774wme.1 for ; Mon, 11 Apr 2016 13:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to; bh=k7bwFUl4nGMvS3I7v0TYgGYQ07+weKJ27xt7lVPyn28=; b=y8/DSOkLSH4/BkHooSucB4brV0w6IR4Q3HGd28K2sFgajtHDExdREgsDfq87aaBhru wer53aT9LKbDJ23AB+5cuae5L0fqt327DKr6shTrFw91WOtUuDGx5lI+GKGgHTb+7WYW V/K5N5l8/Borct2ddlOKBC0SSoeVyiUE78YlMa8UOHNA/nKR8TXFEeFV0YQ1rnl45wIn YxvVZzoLLvmDVXs74EgOHI9uIC6R3TLP9Ta3bNqmTmN0dVnKw31aWBk3LUB0W6Ynx67j tFuNDgiM6ZMP+FGHr4kbmH7biU3ZqAvablnxbPg07XsQhvgYg/J03IwAtnF2VOPNM+Gw 45mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to; bh=k7bwFUl4nGMvS3I7v0TYgGYQ07+weKJ27xt7lVPyn28=; b=e8vZzBIZTumh7PY1RCtb5l4A8rBMPWS2slOYGO+wv6S/G3Ig6FLF38POZFTSz+XrYT CCdWpL+F8gnThG+FRFZmQGBshEm41PQlOohQUQ7S3ktG4PRjV6pdOqz4YJIMnYZRjq7s jBik8jVdYKvdLS0y568lljG/GfguxUU/J+o6wA72NDsZKLTUQUokVn6SrthF8E0h1uUT e8LQObqylXkEVVSdXy6Yx3fEGUgYODJAuh1hrK+kmFP1UHrLJjbrHBi9IxKKl+n5UOQY 5jLNfbFJXS5MG+6DxbhM28c3fqCAMKUI771dtSM2WTFHyFeGVzlqfGa5j1JYSNNBbQmU s+pA== X-Gm-Message-State: AD7BkJJd12NXCM+YzprsPBEXCrlXGiDWxx+POyhaEs03Km7iQGIFigezIVkPDCrc92AtQw== X-Received: by 10.194.3.20 with SMTP id 20mr29423967wjy.59.1460406429390; Mon, 11 Apr 2016 13:27:09 -0700 (PDT) Original-Received: from keima.localdomain (x2f21c8e.dyn.telefonica.de. [2.242.28.142]) by smtp.gmail.com with ESMTPSA id jo6sm29634494wjb.48.2016.04.11.13.27.08 for (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Apr 2016 13:27:08 -0700 (PDT) User-Agent: Postbox 4.0.8 (Macintosh/20151105) In-Reply-To: <81D8AB9F-83C8-452E-A392-02B7416873EC@uva.nl> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 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" Xref: news.gmane.org gmane.comp.tex.context:94384 Archived-At: This is a multi-part message in MIME format. --===============2553230723038578962== Content-Type: multipart/alternative; boundary="------------020400040209080203060202" This is a multi-part message in MIME format. --------------020400040209080203060202 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > Meer, Hans van der > 11. April 2016 um 21:50 > But why should typing \MPcolor{\MPvar{color}}be necessary or useful > when \MPvar(color) obviously is sufficient? > Or is there a special reason for the nested macros? Let's separate your question in two separate things, the first is colors. There are two way to define colors for a metapost graphics, the first is to define it with metapost itself. %% begin example \startMPpage color myred ; myred := (1,0,0) ; fill fullcircle scaled 3cm withcolor myred ; \stopMPpage %% end example The disadvantage is that you can use this color only in your graphics but not in your tex code. Now comes the second method where I define the color in tex with the \definecolor command and access it in metapost with the color \MPcolor command. %% begin example \definecolor[myred][r=1] \startMPpage fill fullcircle scaled 3cm withcolor \MPcolor{myred} ; \stopMPpage %% end example The second part of the questions concerns metapost variables. %% begin example \startuseMPgraphic{mycircle}{diameter,color} fill fullcircle scaled \MPvariable{diameter} withcolor \MPvariable{color} ; \stopuseMPgraphic \startTEXpage \useMPgraphic{mycircle}{diameter=3cm,color=red} \stopTEXpage %% end example The second argument of the \startuseMPgraphic command initializes the variables of your command and the \MPvariable accesses the value of the variable. In this case "color" is only the name of the variable and doesn't tell if we want a tex defined color or a metapost defined color. In my example the color has to be defined in metapost because after expansion we end with "withcolor red" in the example. We you want a color which has been defined in tex you have put \MPcolor around the \MPvariable command, i.e. "\MPcolor{\MPvariable{color}}". Wolfgang --------------020400040209080203060202 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
11. April 2016 um 21:50
But why should typing \MPcolor{\MPvar{color}}be necessary or useful when \MPvar(color) obviously is sufficient?
Or is there a special reason for the nested macros?
Let’s separate your question in two separate things, the first is colors.

There are two way to define colors for a metapost graphics, the first is to define it with metapost itself.

%% begin example
\startMPpage
color myred ; myred := (1,0,0) ;
fill fullcircle scaled 3cm withcolor myred ;
\stopMPpage
%% end example

The disadvantage is that you can use this color only in your graphics but not in your tex code.

Now comes the second method where I define the color in tex with the \definecolor command and access it in metapost with the color \MPcolor command.

%% begin example
\definecolor[myred][r=1]

\startMPpage
fill fullcircle scaled 3cm withcolor \MPcolor{myred} ;
\stopMPpage
%% end example


The second part of the questions concerns metapost variables.

%% begin example
\startuseMPgraphic{mycircle}{diameter,color}
fill fullcircle scaled \MPvariable{diameter} withcolor \MPvariable{color} ;
\stopuseMPgraphic

\startTEXpage
\useMPgraphic{mycircle}{diameter=3cm,color=red}
\stopTEXpage
%% end example

The second argument of the \startuseMPgraphic command initializes
the variables of your command and the \MPvariable accesses the value
of the variable. In this case "color" is only the name of the variable
and doesn’t tell if we want a tex defined color or a metapost defined color.

In my example the color has to be defined in metapost because after
expansion we end with "withcolor red" in the example. We you want
a color which has been defined in tex you have put \MPcolor around
the \MPvariable command, i.e. "\MPcolor{\MPvariable{color}}".

Wolfgang
--------------020400040209080203060202-- --===============2553230723038578962== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============2553230723038578962==--