On Mon, 7 Oct 2013 09:06:37 +0200I 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.
Magnus J <mjo.lists@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.
% 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