function rgbmap = shaded_rgbmake(hue,gray)
% rgbmap = shaded_rgbmake(hue,gray)
% hue is (Nhue) x 1 vector, gray is (Ngray) x 1 vector
% rgbmap is Nhue x Ngray
%
% hues are calculated in degrees around circle. 0=360=red
% gray ranges from 0 (black) to 0.5 (color) to 1.0 (white)
%
% Peter Shaw, WHOI, 11/93

% Peter Shaw, Dec. AGU, 1993
% Woods Hole Oceanographic Institution
% prs@cook.whoi.edu
% 508 457-2000 x2473

Nhues=length(hue);
Ngrays=length(gray);
Ncolors = Nhues*Ngrays;

%Below is minimal table for interpolating basic rainbow series:
TAB = [ 1 0 0; 1 1 0;  0 1 0;  0 1 1; 0 0 1; 1 0 1; 1 0 0 ];
XT  = [     0;    60;    120;    180;   240;   300;   360 ];

[G,H]=meshgrid(gray,hue);
rgbmap0 = interp1(XT,TAB,H(:)); %a little inefficient...
rgbmap=rgbmap0;

Gpos = G > 0.5; Gpos=Gpos(:);
Gneg = G < 0.5; Gneg=Gneg(:);

for ii=1:3, %shockingly crude
rgbmap(Gneg,ii) = rgbmap(Gneg,ii) .* G(Gneg) / 0.5;
rgbmap(Gpos,ii) = rgbmap(Gpos,ii) + ...
( ones(size(rgbmap(Gpos,ii)))-rgbmap(Gpos,ii) ) .* (G(Gpos)-0.5)/0.5;
end
