function plotgeneralmap_rgb_L1tri(x,e,map)

% plotgeneralmap_bw_L1tri(x,e,map)
%            displays a black-and-white map (material topology function).

ne = size(e,2);
minmap = min(map);
% minmap = 1;
maxmap = max(map);

figure
hold on
h = patch('Vertices',x','Faces',e','FaceVertexCData',map','FaceColor','flat');
set(h,'LineStyle','none');
colorbar
axis image
hold off
return

for i=1:ne
    ei = e(:,i);

    xi1 = x(:,ei(1));
    xi2 = x(:,ei(2));
    xi3 = x(:,ei(3));
       
    c = (map(i)-minmap)/(maxmap-minmap);
    if c<=1/4
        rgb = [0,4*c,1];
    elseif c>1/4 && c<=1/2
        rgb = [0,1,2-4*c];
    elseif c>1/2 && c<=3/4
        rgb = [4*c-2,1,0];
    else
        rgb = [1,4-4*c,0];
    end
%    r = 2*max(0,c-1/2); g = 4*max(0,c-r/2-1/4); b = 4*max(0,c-r/2-g/4);
    h = fill([xi1(1),xi2(1),xi3(1)],[xi1(2),xi2(2),xi3(2)],rgb);
    set(h,'LineStyle','none');
end
hold off
