On Mon, 7 Oct 2013 09:06:37 +0200
Magnus J <mjo.li...@gmail.com> wrote:

> 2. I would like to use the \followtokens macro from within metapost. How
> can this be achieved? Specifically, I trying to draw a rainbow-like figure
> with text "between" the colors.

I am not sure what you mean by a rainbow-like figure. However, for rainbow-like 
colors, I use the following MP code, based on the standard resistance color 
code scheme. The function rainbow(f) returns a rainbow spectrum color based on 
the fraction f running from 0 to 1.

% standard resistance color code: rainbow sequence
color resistance_color[] ;                      string resistance_name[] ;
resistance_color0 = (0,0,0) ;                   resistance_name0 = "black" ;
resistance_color1 = (165/255,42/255,42/255) ;   resistance_name1 = "brown" ;
resistance_color2 = (1,0,0) ;                   resistance_name2 = "red" ;
resistance_color3 = (1,165/255,0) ;             resistance_name3 = "orange" ;
resistance_color4 = (1,1,0) ;                   resistance_name4 = "yellow" ;
resistance_color5 = (0,1,0) ;                   resistance_name5 = "green" ;
resistance_color6 = (0,0,1) ;                   resistance_name6 = "blue" ;
resistance_color7 = (148/255,0,211/255) ;       resistance_name7 = "darkviolet" 
;
resistance_color8 = (190/255,190/255,190/255) ; resistance_name8 = "gray" ;
resistance_color9 = (1,1,1) ;                   resistance_name9 = "white" ;

def rainbow(expr f) =
    hide(numeric n_ ; n_ = (abs(5f) mod 5) + 2 ;)
    (n_-floor(n_))[resistance_color[floor n_],resistance_color[ceiling n_]]
enddef ;


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
___________________________________________________________________________________

Reply via email to