ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Alan BRASLAU <alan.braslau@cea.fr>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: \startuseMPgraphic
Date: Mon, 11 Apr 2016 16:30:56 -0600	[thread overview]
Message-ID: <20160411163056.307e48b0@cea.fr> (raw)
In-Reply-To: <570C089A.3070905@gmail.com>

Thank you Wolfgang, this is a very good explanation.


One can simplify one's code, perhaps, by defining MP colors from
ConTeXt colors, as in:
	color orange ; orange := \MPcolor{orange} ;
Then,  one can use orange. There is not much point in redefining the
other colors (red, green, blue, cyan, magenta, yellow, black, white) as
they are defined using the same rgb values.

In fact, \MPcolor{} simply injects "(r,g,b)" or "(c,m,y,k)" with
explicit values into the MP code.

Defining new MP colors is less general than explicitly using
\MPcolor{...}, for it is limiting, and it would be somewhat silly to
add definitions for all of the wonderful colors found in colo-imp-x11,
for example.

By the way, we added colo-imp-crayola having some funky, hallucinogenic
names (according to Hans) as well as colo-imp-ral.
(The first might be of interest to Americans and the second to
Europeans ;-)

Other collections, such as colo-imp-pantone and colo-imp-rosco are not
distributed due to copyright restrictions (but I have made private
copies, shhh!)

Alan




On Mon, 11 Apr 2016 22:27:06 +0200
Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:

> 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}}".

___________________________________________________________________________________
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
___________________________________________________________________________________

  reply	other threads:[~2016-04-11 22:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1460368801.12686.ntg-context@ntg.nl>
2016-04-11 13:10 ` \startuseMPgraphic Jeong Dal
2016-04-11 14:17   ` \startuseMPgraphic Alan BRASLAU
2016-04-11 14:38     ` \startuseMPgraphic Meer, Hans van der
2016-04-11 17:16       ` \startuseMPgraphic Aditya Mahajan
2016-04-11 19:50         ` \startuseMPgraphic Meer, Hans van der
2016-04-11 20:27           ` \startuseMPgraphic Wolfgang Schuster
2016-04-11 22:30             ` Alan BRASLAU [this message]
2016-04-11 22:52               ` Warnings while compiling pdf after update L.S.-Soc&Gam
2016-04-11 23:07                 ` Hans Hagen
2016-04-11 23:00               ` \startuseMPgraphic Aditya Mahajan
2016-04-11  8:35 \startuseMPgraphic Meer, Hans van der
2016-04-11 12:42 ` \startuseMPgraphic Wolfgang Schuster
2016-04-11 13:30   ` \startuseMPgraphic Meer, Hans van der
2016-04-11 14:12     ` \startuseMPgraphic Wolfgang Schuster

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=20160411163056.307e48b0@cea.fr \
    --to=alan.braslau@cea.fr \
    --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).