% Script ColorInterp
% Shows how to interpolate, saturate, and complement a color.

% Prepare the figure window...
close all
figure
axis off
hold on
% Color initializations...
green = [0 1 0]; % rgb of the "bottom" color
magenta = [1 0 1]; % rgb of the "top" color
n = 9; % the number of "in between" colors is n-1
x = [0 3 3 0]; % locates the x-values in the tiles
y = [0 0 1 1]; % locates the y-values in the tiles
% Add colored tiles to the figure window...
for j=0:n+1
% Display the jth tile and its rgb value...
f = j/(n+1);
v = (1-f)*green + f*magenta;
fill(x,y+j,v)
text(3.5,j+.5,sprintf('[ %4.2f , %4.2f , %4.2f ]',v(1),v(2),v(3)))
% Saturate...
v = v/max(v);
fill(15+x,y+j,v)
text(18.5,j+.5,sprintf('[ %4.2f , %4.2f , %4.2f ]',v(1),v(2),v(3)))
% Complement...
v = [1 1 1] - v;
fill(30+x,y+j,v)
text(33.5,j+.5,sprintf('[ %4.2f , %4.2f , %4.2f ]',v(1),v(2),v(3)))
end
hold off
shg