On 27/07/21 08:12, Gavin via ntg-context wrote:
Hi All,
Getting Closer I asked:
2) While I’m having good luck with paths, colors are causing trouble. In the data set the color information is in strings with French names of the color, like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it into a color. It does work if it is a native color, like “red,” but not if it is a defined color and not if the color is in a Lua variable. Any suggestions?
Aditya suggested:
\definecolor[rouge][red] should work. A better option will be use color palettes.
This solves my problem of translating French colors into English, but not the problem of passing colors from Lua to MetaPost. If the string giving the color name is in a variable, it doesn’t go through. A path in a variable works.
I’ve reduced my MWE below – no French, no MPinclusions, no new colors. Both pie slices should be red, but one is black. Any ideas on getting the color “red” passed from Lua to MetaPost when mycolor=“red”?
I am not looking closely at the code, but in general we use fill fullcircle scaled 1cm withcolor red ; and this takes Metapost's knowledge of red, the rgb triplet (1,0,0). One can also use fill fullcircle scaled 1cm withcolor "red" ; as a string (quotation) and this passes Context's definition of the color. Alan -- Alan