* How to define an array of colors in Metafun
@ 2020-06-20 14:48 Otared Kavian
2020-06-20 15:42 ` Hans Hagen
0 siblings, 1 reply; 2+ messages in thread
From: Otared Kavian @ 2020-06-20 14:48 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi all,
I have a family of graphs to draw in Metapost and I would like to attribute a different color to each of them according to the value of a certain variable.
Assuming that the path mygraph(j) depends on the variable j, which is computed within a lua code and passed to Metapost, I wonder if it is possible to define an array of colors named mycolor, so that I could say
draw mygraph(j) withcolor mycolor(j) ;
Here the variable j takes integer values (say between 1 and 10), and one would have defined mycolor(1) through mycolor(10).
Thanks in advance for any help: Otared K.
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to define an array of colors in Metafun
2020-06-20 14:48 How to define an array of colors in Metafun Otared Kavian
@ 2020-06-20 15:42 ` Hans Hagen
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2020-06-20 15:42 UTC (permalink / raw)
To: mailing list for ConTeXt users, Otared Kavian
On 6/20/2020 4:48 PM, Otared Kavian wrote:
> Hi all,
>
> I have a family of graphs to draw in Metapost and I would like to attribute a different color to each of them according to the value of a certain variable.
> Assuming that the path mygraph(j) depends on the variable j, which is computed within a lua code and passed to Metapost, I wonder if it is possible to define an array of colors named mycolor, so that I could say
>
> draw mygraph(j) withcolor mycolor(j) ;
>
> Here the variable j takes integer values (say between 1 and 10), and one would have defined mycolor(1) through mycolor(10).
\startMPpage
string MyColors[] ;
path MyPaths [] ;
MyPaths[1] := fullcircle scaled 3cm; MyColors[1] := "red";
MyPaths[8] := fullsquare scaled 3cm; MyColors[8] := "green";
draw MyPaths[1] withcolor MyColors[1] ;
draw MyPaths[8] withcolor MyColors[8] ;
\stopMPpage
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-20 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 14:48 How to define an array of colors in Metafun Otared Kavian
2020-06-20 15:42 ` Hans Hagen
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).