\startuseMPgraphic
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
On Mon, 11 Apr 2016 22:10:02 +0900
Jeong Dal
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
On 11 Apr 2016, at 16:17, Alan BRASLAU
On Mon, 11 Apr 2016, Meer, Hans van der wrote:
On 11 Apr 2016, at 16:17, Alan BRASLAU
mailto:alan.braslau@cea.fr> 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
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
mailto:alan.braslau@cea.fr> 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
Meer, Hans van der mailto:H.vanderMeer@uva.nl 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
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
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}}".
Hi guys, I updated CTX today and now on every pdf compilation i get two warnings: interfaces > implementor > warning: 'scanners.setmapfile' is redefined interfaces > implementor > warning: 'commands.setmapfile' is redefined so three CTX runs give me six warnings. is there a way to disable them? Greets, Sebastian My system: Win10x64 ConTeXt Version: beta-2016.04.10 23:52 LuaTeX Version: beta-0.95.0
On 4/12/2016 12:52 AM, L.S.-Soc&Gam wrote:
Hi guys,
I updated CTX today and now on every pdf compilation i get two warnings:
interfaces > implementor > warning: 'scanners.setmapfile' is redefined interfaces > implementor > warning: 'commands.setmapfile' is redefined
so three CTX runs give me six warnings. is there a way to disable them?
you have to wait till the update (tomorrow) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
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
participants (7)
-
Aditya Mahajan
-
Alan BRASLAU
-
Hans Hagen
-
Jeong Dal
-
L.S.-Soc&Gam
-
Meer, Hans van der
-
Wolfgang Schuster