function rgb = tri1(n)
% TRI1
%
% rgb = tri1(n) returns an image of an rgb color triangle of width n.

% Author: John S. Loomis (19 March 2000)

x = linspace(-0.02,1.02,n);
x = ones(n,1)*x;
y = flipud(x');
red = x - y/sqrt(3.0);
grn = 2.0*y/sqrt(3.0);
blu = 1.0 - y/sqrt(3.0) -x;
mask = red>=0.0 & red<=1.0 & grn>=0.0 & grn<=1.0 & blu>=0.0 & blu<=1.0;
red = red.*mask;
grn = grn.*mask;
blu = blu.*mask;
rgb = cat(3,red,grn,blu);
k = floor(n - n*sqrt(3.0)/2.);
rgb = rgb(k:n,:,:);


Maintained by John Loomis, last updated 18 March 2000