Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Aditya Mahajan

On Mon, 11 Apr 2016, Alan BRASLAU wrote:


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 ;-)


These are nice colors. For anyone interested, you can view these using:

\showcolor[crayola]
\showcolor[ral]

I'll update the wiki page on colors.

[BTW, all the links generated using {src:...} on the wiki are wrong. 
First, they point to a really old copy (2014.02.14). I can change the link 
to the bitbucket mirror (by changing the src template), but because of the 
recent reorganization of the source code, all the links will be wrong. So 
all the links to source files will need to be updated manually (or using a 
script).


Aditya
___
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
___

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Alan BRASLAU
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  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
___

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Meer, Hans van der
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?

> On 11 Apr 2016, at 19:16, Aditya Mahajan  wrote:
> 
> On Mon, 11 Apr 2016, Meer, Hans van der wrote:
> 
>> 
>> On 11 Apr 2016, at 16:17, Alan BRASLAU 
>> > wrote:
>> 
>> Remember that ConTeXt colors can be accessed in MP as
>> \MPcolor{orange}
>> 
>> Alan
>> 
>> However with the snippet below I see the default black with MPcolor and the 
>> wanted red with \MPvar. Thus?
>> 
>> Hans van der Meer
>> 
>> \starttext
>> \startuseMPgraphic{example1}{color}
>>   pickup pencircle scaled 1mm;
>>   draw unitsquare scaled 1cm
>>withcolor \MPcolor{color};
> 
> This is looking for a color named 'color'. You need \MPcolor{\MPvar{color}}.
> 
> 
>> \stopuseMPgraphic
>> \startuseMPgraphic{example2}{color}
>>   pickup pencircle scaled 1mm;
>>   draw unitsquare scaled 1cm
>>withcolor \MPvar{color};
>> \stopuseMPgraphic
>> \useMPgraphic{example1}{color=red}
>> \useMPgraphic{example2}{color=red}
>> \stoptext
> 
> Aditya

Hans van der Meer




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

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Aditya Mahajan

On Mon, 11 Apr 2016, Meer, Hans van der wrote:



On 11 Apr 2016, at 16:17, Alan BRASLAU 
> wrote:

Remember that ConTeXt colors can be accessed in MP as
\MPcolor{orange}

Alan

However with the snippet below I see the default black with MPcolor and the 
wanted red with \MPvar. Thus?

Hans van der Meer

\starttext
 \startuseMPgraphic{example1}{color}
   pickup pencircle scaled 1mm;
   draw unitsquare scaled 1cm
withcolor \MPcolor{color};


This is looking for a color named 'color'. You need 
\MPcolor{\MPvar{color}}.




 \stopuseMPgraphic
 \startuseMPgraphic{example2}{color}
   pickup pencircle scaled 1mm;
   draw unitsquare scaled 1cm
withcolor \MPvar{color};
 \stopuseMPgraphic
 \useMPgraphic{example1}{color=red}
 \useMPgraphic{example2}{color=red}
\stoptext


Aditya
___
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
___

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Meer, Hans van der

On 11 Apr 2016, at 16:17, Alan BRASLAU 
> wrote:

Remember that ConTeXt colors can be accessed in MP as
\MPcolor{orange}

Alan

However with the snippet below I see the default black with MPcolor and the 
wanted red with \MPvar. Thus?

Hans van der Meer

\starttext
  \startuseMPgraphic{example1}{color}
pickup pencircle scaled 1mm;
draw unitsquare scaled 1cm
 withcolor \MPcolor{color};
  \stopuseMPgraphic
  \startuseMPgraphic{example2}{color}
pickup pencircle scaled 1mm;
draw unitsquare scaled 1cm
 withcolor \MPvar{color};
  \stopuseMPgraphic
  \useMPgraphic{example1}{color=red}
  \useMPgraphic{example2}{color=red}
\stoptext




mpcolor.pdf
Description: mpcolor.pdf
___
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
___

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Alan BRASLAU
On Mon, 11 Apr 2016 22:10:02 +0900
Jeong Dal  wrote:

> BTW, if I change “orange” to “red” or “green”, it is working fine. I
> think that  “orange” is not the predefined color. There is no color
> “orange” in the  MetaFun manual either.

Defined MP colors are:

color black, white, red, green, blue, cyan, magenta, yellow

As a "bonus", orange is defined by default for ConTeXt in
colo-imp-rgb.mkiv
(it is also defined in colo-imp-x11.mkiv, etc.)

Remember that ConTeXt colors can be accessed in MP as
\MPcolor{orange}

Alan
___
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
___

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Wolfgang Schuster

Meer, Hans van der 
11. April 2016 um 15:30
Thanks Wolfgang.
It appears my memory did some "wishful thinking" in wanting 
\startuseMPgraphic{name}{key=value}. Although that would have been nice.
You get a document with the syntax of metapost related commands when you 
type


context --extra=setups metapost

on the command line.

Wolfgang
___
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
___

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Meer, Hans van der
Thanks Wolfgang.
It appears my memory did some "wishful thinking" in wanting 
\startuseMPgraphic{name}{key=value}. Although that would have been nice.
Hans van der Meer

On 11 Apr 2016, at 14:42, Wolfgang Schuster 
> wrote:

Meer, Hans van der
11. April 2016 um 10:35
I seem to remember the following variations in \startuseMPgraphic.

(1) \startuseMPgraphic{name}{comma separated list of variables}
(2) \startuseMPgraphic{name}{comma separated list of key=value pairs}
In the second case one is able to set a default value to that variable, 
possibly to be overridden with \useMPgraphic{name}{key=value}.
I very much would like to specify default values on the \startuseMPgraphic 
definition of the graphic.

However, I cannot get option (2) working. Do I have a bad memory (possible of 
course ;-), Has it to be done otherwise?

\startuseMPgraphic{hans}{color}
  pickup pencircle scaled 1mm;
  draw unitsquare scaled 1cm withcolor \MPvar{color};
\stopuseMPgraphic

\setupMPvariables[hans][color=red]

\starttext

\useMPgraphic{hans}

\useMPgraphic{hans}{color=blue}

\stoptext

Wolfgang

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

[NTG-context] \startuseMPgraphic

2016-04-11 Thread Jeong Dal
Dear Hans van der Meer,

Thank you for your sample code.
I learned how to pass the value of the variables.
BTW, if I change “orange” to “red” or “green”, it is working fine. I think that 
 “orange” is not the predefined color. There is no color “orange” in the  
MetaFun manual either.

Thank you.

Best regards, 
Dalyoung


> \starttext
> \startuseMPgraphic{myname1}{color}
>  pickup pencircle scaled 1mm;
>  draw unitsquare scaled 1cm withcolor \MPvar{color};
> \stopuseMPgraphic
> 
> \startuseMPgraphic{myname2}{color=red}
>  pickup pencircle scaled 1mm;
>  draw unitsquare scaled 1cm withcolor \MPvar{color};
> \stopuseMPgraphic
> 
> \useMPgraphic{myname1}{color=blue}
> \useMPgraphic{myname2}{color=orange}
> 
> \stoptext
> 
> Hans van der Meer
> 

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

Re: [NTG-context] \startuseMPgraphic

2016-04-11 Thread Wolfgang Schuster

Meer, Hans van der 
11. April 2016 um 10:35
I seem to remember the following variations in \startuseMPgraphic.

(1) \startuseMPgraphic{name}{comma separated list of variables}
(2) \startuseMPgraphic{name}{comma separated list of key=value pairs}
In the second case one is able to set a default value to that 
variable, possibly to be overridden with \useMPgraphic{name}{key=value}.
I very much would like to specify default values on the 
\startuseMPgraphic definition of the graphic.


However, I cannot get option (2) working. Do I have a bad memory 
(possible of course ;-), Has it to be done otherwise?
In the example below the graphic myname1 is ok, but myname2 gives the 
following error:

metapost > error:
>> orange
! Improper type.

   ;
<*> ...raw unitsquare scaled 1cm withcolor orange;

minimal example:

\starttext
\startuseMPgraphic{myname1}{color}
  pickup pencircle scaled 1mm;
  draw unitsquare scaled 1cm withcolor \MPvar{color};
\stopuseMPgraphic

\startuseMPgraphic{myname2}{color=red}
  pickup pencircle scaled 1mm;
  draw unitsquare scaled 1cm withcolor \MPvar{color};
\stopuseMPgraphic

\useMPgraphic{myname1}{color=blue}
\useMPgraphic{myname2}{color=orange}

\stoptext

\startuseMPgraphic{hans}{color}
  pickup pencircle scaled 1mm;
  draw unitsquare scaled 1cm withcolor \MPvar{color};
\stopuseMPgraphic

\setupMPvariables[hans][color=red]

\starttext

\useMPgraphic{hans}

\useMPgraphic{hans}{color=blue}

\stoptext

Wolfgang
___
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
___

[NTG-context] \startuseMPgraphic

2016-04-11 Thread Meer, Hans van der
I seem to remember the following variations in \startuseMPgraphic.

(1) \startuseMPgraphic{name}{comma separated list of variables}
(2) \startuseMPgraphic{name}{comma separated list of key=value pairs}
In the second case one is able to set a default value to that variable, 
possibly to be overridden with \useMPgraphic{name}{key=value}.
I very much would like to specify default values on the \startuseMPgraphic 
definition of the graphic.

However, I cannot get option (2) working. Do I have a bad memory (possible of 
course ;-), Has it to be done otherwise?
In the example below the graphic myname1 is ok, but myname2 gives the following 
error:
metapost> error:
>> orange
! Improper type.

   ;
<*> ...raw unitsquare scaled 1cm withcolor orange;

minimal example:

\starttext
\startuseMPgraphic{myname1}{color}
  pickup pencircle scaled 1mm;
  draw unitsquare scaled 1cm withcolor \MPvar{color};
\stopuseMPgraphic

\startuseMPgraphic{myname2}{color=red}
  pickup pencircle scaled 1mm;
  draw unitsquare scaled 1cm withcolor \MPvar{color};
\stopuseMPgraphic

\useMPgraphic{myname1}{color=blue}
\useMPgraphic{myname2}{color=orange}

\stoptext

Hans van der Meer

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